/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: Vincent Ladeuil
  • Date: 2010-10-13 07:55:13 UTC
  • mfrom: (5492 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5501.
  • Revision ID: v.ladeuil+lp@free.fr-20101013075513-hil6q8xi7i9e3ozq
Merge bzr.dev fixing NEWS entry

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.lazy_import import lazy_import
22
22
lazy_import(globals(), """
23
23
import cStringIO
 
24
import itertools
 
25
import re
24
26
import sys
25
27
import time
26
28
 
250
252
    To skip the display of pending merge information altogether, use
251
253
    the no-pending option or specify a file/directory.
252
254
 
253
 
    If a revision argument is given, the status is calculated against
254
 
    that revision, or between two revisions if two are provided.
 
255
    To compare the working directory to a specific revision, pass a
 
256
    single revision to the revision argument.
 
257
 
 
258
    To see which files have changed in a specific revision, or between
 
259
    two revisions, pass a revision range to the revision argument.
 
260
    This will produce the same results as calling 'bzr diff --summarize'.
255
261
    """
256
262
 
257
263
    # TODO: --no-recurse, --recurse options
1063
1069
        Option('strict',
1064
1070
               help='Refuse to push if there are uncommitted changes in'
1065
1071
               ' the working tree, --no-strict disables the check.'),
 
1072
        Option('no-tree',
 
1073
               help="Don't populate the working tree, even for protocols"
 
1074
               " that support it."),
1066
1075
        ]
1067
1076
    takes_args = ['location?']
1068
1077
    encoding_type = 'replace'
1070
1079
    def run(self, location=None, remember=False, overwrite=False,
1071
1080
        create_prefix=False, verbose=False, revision=None,
1072
1081
        use_existing_dir=False, directory=None, stacked_on=None,
1073
 
        stacked=False, strict=None):
 
1082
        stacked=False, strict=None, no_tree=False):
1074
1083
        from bzrlib.push import _show_push_branch
1075
1084
 
1076
1085
        if directory is None:
1122
1131
        _show_push_branch(br_from, revision_id, location, self.outf,
1123
1132
            verbose=verbose, overwrite=overwrite, remember=remember,
1124
1133
            stacked_on=stacked_on, create_prefix=create_prefix,
1125
 
            use_existing_dir=use_existing_dir)
 
1134
            use_existing_dir=use_existing_dir, no_tree=no_tree)
1126
1135
 
1127
1136
 
1128
1137
class cmd_branch(Command):
1505
1514
            title='Deletion Strategy', value_switches=True, enum_switch=False,
1506
1515
            safe='Backup changed files (default).',
1507
1516
            keep='Delete from bzr but leave the working copy.',
 
1517
            no_backup='Don\'t backup changed files.',
1508
1518
            force='Delete all the specified files, even if they can not be '
1509
 
                'recovered and even if they are non-empty directories.')]
 
1519
                'recovered and even if they are non-empty directories. '
 
1520
                '(deprecated, use no-backup)')]
1510
1521
    aliases = ['rm', 'del']
1511
1522
    encoding_type = 'replace'
1512
1523
 
1513
1524
    def run(self, file_list, verbose=False, new=False,
1514
1525
        file_deletion_strategy='safe'):
 
1526
        if file_deletion_strategy == 'force':
 
1527
            note("(The --force option is deprecated, rather use --no-backup "
 
1528
                "in future.)")
 
1529
            file_deletion_strategy = 'no-backup'
 
1530
 
1515
1531
        tree, file_list = WorkingTree.open_containing_paths(file_list)
1516
1532
 
1517
1533
        if file_list is not None:
1538
1554
            file_deletion_strategy = 'keep'
1539
1555
        tree.remove(file_list, verbose=verbose, to_file=self.outf,
1540
1556
            keep_files=file_deletion_strategy=='keep',
1541
 
            force=file_deletion_strategy=='force')
 
1557
            force=(file_deletion_strategy=='no-backup'))
1542
1558
 
1543
1559
 
1544
1560
class cmd_file_id(Command):
1699
1715
                ),
1700
1716
         Option('append-revisions-only',
1701
1717
                help='Never change revnos or the existing log.'
1702
 
                '  Append revisions to it only.')
 
