~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-26 11:00:20 UTC
  • mfrom: (6167 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6169.
  • Revision ID: jelmer@samba.org-20110926110020-g86tgisgnuajlc2n
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
from bzrlib.revisionspec import RevisionSpec, RevisionInfo
58
58
from bzrlib.smtp_connection import SMTPConnection
59
59
from bzrlib.workingtree import WorkingTree
 
60
from bzrlib.i18n import gettext, ngettext
60
61
""")
61
62
 
62
63
from bzrlib.commands import (
112
113
            if view_files:
113
114
                file_list = view_files
114
115
                view_str = views.view_display_str(view_files)
115
 
                note("Ignoring files outside view. View is %s" % view_str)
 
116
                note(gettext("Ignoring files outside view. View is %s") % view_str)
116
117
    return tree, file_list
117
118
 
118
119
 
120
121
    if revisions is None:
121
122
        return None
122
123
    if len(revisions) != 1:
123
 
        raise errors.BzrCommandError(
124
 
            'bzr %s --revision takes exactly one revision identifier' % (
 
124
        raise errors.BzrCommandError(gettext(
 
125
            'bzr %s --revision takes exactly one revision identifier') % (
125
126
                command_name,))
126
127
    return revisions[0]
127
128
 
288
289
        from bzrlib.status import show_tree_status
289
290
 
290
291
        if revision and len(revision) > 2:
291
 
            raise errors.BzrCommandError('bzr status --revision takes exactly'
292
 
                                         ' one or two revision specifiers')
 
292
            raise errors.BzrCommandError(gettext('bzr status --revision takes exactly'
 
293
                                         ' one or two revision specifiers'))
293
294
 
294
295
        tree, relfile_list = WorkingTree.open_containing_paths(file_list)
295
296
        # Avoid asking for specific files when that is not needed.
332
333
    @display_command
333
334
    def run(self, revision_id=None, revision=None, directory=u'.'):
334
335
        if revision_id is not None and revision is not None:
335
 
            raise errors.BzrCommandError('You can only supply one of'
336
 
                                         ' revision_id or --revision')
 
336
            raise errors.BzrCommandError(gettext('You can only supply one of'
 
337
                                         ' revision_id or --revision'))
337
338
        if revision_id is None and revision is None:
338
 
            raise errors.BzrCommandError('You must supply either'
339
 
                                         ' --revision or a revision_id')
 
339
            raise errors.BzrCommandError(gettext('You must supply either'
 
340
                                         ' --revision or a revision_id'))
340
341
 
341
342
        b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
342
343
 
343
344
        revisions = b.repository.revisions
344
345
        if revisions is None:
345
 
            raise errors.BzrCommandError('Repository %r does not support '
346
 
                'access to raw revision texts')
 
346
            raise errors.BzrCommandError(gettext('Repository %r does not support '
 
347
                'access to raw revision texts'))
347
348
 
348
349
        b.repository.lock_read()
349
350
        try:
353
354
                try:
354
355
                    self.print_revision(revisions, revision_id)
355
356
                except errors.NoSuchRevision:
356
 
                    msg = "The repository %s contains no revision %s." % (
 
357
                    msg = gettext("The repository {0} contains no revision {1}.").format(
357
358
                        b.repository.base, revision_id)
358
359
                    raise errors.BzrCommandError(msg)
359
360
            elif revision is not None:
360
361
                for rev in revision:
361
362
                    if rev is None:
362
363
                        raise errors.BzrCommandError(
363
 
                            'You cannot specify a NULL revision.')
 
364
                            gettext('You cannot specify a NULL revision.'))
364
365
                    rev_id = rev.as_revision_id(b)
365
366
                    self.print_revision(revisions, rev_id)
366
367
        finally:
477
478
            try:
478
479
                working = d.open_workingtree()
479
480
            except errors.NoWorkingTree:
480
 
                raise errors.BzrCommandError("No working tree to remove")
 
481
                raise errors.BzrCommandError(gettext("No working tree to remove"))
481
482
            except errors.NotLocalUrl:
482
 
                raise errors.BzrCommandError("You cannot remove the working tree"
483
 
                                             " of a remote path")
 
483
                raise errors.BzrCommandError(gettext("You cannot remove the working tree"
 
484
                                             " of a remote path"))
484
485
            if not force:
485
486
                if (working.has_changes()):
486
487
                    raise errors.UncommittedChanges(working)
488
489
                    raise errors.ShelvedChanges(working)
489
490
 
490
491
            if working.user_url != working.branch.user_url:
491
 
                raise errors.BzrCommandError("You cannot remove the working tree"
492
 
                                             " from a lightweight checkout")
 
492
                raise errors.BzrCommandError(gettext("You cannot remove the working tree"
 
493
                                             " from a lightweight checkout"))
493
494
 
494
495
            d.destroy_workingtree()
495
496
 
527
528
                pass # There seems to be a real error here, so we'll reset
528
529
            else:
529
530
                # Refuse
530
 
                raise errors.BzrCommandError(
 
531
                raise errors.BzrCommandError(gettext(
531
532
                    'The tree does not appear to be corrupt. You probably'
532
533
                    ' want "bzr revert" instead. Use "--force" if you are'
533
 
                    ' sure you want to reset the working tree.')
 
534
                    ' sure you want to reset the working tree.'))
534
535
        if revision is None:
535
536
            revision_ids = None
536
537
        else:
539
540
            tree.reset_state(revision_ids)
540
541
        except errors.BzrError, e:
541
542
            if revision_ids is None:
542
 
                extra = (', the header appears corrupt, try passing -r -1'
543
 
                         ' to set the state to the last commit')
 
543
                extra = (gettext(', the header appears corrupt, try passing -r -1'
 
544
                         ' to set the state to the last commit'))
544
545
            else:
545
546
                extra = ''
546
 
            raise errors.BzrCommandError('failed to reset the tree state'
547
 
                                         + extra)
 
547
            raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
548
548
 
549
549
 
550
550
class cmd_revno(Command):
653
653
    are added.  This search proceeds recursively into versioned
654
654
    directories.  If no names are given '.' is assumed.
655
655
 
 
656
    A warning will be printed when nested trees are encountered,
 
657
    unless they are explicitly ignored.
 
658
 
656
659
    Therefore simply saying 'bzr add' will version all files that
657
660
    are currently unknown.
658
661
 
723
726
            if verbose:
724
727
                for glob in sorted(ignored.keys()):
725
728
                    for path in ignored[glob]:
726
 
                        self.outf.write("ignored %s matching \"%s\"\n"
727
 
                                        % (path, glob))
 
729
                        self.outf.write(
 
730
                         gettext("ignored {0} matching \"{1}\"\n").format(
 
731
                         path, glob))
728
732
 
729
733
 
730
734
class cmd_mkdir(Command):
744
748
            if id != None:
745
749
                os.mkdir(d)
746
750
                wt.add([dd])
747
 
                self.outf.write('added %s\n' % d)
 
751
                self.outf.write(gettext('added %s\n') % d)
748
752
            else:
749
753
                raise errors.NotVersionedError(path=base)
750
754
 
788
792
    @display_command
789
793
    def run(self, revision=None, show_ids=False, kind=None, file_list=None):
790
794
        if kind and kind not in ['file', 'directory', 'symlink']:
791
 
            raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
 
795
            raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
792
796
 
793
797
        revision = _get_one_revision('inventory', revision)
794
798
        work_tree, file_list = WorkingTree.open_containing_paths(file_list)
858
862
        if auto:
859
863
            return self.run_auto(names_list, after, dry_run)
860
864
        elif dry_run:
861
 
            raise errors.BzrCommandError('--dry-run requires --auto.')
 
865
            raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
862
866
        if names_list is None:
863
867
            names_list = []
864
868
        if len(names_list) < 2:
865
 
            raise errors.BzrCommandError("missing file argument")
 
869
            raise errors.BzrCommandError(gettext("missing file argument"))
866
870
        tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
867
871
        self.add_cleanup(tree.lock_tree_write().unlock)
868
872
        self._run(tree, names_list, rel_names, after)
869
873
 
870
874
    def run_auto(self, names_list, after, dry_run):
871
875
        if names_list is not None and len(names_list) > 1:
872
 
            raise errors.BzrCommandError('Only one path may be specified to'
873
 
                                         ' --auto.')
 
876
            raise errors.BzrCommandError(gettext('Only one path may be specified to'
 
877
                                         ' --auto.'))
874
878
        if after:
875
 
            raise errors.BzrCommandError('--after cannot be specified with'
876
 
                                         ' --auto.')
 
879
            raise errors.BzrCommandError(gettext('--after cannot be specified with'
 
880
                                         ' --auto.'))
877
881
        work_tree, file_list = WorkingTree.open_containing_paths(
878
882
            names_list, default_directory='.')
879
883
        self.add_cleanup(work_tree.lock_tree_write().unlock)
909
913
                    self.outf.write("%s => %s\n" % (src, dest))
910
914
        else:
911
915
            if len(names_list) != 2:
912
 
                raise errors.BzrCommandError('to mv multiple files the'
 
916
                raise errors.BzrCommandError(gettext('to mv multiple files the'
913
917
                                             ' destination must be a versioned'
914
 
                                             ' directory')
 
918
                                             ' directory'))
915
919
 
916
920
            # for cicp file-systems: the src references an existing inventory
917
921
            # item:
977
981
    branches have diverged.
978
982
 
979
983
    If there is no default location set, the first pull will set it (use
980
 
    --no-remember to avoid settting it). After that, you can omit the
 
984
    --no-remember to avoid setting it). After that, you can omit the
981
985
    location to use the default.  To change the default, use --remember. The
982
986
    value will only be saved if the remote location can be accessed.
983
987
 
1023
1027
            self.add_cleanup(branch_to.lock_write().unlock)
1024
1028
 
1025
1029
        if tree_to is None and show_base:
1026
 
            raise errors.BzrCommandError("Need working tree for --show-base.")
 
1030
            raise errors.BzrCommandError(gettext("Need working tree for --show-base."))
1027
1031
 
1028
1032
        if local and not branch_to.get_bound_location():
1029
1033
            raise errors.LocalRequiresBoundBranch()
1039
1043
        stored_loc = branch_to.get_parent()
1040
1044
        if location is None:
1041
1045
            if stored_loc is None:
1042
 
                raise errors.BzrCommandError("No pull location known or"
1043
 
                                             " specified.")
 
1046
                raise errors.BzrCommandError(gettext("No pull location known or"
 
1047
                                             " specified."))
1044
1048
            else:
1045
1049
                display_url = urlutils.unescape_for_display(stored_loc,
1046
1050
                        self.outf.encoding)
1047
1051
                if not is_quiet():
1048
 
                    self.outf.write("Using saved parent location: %s\n" % display_url)
 
1052
                    self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1049
1053
                location = stored_loc
1050
1054
 
1051
1055
        revision = _get_one_revision('pull', revision)
1052
1056
        if mergeable is not None:
1053
1057
            if revision is not None:
1054
 
                raise errors.BzrCommandError(
1055
 
                    'Cannot use -r with merge directives or bundles')
 
1058
                raise errors.BzrCommandError(gettext(
 
1059
                    'Cannot use -r with merge directives or bundles'))
1056
1060
            mergeable.install_revisions(branch_to.repository)
1057
1061
            base_revision_id, revision_id, verified = \
1058
1062
                mergeable.get_merge_request(branch_to.repository)
1076
1080
                view_info=view_info)
1077
1081
            result = tree_to.pull(
1078
1082
                branch_from, overwrite, revision_id, change_reporter,
1079
 
                possible_transports=possible_transports, local=local,
1080
 
                show_base=show_base)
 
1083
                local=local, show_base=show_base)
1081
1084
        else:
1082
1085
            result = branch_to.pull(
1083
1086
                branch_from, overwrite, revision_id, local=local)
1114
1117
    After that you will be able to do a push without '--overwrite'.
1115
1118
 
1116
1119
    If there is no default push location set, the first push will set it (use
1117
 
    --no-remember to avoid settting it).  After that, you can omit the
 
1120
    --no-remember to avoid setting it).  After that, you can omit the
1118
1121
    location to use the default.  To change the default, use --remember. The
1119
1122
    value will only be saved if the remote location can be accessed.
1120
1123
    """
1187
1190
                    # error by the feedback given to them. RBC 20080227.
1188
1191
                    stacked_on = parent_url
1189
1192
            if not stacked_on:
1190
 
                raise errors.BzrCommandError(
1191
 
                    "Could not determine branch to refer to.")
 
1193
                raise errors.BzrCommandError(gettext(
 
1194
                    "Could not determine branch to refer to."))
1192
1195
 
1193
1196
        # Get the destination location
1194
1197
        if location is None:
1195
1198
            stored_loc = br_from.get_push_location()
1196
1199
            if stored_loc is None:
1197
 
                raise errors.BzrCommandError(
1198
 
                    "No push location known or specified.")
 
1200
                raise errors.BzrCommandError(gettext(
 
1201
                    "No push location known or specified."))
1199
1202
            else:
1200
1203
                display_url = urlutils.unescape_for_display(stored_loc,
1201
1204
                        self.outf.encoding)
1202
 
                note("Using saved push location: %s" % display_url)
 
1205
                note(gettext("Using saved push location: %s") % display_url)
1203
1206
                location = stored_loc
1204
1207
 
1205
1208
        _show_push_branch(br_from, revision_id, location, self.outf,
1288
1291
            to_transport.mkdir('.')
1289
1292
        except errors.FileExists:
1290
1293
            if not use_existing_dir:
1291
 
                raise errors.BzrCommandError('Target directory "%s" '
1292
 
                    'already exists.' % to_location)
 
1294
                raise errors.BzrCommandError(gettext('Target directory "%s" '
 
1295
                    'already exists.') % to_location)
1293
1296
            else:
1294
1297
                try:
1295
1298
                    bzrdir.BzrDir.open_from_transport(to_transport)
1298
1301
                else:
1299
1302
                    raise errors.AlreadyBranchError(to_location)
1300
1303
        except errors.NoSuchFile:
1301
 
            raise errors.BzrCommandError('Parent of "%s" does not exist.'
 
1304
            raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1302
1305
                                         % to_location)
1303
1306
        try:
1304
1307
            # preserve whatever source format we have.
1312
1315
            branch = dir.open_branch()
1313
1316
        except errors.NoSuchRevision:
1314
1317
            to_transport.delete_tree('.')
1315
 
            msg = "The branch %s has no revision %s." % (from_location,
1316
 
                revision)
 
1318
            msg = gettext("The branch {0} has no revision {1}.").format(
 
1319
                from_location, revision)
1317
1320
            raise errors.BzrCommandError(msg)
1318
1321
        _merge_tags_if_possible(br_from, branch)
1319
1322
        # If the source branch is stacked, the new branch may
1320
1323
        # be stacked whether we asked for that explicitly or not.
1321
1324
        # We therefore need a try/except here and not just 'if stacked:'
1322
1325
        try:
1323
 
            note('Created new stacked branch referring to %s.' %
 
1326
            note(gettext('Created new stacked branch referring to %s.') %
1324
1327
                branch.get_stacked_on_url())
1325
1328
        except (errors.NotStacked, errors.UnstackableBranchFormat,
1326
1329
            errors.UnstackableRepositoryFormat), e:
1327
 
            note('Branched %d revision(s).' % branch.revno())
 
1330
            note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1328
1331
        if bind:
1329
1332
            # Bind to the parent
1330
1333
            parent_branch = Branch.open(from_location)
1331
1334
            branch.bind(parent_branch)
1332
 
            note('New branch bound to %s' % from_location)
 
1335
            note(gettext('New branch bound to %s') % from_location)
1333
1336
        if switch:
1334
1337
            # Switch to the new branch
1335
1338
            wt, _ = WorkingTree.open_containing('.')
1336
1339
            _mod_switch.switch(wt.bzrdir, branch)
1337
 
            note('Switched to branch: %s',
 
1340
            note(gettext('Switched to branch: %s'),
1338
1341
                urlutils.unescape_for_display(branch.base, 'utf-8'))
1339
1342
 
1340
1343
 
1365
1368
            dir = bzrdir.BzrDir.open_containing(location)[0]
1366
1369
            for branch in dir.list_branches():
1367
1370
                if branch.name is None:
1368
 
                    self.outf.write(" (default)\n")
 
1371
                    self.outf.write(gettext(" (default)\n"))
1369
1372
                else:
1370
1373
                    self.outf.write(" %s\n" % branch.name.encode(
1371
1374
                        self.outf.encoding))
1502
1505
 
1503
1506
    def run(self, dir='.', revision=None, show_base=None):
1504
1507
        if revision is not None and len(revision) != 1:
1505
 
            raise errors.BzrCommandError(
1506
 
                        "bzr update --revision takes exactly one revision")
 
1508
            raise errors.BzrCommandError(gettext(
 
1509
                        "bzr update --revision takes exactly one revision"))
1507
1510
        tree = WorkingTree.open_containing(dir)[0]
1508
1511
        branch = tree.branch
1509
1512
        possible_transports = []
1534
1537
            revision_id = branch.last_revision()
1535
1538
        if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1536
1539
            revno = branch.revision_id_to_dotted_revno(revision_id)
1537
 
            note("Tree is up to date at revision %s of branch %s" %
1538
 
                ('.'.join(map(str, revno)), branch_location))
 
1540
            note(gettext("Tree is up to date at revision {0} of branch {1}"
 
1541
                        ).format('.'.join(map(str, revno)), branch_location))
1539
1542
            return 0
1540
1543
        view_info = _get_view_info_for_change_reporter(tree)
1541
1544
        change_reporter = delta._ChangeReporter(
1549
1552
                old_tip=old_tip,
1550
1553
                show_base=show_base)
1551
1554
        except errors.NoSuchRevision, e:
1552
 
            raise errors.BzrCommandError(
 
1555
            raise errors.BzrCommandError(gettext(
1553
1556
                                  "branch has no revision %s\n"
1554
1557
                                  "bzr update --revision only works"
1555
 
                                  " for a revision in the branch history"
 
1558
                                  " for a revision in the branch history")
1556
1559
                                  % (e.revision))
1557
1560
        revno = tree.branch.revision_id_to_dotted_revno(
1558
1561
            _mod_revision.ensure_null(tree.last_revision()))
1559
 
        note('Updated to revision %s of branch %s' %
1560
 
             ('.'.join(map(str, revno)), branch_location))
 
1562
        note(gettext('Updated to revision {0} of branch {1}').format(
 
1563
             '.'.join(map(str, revno)), branch_location))
1561
1564
        parent_ids = tree.get_parent_ids()
1562
1565
        if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1563
 
            note('Your local commits will now show as pending merges with '
1564
 
                 "'bzr status', and can be committed with 'bzr commit'.")
 
1566
            note(gettext('Your local commits will now show as pending merges with '
 
1567
                 "'bzr status', and can be committed with 'bzr commit'."))
1565
1568
        if conflicts != 0:
1566
1569
            return 1
1567
1570
        else:
1639
1642
    def run(self, file_list, verbose=False, new=False,
1640
1643
        file_deletion_strategy='safe'):
1641
1644
        if file_deletion_strategy == 'force':
1642
 
            note("(The --force option is deprecated, rather use --no-backup "
1643
 
                "in future.)")
 
1645
            note(gettext("(The --force option is deprecated, rather use --no-backup "
 
1646
                "in future.)"))
1644
1647
            file_deletion_strategy = 'no-backup'
1645
1648
 
1646
1649
        tree, file_list = WorkingTree.open_containing_paths(file_list)
1656
1659
                specific_files=file_list).added
1657
1660
            file_list = sorted([f[0] for f in added], reverse=True)
1658
1661
            if len(file_list) == 0:
1659
 
                raise errors.BzrCommandError('No matching files.')
 
1662
                raise errors.BzrCommandError(gettext('No matching files.'))
1660
1663
        elif file_list is None:
1661
1664
            # missing files show up in iter_changes(basis) as
1662
1665
            # versioned-with-no-kind.
1856
1859
            to_transport.ensure_base()
1857
1860
        except errors.NoSuchFile:
1858
1861
            if not create_prefix:
1859
 
                raise errors.BzrCommandError("Parent directory of %s"
 
1862
                raise errors.BzrCommandError(gettext("Parent directory of %s"
1860
1863
                    " does not exist."
1861
1864
                    "\nYou may supply --create-prefix to create all"
1862
 
                    " leading parent directories."
 
1865
                    " leading parent directories.")
1863
1866
                    % location)
1864
1867
            to_transport.create_prefix()
1865
1868
 
1890
1893
            try:
1891
1894
                branch.set_append_revisions_only(True)
1892
1895
            except errors.UpgradeRequired:
1893
 
                raise errors.BzrCommandError('This branch format cannot be set'
1894
 
                    ' to append-revisions-only.  Try --default.')
 
1896
                raise errors.BzrCommandError(gettext('This branch format cannot be set'
 
1897
                    ' to append-revisions-only.  Try --default.'))
1895
1898
        if not is_quiet():
1896
1899
            from bzrlib.info import describe_layout, describe_format
1897
1900
            try:
1901
1904
            repository = branch.repository
1902
1905
            layout = describe_layout(repository, branch, tree).lower()
1903
1906
            format = describe_format(a_bzrdir, repository, branch, tree)
1904
 
            self.outf.write("Created a %s (format: %s)\n" % (layout, format))
 
1907
            self.outf.write(gettext("Created a {0} (format: {1})\n").format(
 
1908
                  layout, format))
1905
1909
            if repository.is_shared():
1906
1910
                #XXX: maybe this can be refactored into transport.path_or_url()
1907
1911
                url = repository.bzrdir.root_transport.external_url()
1909
1913
                    url = urlutils.local_path_from_url(url)
1910
1914
                except errors.InvalidURL:
1911
1915
                    pass
1912
 
                self.outf.write("Using shared repository: %s\n" % url)
 
1916
                self.outf.write(gettext("Using shared repository: %s\n") % url)
1913
1917
 
1914
1918
 
1915
1919
class cmd_init_repository(Command):
2106
2110
        elif ':' in prefix:
2107
2111
            old_label, new_label = prefix.split(":")
2108
2112
        else:
2109
 
            raise errors.BzrCommandError(
 
2113
            raise errors.BzrCommandError(gettext(
2110
2114
                '--prefix expects two values separated by a colon'
2111
 
                ' (eg "old/:new/")')
 
2115
                ' (eg "old/:new/")'))
2112
2116
 
2113
2117
        if revision and len(revision) > 2:
2114
 
            raise errors.BzrCommandError('bzr diff --revision takes exactly'
2115
 
                                         ' one or two revision specifiers')
 
2118
            raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
 
2119
                                         ' one or two revision specifiers'))
2116
2120
 
2117
2121
        if using is not None and format is not None:
2118
 
            raise errors.BzrCommandError('--using and --format are mutually '
2119
 
                'exclusive.')
 
2122
            raise errors.BzrCommandError(gettext(
 
2123
                '{0} and {1} are mutually exclusive').format(
 
2124
                '--using', '--format'))
2120
2125
 
2121
2126
        (old_tree, new_tree,
2122
2127
         old_branch, new_branch,
2230
2235
    try:
2231
2236
        return int(limitstring)
2232
2237
    except ValueError:
2233
 
        msg = "The limit argument must be an integer."
 
2238
        msg = gettext("The limit argument must be an integer.")
2234
2239
        raise errors.BzrCommandError(msg)
2235
2240
 
2236
2241
 
2238
2243
    try:
2239
2244
        return int(s)
2240
2245
    except ValueError:
2241
 
        msg = "The levels argument must be an integer."
 
2246
        msg = gettext("The levels argument must be an integer.")
2242
2247
        raise errors.BzrCommandError(msg)
2243
2248
 
2244
2249
 
2436
2441
            Option('show-diff',
2437
2442
                   short_name='p',
2438
2443
                   help='Show changes made in each revision as a patch.'),
2439
 
            Option('include-merges',
 
2444
            Option('include-merged',
2440
2445
                   help='Show merged revisions like --levels 0 does.'),
 
2446
            Option('include-merges', hidden=True,
 
2447
                   help='Historical alias for --include-merged.'),
 
2448
            Option('omit-merges',
 
2449
                   help='Do not report commits with more than one parent.'),
2441
2450
            Option('exclude-common-ancestry',
2442
2451
                   help='Display only the revisions that are not part'
2443
2452
                   ' of both ancestries (require -rX..Y)'
2480
2489
            message=None,
2481
2490
            limit=None,
2482
2491
            show_diff=False,
2483
 
            include_merges=False,
 
2492
            include_merged=None,
2484
2493
            authors=None,
2485
2494
            exclude_common_ancestry=False,
2486
2495
            signatures=False,
2489
2498
            match_committer=None,
2490
2499
            match_author=None,
2491
2500
            match_bugs=None,
 
2501
            omit_merges=False,
 
2502
            include_merges=symbol_versioning.DEPRECATED_PARAMETER,
2492
2503
            ):
2493
2504
        from bzrlib.log import (
2494
2505
            Logger,
2496
2507
            _get_info_for_log_files,
2497
2508
            )
2498
2509
        direction = (forward and 'forward') or 'reverse'
 
2510
        if symbol_versioning.deprecated_passed(include_merges):
 
2511
            ui.ui_factory.show_user_warning(
 
2512
                'deprecated_command_option',
 
2513
                deprecated_name='--include-merges',
 
2514
                recommended_name='--include-merged',
 
2515
                deprecated_in_version='2.5',
 
2516
                command=self.invoked_as)
 
2517
            if include_merged is None:
 
2518
                include_merged = include_merges
 
2519
            else:
 
2520
                raise errors.BzrCommandError(gettext(
 
2521
                    '{0} and {1} are mutually exclusive').format(
 
2522
                    '--include-merges', '--include-merged'))
 
2523
        if include_merged is None:
 
2524
            include_merged = False
2499
2525
        if (exclude_common_ancestry
2500
2526
            and (revision is None or len(revision) != 2)):
2501
 
            raise errors.BzrCommandError(
2502
 
                '--exclude-common-ancestry requires -r with two revisions')
2503
 
        if include_merges:
 
2527
            raise errors.BzrCommandError(gettext(
 
2528
                '--exclude-common-ancestry requires -r with two revisions'))
 
2529
        if include_merged:
2504
2530
            if levels is None:
2505
2531
                levels = 0
2506
2532
            else:
2507
 
                raise errors.BzrCommandError(
2508
 
                    '--levels and --include-merges are mutually exclusive')
 
2533
                raise errors.BzrCommandError(gettext(
 
2534
                    '{0} and {1} are mutually exclusive').format(
 
2535
                    '--levels', '--include-merged'))
2509
2536
 
2510
2537
        if change is not None:
2511
2538
            if len(change) > 1:
2512
2539
                raise errors.RangeInChangeOption()
2513
2540
            if revision is not None:
2514
 
                raise errors.BzrCommandError(
2515
 
                    '--revision and --change are mutually exclusive')
 
2541
                raise errors.BzrCommandError(gettext(
 
2542
                    '{0} and {1} are mutually exclusive').format(
 
2543
                    '--revision', '--change'))
2516
2544
            else:
2517
2545
                revision = change
2518
2546
 
2524
2552
                revision, file_list, self.add_cleanup)
2525
2553
            for relpath, file_id, kind in file_info_list:
2526
2554
                if file_id is None:
2527
 
                    raise errors.BzrCommandError(
2528
 
                        "Path unknown at end or start of revision range: %s" %
 
2555
                    raise errors.BzrCommandError(gettext(
 
2556
                        "Path unknown at end or start of revision range: %s") %
2529
2557
                        relpath)
2530
2558
                # If the relpath is the top of the tree, we log everything
2531
2559
                if relpath == '':
2608
2636
            match_dict['author'] = match_author
2609
2637
        if match_bugs:
2610
2638
            match_dict['bugs'] = match_bugs
2611
 
            
 
2639
 
2612
2640
        # Build the LogRequest and execute it
2613
2641
        if len(file_ids) == 0:
2614
2642
            file_ids = None
2618
2646
            message_search=message, delta_type=delta_type,
2619
2647
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2620
2648
            exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
2621
 
            signature=signatures
 
2649
            signature=signatures, omit_merges=omit_merges,
2622
2650
            )
2623
2651
        Logger(b, rqst).show(lf)
2624
2652
 
2641
2669
            # b is taken from revision[0].get_branch(), and
2642
2670
            # show_log will use its revision_history. Having
2643
2671
            # different branches will lead to weird behaviors.
2644
 
            raise errors.BzrCommandError(
 
2672
            raise errors.BzrCommandError(gettext(
2645
2673
                "bzr %s doesn't accept two revisions in different"
2646
 
                " branches." % command_name)
 
2674
                " branches.") % command_name)
2647
2675
        if start_spec.spec is None:
2648
2676
            # Avoid loading all the history.
2649
2677
            rev1 = RevisionInfo(branch, None, None)
2657
2685
        else:
2658
2686
            rev2 = end_spec.in_history(branch)
2659
2687
    else:
2660
 
        raise errors.BzrCommandError(
2661
 
            'bzr %s --revision takes one or two values.' % command_name)
 
2688
        raise errors.BzrCommandError(gettext(
 
2689
            'bzr %s --revision takes one or two values.') % command_name)
2662
2690
    return rev1, rev2
2663
2691
 
2664
2692
 
2735
2763
            null=False, kind=None, show_ids=False, path=None, directory=None):
2736
2764
 
2737
2765
        if kind and kind not in ('file', 'directory', 'symlink'):
2738
 
            raise errors.BzrCommandError('invalid kind specified')
 
2766
            raise errors.BzrCommandError(gettext('invalid kind specified'))
2739
2767
 
2740
2768
        if verbose and null:
2741
 
            raise errors.BzrCommandError('Cannot set both --verbose and --null')
 
2769
            raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2742
2770
        all = not (unknown or versioned or ignored)
2743
2771
 
2744
2772
        selection = {'I':ignored, '?':unknown, 'V':versioned}
2747
2775
            fs_path = '.'
2748
2776
        else:
2749
2777
            if from_root:
2750
 
                raise errors.BzrCommandError('cannot specify both --from-root'
2751
 
                                             ' and PATH')
 
2778
                raise errors.BzrCommandError(gettext('cannot specify both --from-root'
 
2779
                                             ' and PATH'))
2752
2780
            fs_path = path
2753
2781
        tree, branch, relpath = \
2754
2782
            _open_directory_or_containing_tree_or_branch(fs_path, directory)
2770
2798
            if view_files:
2771
2799
                apply_view = True
2772
2800
                view_str = views.view_display_str(view_files)
2773
 
                note("Ignoring files outside view. View is %s" % view_str)
 
2801
                note(gettext("Ignoring files outside view. View is %s") % view_str)
2774
2802
 
2775
2803
        self.add_cleanup(tree.lock_read().unlock)
2776
2804
        for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2923
2951
                self.outf.write("%s\n" % pattern)
2924
2952
            return
2925
2953
        if not name_pattern_list:
2926
 
            raise errors.BzrCommandError("ignore requires at least one "
2927
 
                "NAME_PATTERN or --default-rules.")
 
2954
            raise errors.BzrCommandError(gettext("ignore requires at least one "
 
2955
                "NAME_PATTERN or --default-rules."))
2928
2956
        name_pattern_list = [globbing.normalize_pattern(p)
2929
2957
                             for p in name_pattern_list]
2930
2958
        bad_patterns = ''
 
2959
        bad_patterns_count = 0
2931
2960
        for p in name_pattern_list:
2932
2961
            if not globbing.Globster.is_pattern_valid(p):
 
2962
                bad_patterns_count += 1
2933
2963
                bad_patterns += ('\n  %s' % p)
2934
2964
        if bad_patterns:
2935
 
            msg = ('Invalid ignore pattern(s) found. %s' % bad_patterns)
 
2965
            msg = (ngettext('Invalid ignore pattern found. %s', 
 
2966
                            'Invalid ignore patterns found. %s',
 
2967
                            bad_patterns_count) % bad_patterns)
2936
2968
            ui.ui_factory.show_error(msg)
2937
2969
            raise errors.InvalidPattern('')
2938
2970
        for name_pattern in name_pattern_list:
2939
2971
            if (name_pattern[0] == '/' or
2940
2972
                (len(name_pattern) > 1 and name_pattern[1] == ':')):
2941
 
                raise errors.BzrCommandError(
2942
 
                    "NAME_PATTERN should not be an absolute path")
 
2973
                raise errors.BzrCommandError(gettext(
 
2974
                    "NAME_PATTERN should not be an absolute path"))
2943
2975
        tree, relpath = WorkingTree.open_containing(directory)
2944
2976
        ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2945
2977
        ignored = globbing.Globster(name_pattern_list)
2952
2984
                if ignored.match(filename):
2953
2985
                    matches.append(filename)
2954
2986
        if len(matches) > 0:
2955
 
            self.outf.write("Warning: the following files are version controlled and"
2956
 
                  " match your ignore pattern:\n%s"
 
2987
            self.outf.write(gettext("Warning: the following files are version "
 
2988
                  "controlled and match your ignore pattern:\n%s"
2957
2989
                  "\nThese files will continue to be version controlled"
2958
 
                  " unless you 'bzr remove' them.\n" % ("\n".join(matches),))
 
2990
                  " unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2959
2991
 
2960
2992
 
2961
2993
class cmd_ignored(Command):
3000
3032
        try:
3001
3033
            revno = int(revno)
3002
3034
        except ValueError:
3003
 
            raise errors.BzrCommandError("not a valid revision-number: %r"
 
3035
            raise errors.BzrCommandError(gettext("not a valid revision-number: %r")
3004
3036
                                         % revno)
3005
3037
        revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
3006
3038
        self.outf.write("%s\n" % revid)
3067
3099
            export(rev_tree, dest, format, root, subdir, filtered=filters,
3068
3100
                   per_file_timestamps=per_file_timestamps)
3069
3101
        except errors.NoSuchExportFormat, e:
3070
 
            raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
 
3102
            raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
3071
3103
 
3072
3104
 
3073
3105
class cmd_cat(Command):
3093
3125
    def run(self, filename, revision=None, name_from_revision=False,
3094
3126
            filters=False, directory=None):
3095
3127
        if revision is not None and len(revision) != 1:
3096
 
            raise errors.BzrCommandError("bzr cat --revision takes exactly"
3097
 
                                         " one revision specifier")
 
3128
            raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
 
3129
                                         " one revision specifier"))
3098
3130
        tree, branch, relpath = \
3099
3131
            _open_directory_or_containing_tree_or_branch(filename, directory)
3100
3132
        self.add_cleanup(branch.lock_read().unlock)
3117
3149
        if name_from_revision:
3118
3150
            # Try in revision if requested
3119
3151
            if old_file_id is None:
3120
 
                raise errors.BzrCommandError(
3121
 
                    "%r is not present in revision %s" % (
 
3152
                raise errors.BzrCommandError(gettext(
 
3153
                    "{0!r} is not present in revision {1}").format(
3122
3154
                        filename, rev_tree.get_revision_id()))
3123
3155
            else:
3124
3156
                actual_file_id = old_file_id
3129
3161
            elif old_file_id is not None:
3130
3162
                actual_file_id = old_file_id
3131
3163
            else:
3132
 
                raise errors.BzrCommandError(
3133
 
                    "%r is not present in revision %s" % (
 
3164
                raise errors.BzrCommandError(gettext(
 
3165
                    "{0!r} is not present in revision {1}").format(
3134
3166
                        filename, rev_tree.get_revision_id()))
3135
3167
        if filtered:
3136
3168
            from bzrlib.filter_tree import ContentFilterTree
3253
3285
    aliases = ['ci', 'checkin']
3254
3286
 
3255
3287
    def _iter_bug_fix_urls(self, fixes, branch):
 
3288
        default_bugtracker  = None
3256
3289
        # Configure the properties for bug fixing attributes.
3257
3290
        for fixed_bug in fixes:
3258
3291
            tokens = fixed_bug.split(':')
3259
 
            if len(tokens) != 2:
3260
 
                raise errors.BzrCommandError(
 
3292
            if len(tokens) == 1:
 
3293
                if default_bugtracker is None:
 
3294
                    branch_config = branch.get_config()
 
3295
                    default_bugtracker = branch_config.get_user_option(
 
3296
                        "bugtracker")
 
3297
                if default_bugtracker is None:
 
3298
                    raise errors.BzrCommandError(gettext(
 
3299
                        "No tracker specified for bug %s. Use the form "
 
3300
                        "'tracker:id' or specify a default bug tracker "
 
3301
                        "using the `bugtracker` option.\nSee "
 
3302
                        "\"bzr help bugs\" for more information on this "
 
3303
                        "feature. Commit refused.") % fixed_bug)
 
3304
                tag = default_bugtracker
 
3305
                bug_id = tokens[0]
 
3306
            elif len(tokens) != 2:
 
3307
                raise errors.BzrCommandError(gettext(
3261
3308
                    "Invalid bug %s. Must be in the form of 'tracker:id'. "
3262
3309
                    "See \"bzr help bugs\" for more information on this "
3263
 
                    "feature.\nCommit refused." % fixed_bug)
3264
 
            tag, bug_id = tokens
 
3310
                    "feature.\nCommit refused.") % fixed_bug)
 
3311
            else:
 
3312
                tag, bug_id = tokens
3265
3313
            try:
3266
3314
                yield bugtracker.get_bug_url(tag, branch, bug_id)
3267
3315
            except errors.UnknownBugTrackerAbbreviation:
3268
 
                raise errors.BzrCommandError(
3269
 
                    'Unrecognized bug %s. Commit refused.' % fixed_bug)
 
3316
                raise errors.BzrCommandError(gettext(
 
3317
                    'Unrecognized bug %s. Commit refused.') % fixed_bug)
3270
3318
            except errors.MalformedBugIdentifier, e:
3271
 
                raise errors.BzrCommandError(
3272
 
                    "%s\nCommit refused." % (str(e),))
 
3319
                raise errors.BzrCommandError(gettext(
 
3320
                    "%s\nCommit refused.") % (str(e),))
3273
3321
 
3274
3322
    def run(self, message=None, file=None, verbose=False, selected_list=None,
3275
3323
            unchanged=False, strict=False, local=False, fixes=None,
3292
3340
            try:
3293
3341
                commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3294
3342
            except ValueError, e:
3295
 
                raise errors.BzrCommandError(
3296
 
                    "Could not parse --commit-time: " + str(e))
 
3343
                raise errors.BzrCommandError(gettext(
 
3344
                    "Could not parse --commit-time: " + str(e)))
3297
3345
 
3298
3346
        properties = {}
3299
3347
 
3332
3380
                message = message.replace('\r\n', '\n')
3333
3381
                message = message.replace('\r', '\n')
3334
3382
            if file:
3335
 
                raise errors.BzrCommandError(
3336
 
                    "please specify either --message or --file")
 
3383
                raise errors.BzrCommandError(gettext(
 
3384
                    "please specify either --message or --file"))
3337
3385
 
3338
3386
        def get_message(commit_obj):
3339
3387
            """Callback to get commit message"""
3362
3410
                    my_message = edit_commit_message_encoded(text,
3363
3411
                        start_message=start_message)
3364
3412
                if my_message is None:
3365
 
                    raise errors.BzrCommandError("please specify a commit"
3366
 
                        " message with either --message or --file")
 
3413
                    raise errors.BzrCommandError(gettext("please specify a commit"
 
3414
                        " message with either --message or --file"))
3367
3415
                if my_message == "":
3368
 
                    raise errors.BzrCommandError("Empty commit message specified."
 
3416
                    raise errors.BzrCommandError(gettext("Empty commit message specified."
3369
3417
                            " Please specify a commit message with either"
3370
3418
                            " --message or --file or leave a blank message"
3371
 
                            " with --message \"\".")
 
3419
                            " with --message \"\"."))
3372
3420
            return my_message
3373
3421
 
3374
3422
        # The API permits a commit with a filter of [] to mean 'select nothing'
3385
3433
                        exclude=tree.safe_relpath_files(exclude),
3386
3434
                        lossy=lossy)
3387
3435
        except PointlessCommit:
3388
 
            raise errors.BzrCommandError("No changes to commit."
 
3436
            raise errors.BzrCommandError(gettext("No changes to commit."
3389
3437
                " Please 'bzr add' the files you want to commit, or use"
3390
 
                " --unchanged to force an empty commit.")
 
3438
                " --unchanged to force an empty commit."))
3391
3439
        except ConflictsInTree:
3392
 
            raise errors.BzrCommandError('Conflicts detected in working '
 
3440
            raise errors.BzrCommandError(gettext('Conflicts detected in working '
3393
3441
                'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
3394
 
                ' resolve.')
 
3442
                ' resolve.'))
3395
3443
        except StrictCommitFailed:
3396
 
            raise errors.BzrCommandError("Commit refused because there are"
3397
 
                              " unknown files in the working tree.")
 
3444
            raise errors.BzrCommandError(gettext("Commit refused because there are"
 
3445
                              " unknown files in the working tree."))
3398
3446
        except errors.BoundBranchOutOfDate, e:
3399
 
            e.extra_help = ("\n"
 
3447
            e.extra_help = (gettext("\n"
3400
3448
                'To commit to master branch, run update and then commit.\n'
3401
3449
                'You can also pass --local to commit to continue working '
3402
 
                'disconnected.')
 
3450
                'disconnected.'))
3403
3451
            raise
3404
3452
 
3405
3453
 
3572
3620
            return
3573
3621
 
3574
3622
        if email:
3575
 
            raise errors.BzrCommandError("--email can only be used to display existing "
3576
 
                                         "identity")
 
3623
            raise errors.BzrCommandError(gettext("--email can only be used to display existing "
 
3624
                                         "identity"))
3577
3625
 
3578
3626
        # display a warning if an email address isn't included in the given name.
3579
3627
        try:
3658
3706
 
3659
3707
    def remove_alias(self, alias_name):
3660
3708
        if alias_name is None:
3661
 
            raise errors.BzrCommandError(
3662
 
                'bzr alias --remove expects an alias to remove.')
 
3709
            raise errors.BzrCommandError(gettext(
 
3710
                'bzr alias --remove expects an alias to remove.'))
3663
3711
        # If alias is not found, print something like:
3664
3712
        # unalias: foo: not found
3665
3713
        c = _mod_config.GlobalConfig()
3803
3851
                                param_name='starting_with', short_name='s',
3804
3852
                                help=
3805
3853
                                'Load only the tests starting with TESTID.'),
 
3854
                     Option('sync',
 
3855
                            help="By default we disable fsync and fdatasync"
 
3856
                                 " while running the test suite.")
3806
3857
                     ]
3807
3858
    encoding_type = 'replace'
3808
3859
 
3816
3867
            first=False, list_only=False,
3817
3868
            randomize=None, exclude=None, strict=False,
3818
3869
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3819
 
            parallel=None, lsprof_tests=False):
 
3870
            parallel=None, lsprof_tests=False,
 
3871
            sync=False):
3820
3872
        from bzrlib import tests
3821
3873
 
3822
3874
        if testspecs_list is not None:
3827
3879
            try:
3828
3880
                from bzrlib.tests import SubUnitBzrRunner
3829
3881
            except ImportError:
3830
 
                raise errors.BzrCommandError("subunit not available. subunit "
3831
 
                    "needs to be installed to use --subunit.")
 
3882
                raise errors.BzrCommandError(gettext("subunit not available. subunit "
 
3883
                    "needs to be installed to use --subunit."))
3832
3884
            self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3833
3885
            # On Windows, disable automatic conversion of '\n' to '\r\n' in
3834
3886
            # stdout, which would corrupt the subunit stream. 
3843
3895
            self.additional_selftest_args.setdefault(
3844
3896
                'suite_decorators', []).append(parallel)
3845
3897
        if benchmark:
3846
 
            raise errors.BzrCommandError(
 
3898
            raise errors.BzrCommandError(gettext(
3847
3899
                "--benchmark is no longer supported from bzr 2.2; "
3848
 
                "use bzr-usertest instead")
 
3900
                "use bzr-usertest instead"))
3849
3901
        test_suite_factory = None
3850
3902
        if not exclude:
3851
3903
            exclude_pattern = None
3852
3904
        else:
3853
3905
            exclude_pattern = '(' + '|'.join(exclude) + ')'
 
3906
        if not sync:
 
3907
            self._disable_fsync()
3854
3908
        selftest_kwargs = {"verbose": verbose,
3855
3909
                          "pattern": pattern,
3856
3910
                          "stop_on_failure": one,
3878
3932
            cleanup()
3879
3933
        return int(not result)
3880
3934
 
 
3935
    def _disable_fsync(self):
 
3936
        """Change the 'os' functionality to not synchronize."""
 
3937
        self._orig_fsync = getattr(os, 'fsync', None)
 
3938
        if self._orig_fsync is not None:
 
3939
            os.fsync = lambda filedes: None
 
3940
        self._orig_fdatasync = getattr(os, 'fdatasync', None)
 
3941
        if self._orig_fdatasync is not None:
 
3942
            os.fdatasync = lambda filedes: None
 
3943
 
3881
3944
 
3882
3945
class cmd_version(Command):
3883
3946
    __doc__ = """Show version of bzr."""
3903
3966
 
3904
3967
    @display_command
3905
3968
    def run(self):
3906
 
        self.outf.write("It sure does!\n")
 
3969
        self.outf.write(gettext("It sure does!\n"))
3907
3970
 
3908
3971
 
3909
3972
class cmd_find_merge_base(Command):
3927
3990
        graph = branch1.repository.get_graph(branch2.repository)
3928
3991
        base_rev_id = graph.find_unique_lca(last1, last2)
3929
3992
 
3930
 
        self.outf.write('merge base is revision %s\n' % base_rev_id)
 
3993
        self.outf.write(gettext('merge base is revision %s\n') % base_rev_id)
3931
3994
 
3932
3995
 
3933
3996
class cmd_merge(Command):
3966
4029
    Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
3967
4030
 
3968
4031
    If there is no default branch set, the first merge will set it (use
3969
 
    --no-remember to avoid settting it). After that, you can omit the branch
 
4032
    --no-remember to avoid setting it). After that, you can omit the branch
3970
4033
    to use the default.  To change the default, use --remember. The value will
3971
4034
    only be saved if the remote location can be accessed.
3972
4035
 
4058
4121
 
4059
4122
        tree = WorkingTree.open_containing(directory)[0]
4060
4123
        if tree.branch.revno() == 0:
4061
 
            raise errors.BzrCommandError('Merging into empty branches not currently supported, '
4062
 
                                         'https://bugs.launchpad.net/bzr/+bug/308562')
 
4124
            raise errors.BzrCommandError(gettext('Merging into empty branches not currently supported, '
 
4125
                                         'https://bugs.launchpad.net/bzr/+bug/308562'))
4063
4126
 
4064
4127
        try:
4065
4128
            basis_tree = tree.revision_tree(tree.last_revision())
4085
4148
                mergeable = None
4086
4149
            else:
4087
4150
                if uncommitted:
4088
 
                    raise errors.BzrCommandError('Cannot use --uncommitted'
4089
 
                        ' with bundles or merge directives.')
 
4151
                    raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
 
4152
                        ' with bundles or merge directives.'))
4090
4153
 
4091
4154
                if revision is not None:
4092
 
                    raise errors.BzrCommandError(
4093
 
                        'Cannot use -r with merge directives or bundles')
 
4155
                    raise errors.BzrCommandError(gettext(
 
4156
                        'Cannot use -r with merge directives or bundles'))
4094
4157
                merger, verified = _mod_merge.Merger.from_mergeable(tree,
4095
4158
                   mergeable, None)
4096
4159
 
4097
4160
        if merger is None and uncommitted:
4098
4161
            if revision is not None and len(revision) > 0:
4099
 
                raise errors.BzrCommandError('Cannot use --uncommitted and'
4100
 
                    ' --revision at the same time.')
 
4162
                raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
 
4163
                    ' --revision at the same time.'))
