/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-15 15:11:31 UTC
  • mfrom: (2230.3.55 branch6)
  • Revision ID: pqm@pqm.ubuntu.com-20070215151131-1f2ce67d76e40200
Provide new branch6 format

Show diffs side-by-side

added added

removed removed

Lines of Context:
1208
1208
                value_switches=True,
1209
1209
                title="Branch Format",
1210
1210
                ),
 
1211
         Option('append-revisions-only',
 
1212
                help='Never change revnos or the existing log.'
 
1213
                '  Append revisions to it only.')
1211
1214
         ]
1212
 
    def run(self, location=None, format=None):
 
1215
    def run(self, location=None, format=None, append_revisions_only=False):
1213
1216
        if format is None:
1214
1217
            format = bzrdir.format_registry.make_bzrdir('default')
1215
1218
        if location is None:
1232
1235
            existing_bzrdir = bzrdir.BzrDir.open(location)
1233
1236
        except errors.NotBranchError:
1234
1237
            # really a NotBzrDir error...
1235
 
            bzrdir.BzrDir.create_branch_convenience(location, format=format)
 
1238
            branch = bzrdir.BzrDir.create_branch_convenience(location,
 
1239
                                                             format=format)
1236
1240
        else:
1237
1241
            from bzrlib.transport.local import LocalTransport
1238
1242
            if existing_bzrdir.has_branch():
1241
1245
                        raise errors.BranchExistsWithoutWorkingTree(location)
1242
1246
                raise errors.AlreadyBranchError(location)
1243
1247
            else:
1244
 
                existing_bzrdir.create_branch()
 
1248
                branch = existing_bzrdir.create_branch()
1245
1249
                existing_bzrdir.create_workingtree()
 
1250
        if append_revisions_only:
 
1251
            try:
 
1252
                branch.set_append_revisions_only(True)
 
1253
            except errors.UpgradeRequired:
 
1254
                raise errors.BzrCommandError('This branch format cannot be set'
 
1255
                    ' to append-revisions-only.  Try --experimental-branch6')
1246
1256
 
1247
1257
 
1248
1258
class cmd_init_repository(Command):
1547
1557
            dir, relpath = bzrdir.BzrDir.open_containing(location)
1548
1558
            b = dir.open_branch()
1549
1559
 
1550
 
        if revision is None:
1551
 
            rev1 = None
1552
 
            rev2 = None
1553
 
        elif len(revision) == 1:
1554
 
            rev1 = rev2 = revision[0].in_history(b).revno
1555
 
        elif len(revision) == 2:
1556
 
            if revision[1].get_branch() != revision[0].get_branch():
1557
 
                # b is taken from revision[0].get_branch(), and
1558
 
                # show_log will use its revision_history. Having
1559
 
                # different branches will lead to weird behaviors.
 
1560
        b.lock_read()
 
1561
        try:
 
1562
            if revision is None:
 
1563
                rev1 = None
 
1564
                rev2 = None
 
1565
            elif len(revision) == 1:
 
1566
                rev1 = rev2 = revision[0].in_history(b).revno
 
1567
            elif len(revision) == 2:
 
1568
                if revision[1].get_branch() != revision[0].get_branch():
 
1569
                    # b is taken from revision[0].get_branch(), and
 
1570
                    # show_log will use its revision_history. Having
 
1571
                    # different branches will lead to weird behaviors.
 
1572
                    raise errors.BzrCommandError(
 
1573
                        "Log doesn't accept two revisions in different"
 
1574
                        " branches.")
 
1575
                if revision[0].spec is None:
 
1576
                    # missing begin-range means first revision
 
1577
                    rev1 = 1
 
1578
                else:
 
1579
                    rev1 = revision[0].in_history(b).revno
 
1580
 
 
1581
                if revision[1].spec is None:
 
1582
                    # missing end-range means last known revision
 
1583
                    rev2 = b.revno()
 
1584
                else:
 
1585
                    rev2 = revision[1].in_history(b).revno
 
1586
            else:
1560
1587
                raise errors.BzrCommandError(
1561
 
                    "Log doesn't accept two revisions in different branches.")
1562
 
            if revision[0].spec is None:
1563
 
                # missing begin-range means first revision
1564
 
                rev1 = 1
1565
 
            else:
1566
 
                rev1 = revision[0].in_history(b).revno
1567
 
 
1568
 
            if revision[1].spec is None:
1569
 
                # missing end-range means last known revision
1570
 
                rev2 = b.revno()
1571
 
            else:
1572
 
                rev2 = revision[1].in_history(b).revno
1573
 
        else:
1574
 
            raise errors.BzrCommandError('bzr log --revision takes one or two values.')
1575
 
 
1576
 
        # By this point, the revision numbers are converted to the +ve
1577
 
        # form if they were supplied in the -ve form, so we can do
1578
 
        # this comparison in relative safety
1579
 
        if rev1 > rev2:
1580
 
            (rev2, rev1) = (rev1, rev2)
1581
 
 
1582
 
        if log_format is None:
1583
 
            log_format = log.log_formatter_registry.get_default(b)
1584
 
 
1585
 
        lf = log_format(show_ids=show_ids, to_file=self.outf,
1586
 
                        show_timezone=timezone)
1587
 
 
1588
 
        show_log(b,
1589
 
                 lf,
1590
 
                 file_id,
1591
 
                 verbose=verbose,
1592
 
                 direction=direction,
1593
 
                 start_revision=rev1,
1594
 
                 end_revision=rev2,
1595
 
                 search=message)
 
1588
                    'bzr log --revision takes one or two values.')
 
1589
 
 
1590
            # By this point, the revision numbers are converted to the +ve
 
1591
            # form if they were supplied in the -ve form, so we can do
 
1592
            # this comparison in relative safety
 
1593
            if rev1 > rev2:
 
1594
                (rev2, rev1) = (rev1, rev2)
 
1595
 
 
1596
            if log_format is None:
 
1597
                log_format = log.log_formatter_registry.get_default(b)
 
1598
 
 
1599
            lf = log_format(show_ids=show_ids, to_file=self.outf,
 
1600
                            show_timezone=timezone)
 
1601
 
 
1602
            show_log(b,
 
1603
                     lf,
 
1604
                     file_id,
 
1605
                     verbose=verbose,
 
1606
                     direction=direction,
 
1607
                     start_revision=rev1,
 
1608
                     end_revision=rev2,
 
1609
                     search=message)
 
1610
        finally:
 
1611
            b.unlock()
1596
1612
 
1597
1613
 
1598
1614
def get_log_format(long=False, short=False, line=False, default='long'):
2943
2959
    See "help checkouts" for more information on checkouts.
2944
2960
    """
2945
2961
 
2946
 
    takes_args = ['location']
 
2962
    takes_args = ['location?']
2947
2963
    takes_options = []
2948
2964
 
2949
2965
    def run(self, location=None):
2950
2966
        b, relpath = Branch.open_containing(u'.')
 
2967
        if location is None:
 
2968
            try:
 
2969
                location = b.get_old_bound_location()
 
2970
            except errors.UpgradeRequired:
 
2971
                raise errors.BzrCommandError('No location supplied.  '
 
2972
                    'This format does not remember old locations.')
 
2973
            else:
 
2974
                if location is None:
 
2975
                    raise errors.BzrCommandError('No location supplied and no '
 
2976
                        'previous location known')
2951
2977
        b_other = Branch.open(location)
2952
2978
        try:
2953
2979
            b.bind(b_other)