1718
                '  Append revisions to it only.'),
 
1719
         Option('no-tree',
 
1720
                'Create a branch without a working tree.')
1703
1721
         ]
1704
1722
    def run(self, location=None, format=None, append_revisions_only=False,
1705
 
            create_prefix=False):
 
1723
            create_prefix=False, no_tree=False):
1706
1724
        if format is None:
1707
1725
            format = bzrdir.format_registry.make_bzrdir('default')
1708
1726
        if location is None:
1731
1749
        except errors.NotBranchError:
1732
1750
            # really a NotBzrDir error...
1733
1751
            create_branch = bzrdir.BzrDir.create_branch_convenience
 
1752
            if no_tree:
 
1753
                force_new_tree = False
 
1754
            else:
 
1755
                force_new_tree = None
1734
1756
            branch = create_branch(to_transport.base, format=format,
1735
 
                                   possible_transports=[to_transport])
 
1757
                                   possible_transports=[to_transport],
 
1758
                                   force_new_tree=force_new_tree)
1736
1759
            a_bzrdir = branch.bzrdir
1737
1760
        else:
1738
1761
            from bzrlib.transport.local import LocalTransport
1742
1765
                        raise errors.BranchExistsWithoutWorkingTree(location)
1743
1766
                raise errors.AlreadyBranchError(location)
1744
1767
            branch = a_bzrdir.create_branch()
1745
 
            a_bzrdir.create_workingtree()
 
1768
            if not no_tree:
 
1769
                a_bzrdir.create_workingtree()
1746
1770
        if append_revisions_only:
1747
1771
            try:
1748
1772
                branch.set_append_revisions_only(True)
5364
5388
            if tag_name is None:
5365
5389
                raise errors.BzrCommandError("No tag specified to delete.")
5366
5390
            branch.tags.delete_tag(tag_name)
5367
 
            self.outf.write('Deleted tag %s.\n' % tag_name)
 
5391
            note('Deleted tag %s.' % tag_name)
5368
5392
        else:
5369
5393
            if revision:
5370
5394
                if len(revision) != 1:
5382
5406
            if (not force) and branch.tags.has_tag(tag_name):
5383
5407
                raise errors.TagAlreadyExists(tag_name)
5384
5408
            branch.tags.set_tag(tag_name, revision_id)
5385
 
            self.outf.write('Created tag %s.\n' % tag_name)
 
5409
            note('Created tag %s.' % tag_name)
5386
5410
 
5387
5411
 
5388
5412
class cmd_tags(Command):
5397
5421
            help='Branch whose tags should be displayed.'),
5398
5422
        RegistryOption.from_kwargs('sort',
5399
5423
            'Sort tags by different criteria.', title='Sorting',
5400
 
            alpha='Sort tags lexicographically (default).',
 
5424
            natural='Sort numeric substrings as numbers:'
 
5425
                    ' suitable for version numbers. (default)',
 
5426
            alpha='Sort tags lexicographically.',
5401
5427
            time='Sort tags chronologically.',
5402
5428
            ),
5403
5429
        'show-ids',
5407
5433
    @display_command
5408
5434
    def run(self,
5409
5435
            directory='.',
5410
 
            sort='alpha',
 
5436
            sort='natural',
5411
5437
            show_ids=False,
5412
5438
            revision=None,
5413
5439
            ):
5425
5451
            # only show revisions between revid1 and revid2 (inclusive)
5426
5452
            tags = [(tag, revid) for tag, revid in tags if
5427
5453
                graph.is_between(revid, revid1, revid2)]
5428
 
        if sort == 'alpha':
 
5454
        if sort == 'natural':
 
5455
            def natural_sort_key(tag):
 
5456
                return [f(s) for f,s in 
 
5457
                        zip(itertools.cycle((unicode.lower,int)),
 
5458
                                            re.split('([0-9]+)', tag[0]))]
 
5459
            tags.sort(key=natural_sort_key)
 
5460
        elif sort == 'alpha':
5429
5461
            tags.sort()
5430
5462
        elif sort == 'time':
5431
5463
            timestamps = {}