4101
4164
            merger = self.get_merger_from_uncommitted(tree, location, None)
4102
4165
            allow_pending = False
4103
4166
 
4116
4179
            if merger.interesting_files:
4117
4180
                if not merger.other_tree.has_filename(
4118
4181
                    merger.interesting_files[0]):
4119
 
                    note("merger: " + str(merger))
 
4182
                    note(gettext("merger: ") + str(merger))
4120
4183
                    raise errors.PathsDoNotExist([location])
4121
 
            note('Nothing to do.')
 
4184
            note(gettext('Nothing to do.'))
4122
4185
            return 0
4123
4186
        if pull and not preview:
4124
4187
            if merger.interesting_files is not None:
4125
 
                raise errors.BzrCommandError('Cannot pull individual files')
 
4188
                raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4126
4189
            if (merger.base_rev_id == tree.last_revision()):
4127
4190
                result = tree.pull(merger.other_branch, False,
4128
4191
                                   merger.other_rev_id)
4129
4192
                result.report(self.outf)
4130
4193
                return 0
4131
4194
        if merger.this_basis is None:
4132
 
            raise errors.BzrCommandError(
 
4195
            raise errors.BzrCommandError(gettext(
4133
4196
                "This branch has no commits."
4134
 
                " (perhaps you would prefer 'bzr pull')")
 
4197
                " (perhaps you would prefer 'bzr pull')"))
4135
4198
        if preview:
4136
4199
            return self._do_preview(merger)
4137
4200
        elif interactive:
4188
4251
    def sanity_check_merger(self, merger):
4189
4252
        if (merger.show_base and
4190
4253
            not merger.merge_type is _mod_merge.Merge3Merger):
4191
 
            raise errors.BzrCommandError("Show-base is not supported for this"
4192
 
                                         " merge type. %s" % merger.merge_type)
 
4254
            raise errors.BzrCommandError(gettext("Show-base is not supported for this"
 
4255
                                         " merge type. %s") % merger.merge_type)
4193
4256
        if merger.reprocess is None:
4194
4257
            if merger.show_base:
4195
4258
                merger.reprocess = False
4197
4260
                # Use reprocess if the merger supports it
4198
4261
                merger.reprocess = merger.merge_type.supports_reprocess
4199
4262
        if merger.reprocess and not merger.merge_type.supports_reprocess:
4200
 
            raise errors.BzrCommandError("Conflict reduction is not supported"
4201
 
                                         " for merge type %s." %
 
4263
            raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
 
4264
                                         " for merge type %s.") %
4202
4265
                                         merger.merge_type)
4203
4266
        if merger.reprocess and merger.show_base:
4204
 
            raise errors.BzrCommandError("Cannot do conflict reduction and"
4205
 
                                         " show base.")
 
4267
            raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
 
4268
                                         " show base."))
4206
4269
 
4207
4270
    def _get_merger_from_branch(self, tree, location, revision, remember,
4208
4271
                                possible_transports, pb):
4312
4375
            stored_location_type = "parent"
4313
4376
        mutter("%s", stored_location)
4314
4377
        if stored_location is None:
4315
 
            raise errors.BzrCommandError("No location specified or remembered")
 
4378
            raise errors.BzrCommandError(gettext("No location specified or remembered"))
4316
4379
        display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4317
 
        note(u"%s remembered %s location %s", verb_string,
4318
 
                stored_location_type, display_url)
 
4380
        note(gettext("{0} remembered {1} location {2}").format(verb_string,
 
4381
                stored_location_type, display_url))
4319
4382
        return stored_location
4320
4383
 
4321
4384
 
4358
4421
        self.add_cleanup(tree.lock_write().unlock)
4359
4422
        parents = tree.get_parent_ids()
4360
4423
        if len(parents) != 2:
4361
 
            raise errors.BzrCommandError("Sorry, remerge only works after normal"
 
4424
            raise errors.BzrCommandError(gettext("Sorry, remerge only works after normal"
4362
4425
                                         " merges.  Not cherrypicking or"
4363
 
                                         " multi-merges.")
 
4426
                                         " multi-merges."))
4364
4427
        repository = tree.branch.repository
4365
4428
        interesting_ids = None
4366
4429
        new_conflicts = []
4585
4648
            type=_parse_revision_str,
4586
4649
            help='Filter on local branch revisions (inclusive). '
4587
4650
                'See "help revisionspec" for details.'),
4588
 
        Option('include-merges',
 
4651
        Option('include-merged',
4589
4652
               'Show all revisions in addition to the mainline ones.'),
 
4653
        Option('include-merges', hidden=True,
 
4654
               help='Historical alias for --include-merged.'),
4590
4655
        ]
4591
4656
    encoding_type = 'replace'
4592
4657
 
4595
4660
            theirs_only=False,
4596
4661
            log_format=None, long=False, short=False, line=False,
4597
4662
            show_ids=False, verbose=False, this=False, other=False,
4598
 
            include_merges=False, revision=None, my_revision=None,
4599
 
            directory=u'.'):
 
4663
            include_merged=None, revision=None, my_revision=None,
 
4664
            directory=u'.',
 
4665
            include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4600
4666
        from bzrlib.missing import find_unmerged, iter_log_revisions
4601
4667
        def message(s):
4602
4668
            if not is_quiet():
4603
4669
                self.outf.write(s)
4604
4670
 
 
4671
        if symbol_versioning.deprecated_passed(include_merges):
 
4672
            ui.ui_factory.show_user_warning(
 
4673
                'deprecated_command_option',
 
4674
                deprecated_name='--include-merges',
 
4675
                recommended_name='--include-merged',
 
4676
                deprecated_in_version='2.5',
 
4677
                command=self.invoked_as)
 
4678
            if include_merged is None:
 
4679
                include_merged = include_merges
 
4680
            else:
 
4681
                raise errors.BzrCommandError(gettext(
 
4682
                    '{0} and {1} are mutually exclusive').format(
 
4683
                    '--include-merges', '--include-merged'))
 
4684
        if include_merged is None:
 
4685
            include_merged = False
4605
4686
        if this:
4606
4687
            mine_only = this
4607
4688
        if other:
4622
4703
        if other_branch is None:
4623
4704
            other_branch = parent
4624
4705
            if other_branch is None:
4625
 
                raise errors.BzrCommandError("No peer location known"
4626
 
                                             " or specified.")
 
4706
                raise errors.BzrCommandError(gettext("No peer location known"
 
4707
                                             " or specified."))
4627
4708
            display_url = urlutils.unescape_for_display(parent,
4628
4709
                                                        self.outf.encoding)
4629
 
            message("Using saved parent location: "
4630
 
                    + display_url + "\n")
 
4710
            message(gettext("Using saved parent location: {0}\n").format(
 
4711
                    display_url))
4631
4712
 
4632
4713
        remote_branch = Branch.open(other_branch)
4633
4714
        if remote_branch.base == local_branch.base:
4646
4727
        local_extra, remote_extra = find_unmerged(
4647
4728
            local_branch, remote_branch, restrict,
4648
4729
            backward=not reverse,
4649
 
            include_merges=include_merges,
 
4730
            include_merged=include_merged,
4650
4731
            local_revid_range=local_revid_range,
4651
4732
            remote_revid_range=remote_revid_range)
4652
4733
 
4659
4740
 
4660
4741
        status_code = 0
4661
4742
        if local_extra and not theirs_only:
4662
 
            message("You have %d extra revision(s):\n" %
 
4743
            message(ngettext("You have %d extra revision:\n",
 
4744
                             "You have %d extra revisions:\n", 
 
4745
                             len(local_extra)) %
4663
4746
                len(local_extra))
4664
4747
            for revision in iter_log_revisions(local_extra,
4665
4748
                                local_branch.repository,
4673
4756
        if remote_extra and not mine_only:
4674
4757
            if printed_local is True:
4675
4758
                message("\n\n\n")
4676
 
            message("You are missing %d revision(s):\n" %
 
4759
            message(ngettext("You are missing %d revision:\n",
 
4760
                             "You are missing %d revisions:\n",
 
4761
                             len(remote_extra)) %
4677
4762
                len(remote_extra))
4678
4763
            for revision in iter_log_revisions(remote_extra,
4679
4764
                                remote_branch.repository,
4683
4768
 
4684
4769
        if mine_only and not local_extra:
4685
4770
            # We checked local, and found nothing extra
4686
 
            message('This branch has no new revisions.\n')
 
4771
            message(gettext('This branch has no new revisions.\n'))
4687
4772
        elif theirs_only and not remote_extra:
4688
4773
            # We checked remote, and found nothing extra
4689
 
            message('Other branch has no new revisions.\n')
 
4774
            message(gettext('Other branch has no new revisions.\n'))
4690
4775
        elif not (mine_only or theirs_only or local_extra or
4691
4776
                  remote_extra):
4692
4777
            # We checked both branches, and neither one had extra
4693
4778
            # revisions
4694
 
            message("Branches are up to date.\n")
 
4779
            message(gettext("Branches are up to date.\n"))
4695
4780
        self.cleanup_now()
4696
4781
        if not status_code and parent is None and other_branch is not None:
4697
4782
            self.add_cleanup(local_branch.lock_write().unlock)
4858
4943
 
4859
4944
    def run(self, revision_id_list=None, revision=None, directory=u'.'):
4860
4945
        if revision_id_list is not None and revision is not None:
4861
 
            raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
 
4946
            raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
4862
4947
        if revision_id_list is None and revision is None:
4863
 
            raise errors.BzrCommandError('You must supply either --revision or a revision_id')
 
4948
            raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
4864
4949
        b = WorkingTree.open_containing(directory)[0].branch
4865
4950
        self.add_cleanup(b.lock_write().unlock)
4866
4951
        return self._run(b, revision_id_list, revision)
4898
4983
                if to_revid is None:
4899
4984
                    to_revno = b.revno()
4900
4985
                if from_revno is None or to_revno is None:
4901
 
                    raise errors.BzrCommandError('Cannot sign a range of non-revision-history revisions')
 
4986
                    raise errors.BzrCommandError(gettext('Cannot sign a range of non-revision-history revisions'))
4902
4987
                b.repository.start_write_group()
4903
4988
                try:
4904
4989
                    for revno in range(from_revno, to_revno + 1):
4910
4995
                else:
4911
4996
                    b.repository.commit_write_group()
4912
4997
            else:
4913
 
                raise errors.BzrCommandError('Please supply either one revision, or a range.')
 
4998
                raise errors.BzrCommandError(gettext('Please supply either one revision, or a range.'))
4914
4999
 
4915
5000
 
4916
5001
class cmd_bind(Command):
4935
5020
            try:
4936
5021
                location = b.get_old_bound_location()
4937
5022
            except errors.UpgradeRequired:
4938
 
                raise errors.BzrCommandError('No location supplied.  '
4939
 
                    'This format does not remember old locations.')
 
5023
                raise errors.BzrCommandError(gettext('No location supplied.  '
 
5024
                    'This format does not remember old locations.'))
4940
5025
            else:
4941
5026
                if location is None:
4942
5027
                    if b.get_bound_location() is not None:
4943
 
                        raise errors.BzrCommandError('Branch is already bound')
 
5028
                        raise errors.BzrCommandError(gettext('Branch is already bound'))
4944
5029
                    else:
4945
 
                        raise errors.BzrCommandError('No location supplied '
4946
 
                            'and no previous location known')
 
5030
                        raise errors.BzrCommandError(gettext('No location supplied '
 
5031
                            'and no previous location known'))
4947
5032
        b_other = Branch.open(location)
4948
5033
        try:
4949
5034
            b.bind(b_other)
4950
5035
        except errors.DivergedBranches:
4951
 
            raise errors.BzrCommandError('These branches have diverged.'
4952
 
                                         ' Try merging, and then bind again.')
 
5036
            raise errors.BzrCommandError(gettext('These branches have diverged.'
 
5037
                                         ' Try merging, and then bind again.'))
4953
5038
        if b.get_config().has_explicit_nickname():
4954
5039
            b.nick = b_other.nick
4955
5040
 
4968
5053
    def run(self, directory=u'.'):
4969
5054
        b, relpath = Branch.open_containing(directory)
4970
5055
        if not b.unbind():
4971
 
            raise errors.BzrCommandError('Local branch is not bound')
 
5056
            raise errors.BzrCommandError(gettext('Local branch is not bound'))
4972
5057
 
4973
5058
 
4974
5059
class cmd_uncommit(Command):
5047
5132
                rev_id = b.get_rev_id(revno)
5048
5133
 
5049
5134
        if rev_id is None or _mod_revision.is_null(rev_id):
5050
 
            self.outf.write('No revisions to uncommit.\n')
 
5135
            self.outf.write(gettext('No revisions to uncommit.\n'))
5051
5136
            return 1
5052
5137
 
5053
5138
        lf = log_formatter('short',
5062
5147
                 end_revision=last_revno)
5063
5148
 
5064
5149
        if dry_run:
5065
 
            self.outf.write('Dry-run, pretending to remove'
5066
 
                            ' the above revisions.\n')
 
5150
            self.outf.write(gettext('Dry-run, pretending to remove'
 
5151
                            ' the above revisions.\n'))
5067
5152
        else:
5068
 
            self.outf.write('The above revision(s) will be removed.\n')
 
5153
            self.outf.write(gettext('The above revision(s) will be removed.\n'))
5069
5154
 
5070
5155
        if not force:
5071
5156
            if not ui.ui_factory.confirm_action(
5072
 
                    u'Uncommit these revisions',
 
5157
                    gettext(u'Uncommit these revisions'),
5073
5158
                    'bzrlib.builtins.uncommit',
5074
5159
                    {}):
5075
 
                self.outf.write('Canceled\n')
 
5160
                self.outf.write(gettext('Canceled\n'))
5076
5161
                return 0
5077
5162
 
5078
5163
        mutter('Uncommitting from {%s} to {%s}',
5079
5164
               last_rev_id, rev_id)
5080
5165
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5081
5166
                 revno=revno, local=local, keep_tags=keep_tags)
5082
 
        self.outf.write('You can restore the old tip by running:\n'
5083
 
             '  bzr pull . -r revid:%s\n' % last_rev_id)
 
5167
        self.outf.write(gettext('You can restore the old tip by running:\n'
 
5168
             '  bzr pull . -r revid:%s\n') % last_rev_id)
5084
5169
 
5085
5170
 
5086
5171
class cmd_break_lock(Command):
5232
5317
        containing_tree = WorkingTree.open_containing(parent_dir)[0]
5233
5318
        repo = containing_tree.branch.repository
5234
5319
        if not repo.supports_rich_root():
5235
 
            raise errors.BzrCommandError(
 
5320
            raise errors.BzrCommandError(gettext(
5236
5321
                "Can't join trees because %s doesn't support rich root data.\n"
5237
 
                "You can use bzr upgrade on the repository."
 
5322
                "You can use bzr upgrade on the repository.")
5238
5323
                % (repo,))
5239
5324
        if reference:
5240
5325
            try:
5242
5327
            except errors.BadReferenceTarget, e:
5243
5328
                # XXX: Would be better to just raise a nicely printable
5244
5329
                # exception from the real origin.  Also below.  mbp 20070306
5245
 
                raise errors.BzrCommandError("Cannot join %s.  %s" %
5246
 
                                             (tree, e.reason))
 
5330
                raise errors.BzrCommandError(
 
5331
                       gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5247
5332
        else:
5248
5333
            try:
5249
5334
                containing_tree.subsume(sub_tree)
5250
5335
            except errors.BadSubsumeSource, e:
5251
 
                raise errors.BzrCommandError("Cannot join %s.  %s" %
5252
 
                                             (tree, e.reason))
 
5336
                raise errors.BzrCommandError(
 
5337
                       gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5253
5338
 
5254
5339
 
5255
5340
class cmd_split(Command):
5339
5424
        if submit_branch is None:
5340
5425
            submit_branch = branch.get_parent()
5341
5426
        if submit_branch is None:
5342
 
            raise errors.BzrCommandError('No submit branch specified or known')
 
5427
            raise errors.BzrCommandError(gettext('No submit branch specified or known'))
5343
5428
 
5344
5429
        stored_public_branch = branch.get_public_branch()
5345
5430
        if public_branch is None:
5347
5432
        elif stored_public_branch is None:
5348
5433
            branch.set_public_branch(public_branch)
5349
5434
        if not include_bundle and public_branch is None:
5350
 
            raise errors.BzrCommandError('No public branch specified or'
5351
 
                                         ' known')
 
5435
            raise errors.BzrCommandError(gettext('No public branch specified or'
 
5436
                                         ' known'))
5352
5437
        base_revision_id = None
5353
5438
        if revision is not None:
5354
5439
            if len(revision) > 2:
5355
 
                raise errors.BzrCommandError('bzr merge-directive takes '
5356
 
                    'at most two one revision identifiers')
 
5440
                raise errors.BzrCommandError(gettext('bzr merge-directive takes '
 
5441
                    'at most two one revision identifiers'))
5357
5442
            revision_id = revision[-1].as_revision_id(branch)
5358
5443
            if len(revision) == 2:
5359
5444
                base_revision_id = revision[0].as_revision_id(branch)
5361
5446
            revision_id = branch.last_revision()
5362
5447
        revision_id = ensure_null(revision_id)
5363
5448
        if revision_id == NULL_REVISION:
5364
 
            raise errors.BzrCommandError('No revisions to bundle.')
 
5449
            raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5365
5450
        directive = merge_directive.MergeDirective2.from_objects(
5366
5451
            branch.repository, revision_id, time.time(),
5367
5452
            osutils.local_time_offset(), submit_branch,
5413
5498
 
5414
5499
    Both the submit branch and the public branch follow the usual behavior with
5415
5500
    respect to --remember: If there is no default location set, the first send
5416
 
    will set it (use --no-remember to avoid settting it). After that, you can
 
5501
    will set it (use --no-remember to avoid setting it). After that, you can
5417
5502
    omit the location to use the default.  To change the default, use
5418
5503
    --remember. The value will only be saved if the location can be accessed.
5419
5504
 
5621
5706
        self.add_cleanup(branch.lock_write().unlock)
5622
5707
        if delete:
5623
5708
            if tag_name is None:
5624
 
                raise errors.BzrCommandError("No tag specified to delete.")
 
5709
                raise errors.BzrCommandError(gettext("No tag specified to delete."))
5625
5710
            branch.tags.delete_tag(tag_name)
5626
 
            note('Deleted tag %s.' % tag_name)
 
5711
            note(gettext('Deleted tag %s.') % tag_name)
5627
5712
        else:
5628
5713
            if revision:
5629
5714
                if len(revision) != 1:
5630
 
                    raise errors.BzrCommandError(
 
5715
                    raise errors.BzrCommandError(gettext(
5631
5716
                        "Tags can only be placed on a single revision, "
5632
 
                        "not on a range")
 
5717
                        "not on a range"))
5633
5718
                revision_id = revision[0].as_revision_id(branch)
5634
5719
            else:
5635
5720
                revision_id = branch.last_revision()
5636
5721
            if tag_name is None:
5637
5722
                tag_name = branch.automatic_tag_name(revision_id)
5638
5723
                if tag_name is None:
5639
 
                    raise errors.BzrCommandError(
5640
 
                        "Please specify a tag name.")
5641
 
            if (not force) and branch.tags.has_tag(tag_name):
 
5724
                    raise errors.BzrCommandError(gettext(
 
5725
                        "Please specify a tag name."))
 
5726
            try:
 
5727
                existing_target = branch.tags.lookup_tag(tag_name)
 
5728
            except errors.NoSuchTag:
 
5729
                existing_target = None
 
5730
            if not force and existing_target not in (None, revision_id):
5642
5731
                raise errors.TagAlreadyExists(tag_name)
5643
 
            branch.tags.set_tag(tag_name, revision_id)
5644
 
            note('Created tag %s.' % tag_name)
 
5732
            if existing_target == revision_id:
 
5733
                note(gettext('Tag %s already exists for that revision.') % tag_name)
 
5734
            else:
 
5735
                branch.tags.set_tag(tag_name, revision_id)
 
5736
                if existing_target is None:
 
5737
                    note(gettext('Created tag %s.') % tag_name)
 
5738
                else:
 
5739
                    note(gettext('Updated tag %s.') % tag_name)
5645
5740
 
5646
5741
 
5647
5742
class cmd_tags(Command):
5673
5768
 
5674
5769
        self.add_cleanup(branch.lock_read().unlock)
5675
5770
        if revision:
5676
 
            graph = branch.repository.get_graph()
5677
 
            rev1, rev2 = _get_revision_range(revision, branch, self.name())
5678
 
            revid1, revid2 = rev1.rev_id, rev2.rev_id
5679
 
            # only show revisions between revid1 and revid2 (inclusive)
5680
 
            tags = [(tag, revid) for tag, revid in tags if
5681
 
                graph.is_between(revid, revid1, revid2)]
 
5771
            # Restrict to the specified range
 
5772
            tags = self._tags_for_range(branch, revision)
5682
5773
        if sort is None:
5683
5774
            sort = tag_sort_methods.get()
5684
5775
        sort(branch, tags)
5689
5780
                    revno = branch.revision_id_to_dotted_revno(revid)
5690
5781
                    if isinstance(revno, tuple):
5691
5782
                        revno = '.'.join(map(str, revno))
5692
 
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
 
5783
                except (errors.NoSuchRevision,
 
5784
                        errors.GhostRevisionsHaveNoRevno):
5693
5785
                    # Bad tag data/merges can lead to tagged revisions
5694
5786
                    # which are not in this branch. Fail gracefully ...
5695
5787
                    revno = '?'
5698
5790
        for tag, revspec in tags:
5699
5791
            self.outf.write('%-20s %s\n' % (tag, revspec))
5700
5792
 
 
5793
    def _tags_for_range(self, branch, revision):
 
5794
        range_valid = True
 
5795
        rev1, rev2 = _get_revision_range(revision, branch, self.name())
 
5796
        revid1, revid2 = rev1.rev_id, rev2.rev_id
 
5797
        # _get_revision_range will always set revid2 if it's not specified.
 
5798
        # If revid1 is None, it means we want to start from the branch
 
5799
        # origin which is always a valid ancestor. If revid1 == revid2, the
 
5800
        # ancestry check is useless.
 
5801
        if revid1 and revid1 != revid2:
 
5802
            # FIXME: We really want to use the same graph than
 
5803
            # branch.iter_merge_sorted_revisions below, but this is not
 
5804
            # easily available -- vila 2011-09-23
 
5805
            if branch.repository.get_graph().is_ancestor(revid2, revid1):
 
5806
                # We don't want to output anything in this case...
 
5807
                return []
 
5808
        # only show revisions between revid1 and revid2 (inclusive)
 
5809
        tagged_revids = branch.tags.get_reverse_tag_dict()
 
5810
        found = []
 
5811
        for r in branch.iter_merge_sorted_revisions(
 
5812
            start_revision_id=revid2, stop_revision_id=revid1,
 
5813
            stop_rule='include'):
 
5814
            revid_tags = tagged_revids.get(r[0], None)
 
5815
            if revid_tags:
 
5816
                found.extend([(tag, r[0]) for tag in revid_tags])
 
5817
        return found
 
5818
 
5701
5819
 
5702
5820
class cmd_reconfigure(Command):
5703
5821
    __doc__ = """Reconfigure the type of a bzr directory.
5717
5835
    takes_args = ['location?']
5718
5836
    takes_options = [
5719
5837
        RegistryOption.from_kwargs(
5720
 
            'target_type',
5721
 
            title='Target type',
5722
 
            help='The type to reconfigure the directory to.',
 
5838
            'tree_type',
 
5839
            title='Tree type',
 
5840
            help='The relation between branch and tree.',
5723
5841
            value_switches=True, enum_switch=False,
5724
5842
            branch='Reconfigure to be an unbound branch with no working tree.',
5725
5843
            tree='Reconfigure to be an unbound branch with a working tree.',
5726
5844
            checkout='Reconfigure to be a bound branch with a working tree.',
5727
5845
            lightweight_checkout='Reconfigure to be a lightweight'
5728
5846
                ' checkout (with no local history).',
 
5847
            ),
 
5848
        RegistryOption.from_kwargs(
 
5849
            'repository_type',
 
5850
            title='Repository type',
 
5851
            help='Location fo the repository.',
 
5852
            value_switches=True, enum_switch=False,
5729
5853
            standalone='Reconfigure to be a standalone branch '
5730
5854
                '(i.e. stop using shared repository).',
5731
5855
            use_shared='Reconfigure to use a shared repository.',
 
5856
            ),
 
5857
        RegistryOption.from_kwargs(
 
5858
            'repository_trees',
 
5859
            title='Trees in Repository',
 
5860
            help='Whether new branches in the repository have trees.',
 
5861
            value_switches=True, enum_switch=False,
5732
5862
            with_trees='Reconfigure repository to create '
5733
5863
                'working trees on branches by default.',
5734
5864
            with_no_trees='Reconfigure repository to not create '
5748
5878
            ),
5749
5879
        ]
5750
5880
 
5751
 
    def run(self, location=None, target_type=None, bind_to=None, force=False,
5752
 
            stacked_on=None,
5753
 
            unstacked=None):
 
5881
    def run(self, location=None, bind_to=None, force=False,
 
5882
            tree_type=None, repository_type=None, repository_trees=None,
 
5883
            stacked_on=None, unstacked=None):
5754
5884
        directory = bzrdir.BzrDir.open(location)
5755
5885
        if stacked_on and unstacked:
5756
 
            raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
 
5886
            raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5757
5887
        elif stacked_on is not None:
5758
5888
            reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5759
5889
        elif unstacked:
5761
5891
        # At the moment you can use --stacked-on and a different
5762
5892
        # reconfiguration shape at the same time; there seems no good reason
5763
5893
        # to ban it.
5764
 
        if target_type is None:
 
5894
        if (tree_type is None and
 
5895
            repository_type is None and
 
5896
            repository_trees is None):
5765
5897
            if stacked_on or unstacked:
5766
5898
                return
5767
5899
            else:
5768
 
                raise errors.BzrCommandError('No target configuration '
5769
 
                    'specified')
5770
 
        elif target_type == 'branch':
 
5900
                raise errors.BzrCommandError(gettext('No target configuration '
 
5901
                    'specified'))
 
5902
        reconfiguration = None
 
5903
        if tree_type == 'branch':
5771
5904
            reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5772
 
        elif target_type == 'tree':
 
5905
        elif tree_type == 'tree':
5773
5906
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5774
 
        elif target_type == 'checkout':
 
5907
        elif tree_type == 'checkout':
5775
5908
            reconfiguration = reconfigure.Reconfigure.to_checkout(
5776
5909
                directory, bind_to)
5777
 
        elif target_type == 'lightweight-checkout':
 
5910
        elif tree_type == 'lightweight-checkout':
5778
5911
            reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5779
5912
                directory, bind_to)
5780
 
        elif target_type == 'use-shared':
 
5913
        if reconfiguration:
 
5914
            reconfiguration.apply(force)
 
5915
            reconfiguration = None
 
5916
        if repository_type == 'use-shared':
5781
5917
            reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5782
 
        elif target_type == 'standalone':
 
5918
        elif repository_type == 'standalone':
5783
5919
            reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5784
 
        elif target_type == 'with-trees':
 
5920
        if reconfiguration:
 
5921
            reconfiguration.apply(force)
 
5922
            reconfiguration = None
 
5923
        if repository_trees == 'with-trees':
5785
5924
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5786
5925
                directory, True)
5787
 
        elif target_type == 'with-no-trees':
 
5926
        elif repository_trees == 'with-no-trees':
5788
5927
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5789
5928
                directory, False)
5790
 
        reconfiguration.apply(force)
 
5929
        if reconfiguration:
 
5930
            reconfiguration.apply(force)
 
5931
            reconfiguration = None
5791
5932
 
5792
5933
 
5793
5934
class cmd_switch(Command):
5831
5972
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
5832
5973
        if to_location is None:
5833
5974
            if revision is None:
5834
 
                raise errors.BzrCommandError('You must supply either a'
5835
 
                                             ' revision or a location')
 
5975
                raise errors.BzrCommandError(gettext('You must supply either a'
 
5976
                                             ' revision or a location'))
5836
5977
            to_location = tree_location
5837
5978
        try:
5838
5979
            branch = control_dir.open_branch()
5842
5983
            had_explicit_nick = False
5843
5984
        if create_branch:
5844
5985
            if branch is None:
5845
 
                raise errors.BzrCommandError('cannot create branch without'
5846
 
                                             ' source branch')
 
5986
                raise errors.BzrCommandError(gettext('cannot create branch without'
 
5987
                                             ' source branch'))
5847
5988
            to_location = directory_service.directories.dereference(
5848
5989
                              to_location)
5849
5990
            if '/' not in to_location and '\\' not in to_location:
5866
6007
        if had_explicit_nick:
5867
6008
            branch = control_dir.open_branch() #get the new branch!
5868
6009
            branch.nick = to_branch.nick
5869
 
        note('Switched to branch: %s',
 
6010
        note(gettext('Switched to branch: %s'),
5870
6011
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5871
6012
 
5872
6013
    def _get_branch_location(self, control_dir):
5981
6122
            name = current_view
5982
6123
        if delete:
5983
6124
            if file_list:
5984
 
                raise errors.BzrCommandError(
5985
 
                    "Both --delete and a file list specified")
 
6125
                raise errors.BzrCommandError(gettext(
 
6126
                    "Both --delete and a file list specified"))
5986
6127
            elif switch:
5987
 
                raise errors.BzrCommandError(
5988
 
                    "Both --delete and --switch specified")
 
6128
                raise errors.BzrCommandError(gettext(
 
6129
                    "Both --delete and --switch specified"))
5989
6130
            elif all:
5990
6131
                tree.views.set_view_info(None, {})
5991
 
                self.outf.write("Deleted all views.\n")
 
6132
                self.outf.write(gettext("Deleted all views.\n"))
5992
6133
            elif name is None:
5993
 
                raise errors.BzrCommandError("No current view to delete")
 
6134
                raise errors.BzrCommandError(gettext("No current view to delete"))
5994
6135
            else:
5995
6136
                tree.views.delete_view(name)
5996
 
                self.outf.write("Deleted '%s' view.\n" % name)
 
6137
                self.outf.write(gettext("Deleted '%s' view.\n") % name)
5997
6138
        elif switch:
5998
6139
            if file_list:
5999
 
                raise errors.BzrCommandError(
6000
 
                    "Both --switch and a file list specified")
 
6140
                raise errors.BzrCommandError(gettext(
 
6141
                    "Both --switch and a file list specified"))
6001
6142
            elif all:
6002
 
                raise errors.BzrCommandError(
6003
 
                    "Both --switch and --all specified")
 
6143
                raise errors.BzrCommandError(gettext(
 
6144
                    "Both --switch and --all specified"))
6004
6145
            elif switch == 'off':
6005
6146
                if current_view is None:
6006
 
                    raise errors.BzrCommandError("No current view to disable")
 
6147
                    raise errors.BzrCommandError(gettext("No current view to disable"))
6007
6148
                tree.views.set_view_info(None, view_dict)
6008
 
                self.outf.write("Disabled '%s' view.\n" % (current_view))
 
6149
                self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
6009
6150
            else:
6010
6151
                tree.views.set_view_info(switch, view_dict)
6011
6152
                view_str = views.view_display_str(tree.views.lookup_view())
6012
 
                self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
 
6153
                self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
6013
6154
        elif all:
6014
6155
            if view_dict:
6015
 
                self.outf.write('Views defined:\n')
 
6156
                self.outf.write(gettext('Views defined:\n'))
6016
6157
                for view in sorted(view_dict):
6017
6158
                    if view == current_view:
6018
6159
                        active = "=>"
6021
6162
                    view_str = views.view_display_str(view_dict[view])
6022
6163
                    self.outf.write('%s %-20s %s\n' % (active, view, view_str))
6023
6164
            else:
6024
 
                self.outf.write('No views defined.\n')
 
6165
                self.outf.write(gettext('No views defined.\n'))
6025
6166
        elif file_list:
6026
6167
            if name is None:
6027
6168
                # No name given and no current view set
6028
6169
                name = 'my'
6029
6170
            elif name == 'off':
6030
 
                raise errors.BzrCommandError(
6031
 
                    "Cannot change the 'off' pseudo view")
 
6171
                raise errors.BzrCommandError(gettext(
 
6172
                    "Cannot change the 'off' pseudo view"))
6032
6173
            tree.views.set_view(name, sorted(file_list))
6033
6174
            view_str = views.view_display_str(tree.views.lookup_view())
6034
 
            self.outf.write("Using '%s' view: %s\n" % (name, view_str))
 
6175
            self.outf.write(gettext("Using '{0}' view: {1}\n").format(name, view_str))
6035
6176
        else:
6036
6177
            # list the files
6037
6178
            if name is None:
6038
6179
                # No name given and no current view set
6039
 
                self.outf.write('No current view.\n')
 
6180
                self.outf.write(gettext('No current view.\n'))
6040
6181
            else:
6041
6182
                view_str = views.view_display_str(tree.views.lookup_view(name))
6042
 
                self.outf.write("'%s' view is: %s\n" % (name, view_str))
 
6183
                self.outf.write(gettext("'{0}' view is: {1}\n").format(name, view_str))
6043
6184
 
6044
6185
 
6045
6186
class cmd_hooks(Command):
6059
6200
                        self.outf.write("    %s\n" %
6060
6201
                                        (some_hooks.get_hook_name(hook),))
6061
6202
                else:
6062
 
                    self.outf.write("    <no hooks installed>\n")
 
6203
                    self.outf.write(gettext("    <no hooks installed>\n"))
6063
6204
 
6064
6205
 
6065
6206
class cmd_remove_branch(Command):
6166
6307
        manager = tree.get_shelf_manager()
6167
6308
        shelves = manager.active_shelves()
6168
6309
        if len(shelves) == 0:
6169
 
            note('No shelved changes.')
 
6310
            note(gettext('No shelved changes.'))
6170
6311
            return 0
6171
6312
        for shelf_id in reversed(shelves):
6172
6313
            message = manager.get_metadata(shelf_id).get('message')