~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Abbreviate pack_stat struct format to '>6L'

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    rename_map,
45
45
    revision as _mod_revision,
46
46
    static_tuple,
47
 
    symbol_versioning,
48
47
    timestamp,
49
48
    transport,
50
49
    ui,
51
50
    urlutils,
52
51
    views,
 
52
    gpg,
53
53
    )
54
54
from bzrlib.branch import Branch
55
55
from bzrlib.conflicts import ConflictList
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 (
72
73
    _parse_revision_str,
73
74
    )
74
75
from bzrlib.trace import mutter, note, warning, is_quiet, get_verbosity_level
 
76
from bzrlib import (
 
77
    symbol_versioning,
 
78
    )
75
79
 
76
80
 
77
81
@symbol_versioning.deprecated_function(symbol_versioning.deprecated_in((2, 3, 0)))
109
113
            if view_files:
110
114
                file_list = view_files
111
115
                view_str = views.view_display_str(view_files)
112
 
                note("Ignoring files outside view. View is %s" % view_str)
 
116
                note(gettext("Ignoring files outside view. View is %s") % view_str)
113
117
    return tree, file_list
114
118
 
115
119
 
117
121
    if revisions is None:
118
122
        return None
119
123
    if len(revisions) != 1:
120
 
        raise errors.BzrCommandError(
121
 
            'bzr %s --revision takes exactly one revision identifier' % (
 
124
        raise errors.BzrCommandError(gettext(
 
125
            'bzr %s --revision takes exactly one revision identifier') % (
122
126
                command_name,))
123
127
    return revisions[0]
124
128
 
229
233
    unknown
230
234
        Not versioned and not matching an ignore pattern.
231
235
 
232
 
    Additionally for directories, symlinks and files with an executable
233
 
    bit, Bazaar indicates their type using a trailing character: '/', '@'
234
 
    or '*' respectively.
 
236
    Additionally for directories, symlinks and files with a changed
 
237
    executable bit, Bazaar indicates their type using a trailing
 
238
    character: '/', '@' or '*' respectively. These decorations can be
 
239
    disabled using the '--no-classify' option.
235
240
 
236
241
    To see ignored files use 'bzr ignored'.  For details on the
237
242
    changes to file texts, use 'bzr diff'.
268
273
                            short_name='V'),
269
274
                     Option('no-pending', help='Don\'t show pending merges.',
270
275
                           ),
 
276
                     Option('no-classify',
 
277
                            help='Do not mark object type using indicator.',
 
278
                           ),
271
279
                     ]
272
280
    aliases = ['st', 'stat']
273
281
 
276
284
 
277
285
    @display_command
278
286
    def run(self, show_ids=False, file_list=None, revision=None, short=False,
279
 
            versioned=False, no_pending=False, verbose=False):
 
287
            versioned=False, no_pending=False, verbose=False,
 
288
            no_classify=False):
280
289
        from bzrlib.status import show_tree_status
281
290
 
282
291
        if revision and len(revision) > 2:
283
 
            raise errors.BzrCommandError('bzr status --revision takes exactly'
284
 
                                         ' one or two revision specifiers')
 
292
            raise errors.BzrCommandError(gettext('bzr status --revision takes exactly'
 
293
                                         ' one or two revision specifiers'))
285
294
 
286
295
        tree, relfile_list = WorkingTree.open_containing_paths(file_list)
287
296
        # Avoid asking for specific files when that is not needed.
296
305
        show_tree_status(tree, show_ids=show_ids,
297
306
                         specific_files=relfile_list, revision=revision,
298
307
                         to_file=self.outf, short=short, versioned=versioned,
299
 
                         show_pending=(not no_pending), verbose=verbose)
 
308
                         show_pending=(not no_pending), verbose=verbose,
 
309
                         classify=not no_classify)
300
310
 
301
311
 
302
312
class cmd_cat_revision(Command):
323
333
    @display_command
324
334
    def run(self, revision_id=None, revision=None, directory=u'.'):
325
335
        if revision_id is not None and revision is not None:
326
 
            raise errors.BzrCommandError('You can only supply one of'
327
 
                                         ' revision_id or --revision')
 
336
            raise errors.BzrCommandError(gettext('You can only supply one of'
 
337
                                         ' revision_id or --revision'))
328
338
        if revision_id is None and revision is None:
329
 
            raise errors.BzrCommandError('You must supply either'
330
 
                                         ' --revision or a revision_id')
 
339
            raise errors.BzrCommandError(gettext('You must supply either'
 
340
                                         ' --revision or a revision_id'))
331
341
 
332
342
        b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
333
343
 
334
344
        revisions = b.repository.revisions
335
345
        if revisions is None:
336
 
            raise errors.BzrCommandError('Repository %r does not support '
337
 
                'access to raw revision texts')
 
346
            raise errors.BzrCommandError(gettext('Repository %r does not support '
 
347
                'access to raw revision texts'))
338
348
 
339
349
        b.repository.lock_read()
340
350
        try:
344
354
                try:
345
355
                    self.print_revision(revisions, revision_id)
346
356
                except errors.NoSuchRevision:
347
 
                    msg = "The repository %s contains no revision %s." % (
 
357
                    msg = gettext("The repository {0} contains no revision {1}.").format(
348
358
                        b.repository.base, revision_id)
349
359
                    raise errors.BzrCommandError(msg)
350
360
            elif revision is not None:
351
361
                for rev in revision:
352
362
                    if rev is None:
353
363
                        raise errors.BzrCommandError(
354
 
                            'You cannot specify a NULL revision.')
 
364
                            gettext('You cannot specify a NULL revision.'))
355
365
                    rev_id = rev.as_revision_id(b)
356
366
                    self.print_revision(revisions, rev_id)
357
367
        finally:
468
478
            try:
469
479
                working = d.open_workingtree()
470
480
            except errors.NoWorkingTree:
471
 
                raise errors.BzrCommandError("No working tree to remove")
 
481
                raise errors.BzrCommandError(gettext("No working tree to remove"))
472
482
            except errors.NotLocalUrl:
473
 
                raise errors.BzrCommandError("You cannot remove the working tree"
474
 
                                             " of a remote path")
 
483
                raise errors.BzrCommandError(gettext("You cannot remove the working tree"
 
484
                                             " of a remote path"))
475
485
            if not force:
476
486
                if (working.has_changes()):
477
487
                    raise errors.UncommittedChanges(working)
479
489
                    raise errors.ShelvedChanges(working)
480
490
 
481
491
            if working.user_url != working.branch.user_url:
482
 
                raise errors.BzrCommandError("You cannot remove the working tree"
483
 
                                             " from a lightweight checkout")
 
492
                raise errors.BzrCommandError(gettext("You cannot remove the working tree"
 
493
                                             " from a lightweight checkout"))
484
494
 
485
495
            d.destroy_workingtree()
486
496
 
518
528
                pass # There seems to be a real error here, so we'll reset
519
529
            else:
520
530
                # Refuse
521
 
                raise errors.BzrCommandError(
 
531
                raise errors.BzrCommandError(gettext(
522
532
                    'The tree does not appear to be corrupt. You probably'
523
533
                    ' want "bzr revert" instead. Use "--force" if you are'
524
 
                    ' sure you want to reset the working tree.')
 
534
                    ' sure you want to reset the working tree.'))
525
535
        if revision is None:
526
536
            revision_ids = None
527
537
        else:
530
540
            tree.reset_state(revision_ids)
531
541
        except errors.BzrError, e:
532
542
            if revision_ids is None:
533
 
                extra = (', the header appears corrupt, try passing -r -1'
534
 
                         ' 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'))
535
545
            else:
536
546
                extra = ''
537
 
            raise errors.BzrCommandError('failed to reset the tree state'
538
 
                                         + extra)
 
547
            raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
539
548
 
540
549
 
541
550
class cmd_revno(Command):
644
653
    are added.  This search proceeds recursively into versioned
645
654
    directories.  If no names are given '.' is assumed.
646
655
 
 
656
    A warning will be printed when nested trees are encountered,
 
657
    unless they are explicitly ignored.
 
658
 
647
659
    Therefore simply saying 'bzr add' will version all files that
648
660
    are currently unknown.
649
661
 
665
677
    
666
678
    Any files matching patterns in the ignore list will not be added
667
679
    unless they are explicitly mentioned.
 
680
    
 
681
    In recursive mode, files larger than the configuration option 
 
682
    add.maximum_file_size will be skipped. Named items are never skipped due
 
683
    to file size.
668
684
    """
669
685
    takes_args = ['file*']
670
686
    takes_options = [
697
713
            action = bzrlib.add.AddFromBaseAction(base_tree, base_path,
698
714
                          to_file=self.outf, should_print=(not is_quiet()))
699
715
        else:
700
 
            action = bzrlib.add.AddAction(to_file=self.outf,
 
716
            action = bzrlib.add.AddWithSkipLargeAction(to_file=self.outf,
701
717
                should_print=(not is_quiet()))
702
718
 
703
719
        if base_tree:
710
726
            if verbose:
711
727
                for glob in sorted(ignored.keys()):
712
728
                    for path in ignored[glob]:
713
 
                        self.outf.write("ignored %s matching \"%s\"\n"
714
 
                                        % (path, glob))
 
729
                        self.outf.write(
 
730
                         gettext("ignored {0} matching \"{1}\"\n").format(
 
731
                         path, glob))
715
732
 
716
733
 
717
734
class cmd_mkdir(Command):
731
748
            if id != None:
732
749
                os.mkdir(d)
733
750
                wt.add([dd])
734
 
                self.outf.write('added %s\n' % d)
 
751
                self.outf.write(gettext('added %s\n') % d)
735
752
            else:
736
753
                raise errors.NotVersionedError(path=base)
737
754
 
775
792
    @display_command
776
793
    def run(self, revision=None, show_ids=False, kind=None, file_list=None):
777
794
        if kind and kind not in ['file', 'directory', 'symlink']:
778
 
            raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
 
795
            raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
779
796
 
780
797
        revision = _get_one_revision('inventory', revision)
781
798
        work_tree, file_list = WorkingTree.open_containing_paths(file_list)
794
811
                                      require_versioned=True)
795
812
            # find_ids_across_trees may include some paths that don't
796
813
            # exist in 'tree'.
797
 
            entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
798
 
                             for file_id in file_ids if file_id in tree)
 
814
            entries = sorted(
 
815
                (tree.id2path(file_id), tree.inventory[file_id])
 
816
                for file_id in file_ids if tree.has_id(file_id))
799
817
        else:
800
818
            entries = tree.inventory.entries()
801
819
 
844
862
        if auto:
845
863
            return self.run_auto(names_list, after, dry_run)
846
864
        elif dry_run:
847
 
            raise errors.BzrCommandError('--dry-run requires --auto.')
 
865
            raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
848
866
        if names_list is None:
849
867
            names_list = []
850
868
        if len(names_list) < 2:
851
 
            raise errors.BzrCommandError("missing file argument")
 
869
            raise errors.BzrCommandError(gettext("missing file argument"))
852
870
        tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
853
871
        self.add_cleanup(tree.lock_tree_write().unlock)
854
872
        self._run(tree, names_list, rel_names, after)
855
873
 
856
874
    def run_auto(self, names_list, after, dry_run):
857
875
        if names_list is not None and len(names_list) > 1:
858
 
            raise errors.BzrCommandError('Only one path may be specified to'
859
 
                                         ' --auto.')
 
876
            raise errors.BzrCommandError(gettext('Only one path may be specified to'
 
877
                                         ' --auto.'))
860
878
        if after:
861
 
            raise errors.BzrCommandError('--after cannot be specified with'
862
 
                                         ' --auto.')
 
879
            raise errors.BzrCommandError(gettext('--after cannot be specified with'
 
880
                                         ' --auto.'))
863
881
        work_tree, file_list = WorkingTree.open_containing_paths(
864
882
            names_list, default_directory='.')
865
883
        self.add_cleanup(work_tree.lock_tree_write().unlock)
895
913
                    self.outf.write("%s => %s\n" % (src, dest))
896
914
        else:
897
915
            if len(names_list) != 2:
898
 
                raise errors.BzrCommandError('to mv multiple files the'
 
916
                raise errors.BzrCommandError(gettext('to mv multiple files the'
899
917
                                             ' destination must be a versioned'
900
 
                                             ' directory')
 
918
                                             ' directory'))
901
919
 
902
920
            # for cicp file-systems: the src references an existing inventory
903
921
            # item:
962
980
    match the remote one, use pull --overwrite. This will work even if the two
963
981
    branches have diverged.
964
982
 
965
 
    If there is no default location set, the first pull will set it.  After
966
 
    that, you can omit the location to use the default.  To change the
967
 
    default, use --remember. The value will only be saved if the remote
968
 
    location can be accessed.
 
983
    If there is no default location set, the first pull will set it (use
 
984
    --no-remember to avoid setting it). After that, you can omit the
 
985
    location to use the default.  To change the default, use --remember. The
 
986
    value will only be saved if the remote location can be accessed.
969
987
 
970
988
    Note: The location can be specified either in the form of a branch,
971
989
    or in the form of a path to a file containing a merge directive generated
990
1008
    takes_args = ['location?']
991
1009
    encoding_type = 'replace'
992
1010
 
993
 
    def run(self, location=None, remember=False, overwrite=False,
 
1011
    def run(self, location=None, remember=None, overwrite=False,
994
1012
            revision=None, verbose=False,
995
1013
            directory=None, local=False,
996
1014
            show_base=False):
1009
1027
            self.add_cleanup(branch_to.lock_write().unlock)
1010
1028
 
1011
1029
        if tree_to is None and show_base:
1012
 
            raise errors.BzrCommandError("Need working tree for --show-base.")
 
1030
            raise errors.BzrCommandError(gettext("Need working tree for --show-base."))
1013
1031
 
1014
1032
        if local and not branch_to.get_bound_location():
1015
1033
            raise errors.LocalRequiresBoundBranch()
1025
1043
        stored_loc = branch_to.get_parent()
1026
1044
        if location is None:
1027
1045
            if stored_loc is None:
1028
 
                raise errors.BzrCommandError("No pull location known or"
1029
 
                                             " specified.")
 
1046
                raise errors.BzrCommandError(gettext("No pull location known or"
 
1047
                                             " specified."))
1030
1048
            else:
1031
1049
                display_url = urlutils.unescape_for_display(stored_loc,
1032
1050
                        self.outf.encoding)
1033
1051
                if not is_quiet():
1034
 
                    self.outf.write("Using saved parent location: %s\n" % display_url)
 
1052
                    self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1035
1053
                location = stored_loc
1036
1054
 
1037
1055
        revision = _get_one_revision('pull', revision)
1038
1056
        if mergeable is not None:
1039
1057
            if revision is not None:
1040
 
                raise errors.BzrCommandError(
1041
 
                    'Cannot use -r with merge directives or bundles')
 
1058
                raise errors.BzrCommandError(gettext(
 
1059
                    'Cannot use -r with merge directives or bundles'))
1042
1060
            mergeable.install_revisions(branch_to.repository)
1043
1061
            base_revision_id, revision_id, verified = \
1044
1062
                mergeable.get_merge_request(branch_to.repository)
1047
1065
            branch_from = Branch.open(location,
1048
1066
                possible_transports=possible_transports)
1049
1067
            self.add_cleanup(branch_from.lock_read().unlock)
1050
 
 
1051
 
            if branch_to.get_parent() is None or remember:
 
1068
            # Remembers if asked explicitly or no previous location is set
 
1069
            if (remember
 
1070
                or (remember is None and branch_to.get_parent() is None)):
1052
1071
                branch_to.set_parent(branch_from.base)
1053
1072
 
1054
1073
        if revision is not None:
1061
1080
                view_info=view_info)
1062
1081
            result = tree_to.pull(
1063
1082
                branch_from, overwrite, revision_id, change_reporter,
1064
 
                possible_transports=possible_transports, local=local,
1065
 
                show_base=show_base)
 
1083
                local=local, show_base=show_base)
1066
1084
        else:
1067
1085
            result = branch_to.pull(
1068
1086
                branch_from, overwrite, revision_id, local=local)
1098
1116
    do a merge (see bzr help merge) from the other branch, and commit that.
1099
1117
    After that you will be able to do a push without '--overwrite'.
1100
1118
 
1101
 
    If there is no default push location set, the first push will set it.
1102
 
    After that, you can omit the location to use the default.  To change the
1103
 
    default, use --remember. The value will only be saved if the remote
1104
 
    location can be accessed.
 
1119
    If there is no default push location set, the first push will set it (use
 
1120
    --no-remember to avoid setting it).  After that, you can omit the
 
1121
    location to use the default.  To change the default, use --remember. The
 
1122
    value will only be saved if the remote location can be accessed.
1105
1123
    """
1106
1124
 
1107
1125
    _see_also = ['pull', 'update', 'working-trees']
1135
1153
    takes_args = ['location?']
1136
1154
    encoding_type = 'replace'
1137
1155
 
1138
 
    def run(self, location=None, remember=False, overwrite=False,
 
1156
    def run(self, location=None, remember=None, overwrite=False,
1139
1157
        create_prefix=False, verbose=False, revision=None,
1140
1158
        use_existing_dir=False, directory=None, stacked_on=None,
1141
1159
        stacked=False, strict=None, no_tree=False):
1172
1190
                    # error by the feedback given to them. RBC 20080227.
1173
1191
                    stacked_on = parent_url
1174
1192
            if not stacked_on:
1175
 
                raise errors.BzrCommandError(
1176
 
                    "Could not determine branch to refer to.")
 
1193
                raise errors.BzrCommandError(gettext(
 
1194
                    "Could not determine branch to refer to."))
1177
1195
 
1178
1196
        # Get the destination location
1179
1197
        if location is None:
1180
1198
            stored_loc = br_from.get_push_location()
1181
1199
            if stored_loc is None:
1182
 
                raise errors.BzrCommandError(
1183
 
                    "No push location known or specified.")
 
1200
                raise errors.BzrCommandError(gettext(
 
1201
                    "No push location known or specified."))
1184
1202
            else:
1185
1203
                display_url = urlutils.unescape_for_display(stored_loc,
1186
1204
                        self.outf.encoding)
1187
 
                self.outf.write("Using saved push location: %s\n" % display_url)
 
1205
                note(gettext("Using saved push location: %s") % display_url)
1188
1206
                location = stored_loc
1189
1207
 
1190
1208
        _show_push_branch(br_from, revision_id, location, self.outf,
1273
1291
            to_transport.mkdir('.')
1274
1292
        except errors.FileExists:
1275
1293
            if not use_existing_dir:
1276
 
                raise errors.BzrCommandError('Target directory "%s" '
1277
 
                    'already exists.' % to_location)
 
1294
                raise errors.BzrCommandError(gettext('Target directory "%s" '
 
1295
                    'already exists.') % to_location)
1278
1296
            else:
1279
1297
                try:
1280
1298
                    bzrdir.BzrDir.open_from_transport(to_transport)
1283
1301
                else:
1284
1302
                    raise errors.AlreadyBranchError(to_location)
1285
1303
        except errors.NoSuchFile:
1286
 
            raise errors.BzrCommandError('Parent of "%s" does not exist.'
 
1304
            raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1287
1305
                                         % to_location)
1288
1306
        try:
1289
1307
            # preserve whatever source format we have.
1297
1315
            branch = dir.open_branch()
1298
1316
        except errors.NoSuchRevision:
1299
1317
            to_transport.delete_tree('.')
1300
 
            msg = "The branch %s has no revision %s." % (from_location,
1301
 
                revision)
 
1318
            msg = gettext("The branch {0} has no revision {1}.").format(
 
1319
                from_location, revision)
1302
1320
            raise errors.BzrCommandError(msg)
1303
1321
        _merge_tags_if_possible(br_from, branch)
1304
1322
        # If the source branch is stacked, the new branch may
1305
1323
        # be stacked whether we asked for that explicitly or not.
1306
1324
        # We therefore need a try/except here and not just 'if stacked:'
1307
1325
        try:
1308
 
            note('Created new stacked branch referring to %s.' %
 
1326
            note(gettext('Created new stacked branch referring to %s.') %
1309
1327
                branch.get_stacked_on_url())
1310
1328
        except (errors.NotStacked, errors.UnstackableBranchFormat,
1311
1329
            errors.UnstackableRepositoryFormat), e:
1312
 
            note('Branched %d revision(s).' % branch.revno())
 
1330
            note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1313
1331
        if bind:
1314
1332
            # Bind to the parent
1315
1333
            parent_branch = Branch.open(from_location)
1316
1334
            branch.bind(parent_branch)
1317
 
            note('New branch bound to %s' % from_location)
 
1335
            note(gettext('New branch bound to %s') % from_location)
1318
1336
        if switch:
1319
1337
            # Switch to the new branch
1320
1338
            wt, _ = WorkingTree.open_containing('.')
1321
1339
            _mod_switch.switch(wt.bzrdir, branch)
1322
 
            note('Switched to branch: %s',
 
1340
            note(gettext('Switched to branch: %s'),
1323
1341
                urlutils.unescape_for_display(branch.base, 'utf-8'))
1324
1342
 
1325
1343
 
 
1344
class cmd_branches(Command):
 
1345
    __doc__ = """List the branches available at the current location.
 
1346
 
 
1347
    This command will print the names of all the branches at the current
 
1348
    location.
 
1349
    """
 
1350
 
 
1351
    takes_args = ['location?']
 
1352
    takes_options = [
 
1353
                  Option('recursive', short_name='R',
 
1354
                         help='Recursively scan for branches rather than '
 
1355
                              'just looking in the specified location.')]
 
1356
 
 
1357
    def run(self, location=".", recursive=False):
 
1358
        if recursive:
 
1359
            t = transport.get_transport(location)
 
1360
            if not t.listable():
 
1361
                raise errors.BzrCommandError(
 
1362
                    "Can't scan this type of location.")
 
1363
            for b in bzrdir.BzrDir.find_branches(t):
 
1364
                self.outf.write("%s\n" % urlutils.unescape_for_display(
 
1365
                    urlutils.relative_url(t.base, b.base),
 
1366
                    self.outf.encoding).rstrip("/"))
 
1367
        else:
 
1368
            dir = bzrdir.BzrDir.open_containing(location)[0]
 
1369
            for branch in dir.list_branches():
 
1370
                if branch.name is None:
 
1371
                    self.outf.write(gettext(" (default)\n"))
 
1372
                else:
 
1373
                    self.outf.write(" %s\n" % branch.name.encode(
 
1374
                        self.outf.encoding))
 
1375
 
 
1376
 
1326
1377
class cmd_checkout(Command):
1327
1378
    __doc__ = """Create a new checkout of an existing branch.
1328
1379
 
1454
1505
 
1455
1506
    def run(self, dir='.', revision=None, show_base=None):
1456
1507
        if revision is not None and len(revision) != 1:
1457
 
            raise errors.BzrCommandError(
1458
 
                        "bzr update --revision takes exactly one revision")
 
1508
            raise errors.BzrCommandError(gettext(
 
1509
                        "bzr update --revision takes exactly one revision"))
1459
1510
        tree = WorkingTree.open_containing(dir)[0]
1460
1511
        branch = tree.branch
1461
1512
        possible_transports = []
1486
1537
            revision_id = branch.last_revision()
1487
1538
        if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1488
1539
            revno = branch.revision_id_to_dotted_revno(revision_id)
1489
 
            note("Tree is up to date at revision %s of branch %s" %
1490
 
                ('.'.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))
1491
1542
            return 0
1492
1543
        view_info = _get_view_info_for_change_reporter(tree)
1493
1544
        change_reporter = delta._ChangeReporter(
1501
1552
                old_tip=old_tip,
1502
1553
                show_base=show_base)
1503
1554
        except errors.NoSuchRevision, e:
1504
 
            raise errors.BzrCommandError(
 
1555
            raise errors.BzrCommandError(gettext(
1505
1556
                                  "branch has no revision %s\n"
1506
1557
                                  "bzr update --revision only works"
1507
 
                                  " for a revision in the branch history"
 
1558
                                  " for a revision in the branch history")
1508
1559
                                  % (e.revision))
1509
1560
        revno = tree.branch.revision_id_to_dotted_revno(
1510
1561
            _mod_revision.ensure_null(tree.last_revision()))
1511
 
        note('Updated to revision %s of branch %s' %
1512
 
             ('.'.join(map(str, revno)), branch_location))
 
1562
        note(gettext('Updated to revision {0} of branch {1}').format(
 
1563
             '.'.join(map(str, revno)), branch_location))
1513
1564
        parent_ids = tree.get_parent_ids()
1514
1565
        if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1515
 
            note('Your local commits will now show as pending merges with '
1516
 
                 "'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'."))
1517
1568
        if conflicts != 0:
1518
1569
            return 1
1519
1570
        else:
1591
1642
    def run(self, file_list, verbose=False, new=False,
1592
1643
        file_deletion_strategy='safe'):
1593
1644
        if file_deletion_strategy == 'force':
1594
 
            note("(The --force option is deprecated, rather use --no-backup "
1595
 
                "in future.)")
 
1645
            note(gettext("(The --force option is deprecated, rather use --no-backup "
 
1646
                "in future.)"))
1596
1647
            file_deletion_strategy = 'no-backup'
1597
1648
 
1598
1649
        tree, file_list = WorkingTree.open_containing_paths(file_list)
1608
1659
                specific_files=file_list).added
1609
1660
            file_list = sorted([f[0] for f in added], reverse=True)
1610
1661
            if len(file_list) == 0:
1611
 
                raise errors.BzrCommandError('No matching files.')
 
1662
                raise errors.BzrCommandError(gettext('No matching files.'))
1612
1663
        elif file_list is None:
1613
1664
            # missing files show up in iter_changes(basis) as
1614
1665
            # versioned-with-no-kind.
1737
1788
            b = wt.branch
1738
1789
            last_revision = wt.last_revision()
1739
1790
 
1740
 
        revision_ids = b.repository.get_ancestry(last_revision)
1741
 
        revision_ids.pop(0)
1742
 
        for revision_id in revision_ids:
 
1791
        self.add_cleanup(b.repository.lock_read().unlock)
 
1792
        graph = b.repository.get_graph()
 
1793
        revisions = [revid for revid, parents in
 
1794
            graph.iter_ancestry([last_revision])]
 
1795
        for revision_id in reversed(revisions):
 
1796
            if _mod_revision.is_null(revision_id):
 
1797
                continue
1743
1798
            self.outf.write(revision_id + '\n')
1744
1799
 
1745
1800
 
1804
1859
            to_transport.ensure_base()
1805
1860
        except errors.NoSuchFile:
1806
1861
            if not create_prefix:
1807
 
                raise errors.BzrCommandError("Parent directory of %s"
 
1862
                raise errors.BzrCommandError(gettext("Parent directory of %s"
1808
1863
                    " does not exist."
1809
1864
                    "\nYou may supply --create-prefix to create all"
1810
 
                    " leading parent directories."
 
1865
                    " leading parent directories.")
1811
1866
                    % location)
1812
1867
            to_transport.create_prefix()
1813
1868
 
1838
1893
            try:
1839
1894
                branch.set_append_revisions_only(True)
1840
1895
            except errors.UpgradeRequired:
1841
 
                raise errors.BzrCommandError('This branch format cannot be set'
1842
 
                    ' to append-revisions-only.  Try --default.')
 
1896
                raise errors.BzrCommandError(gettext('This branch format cannot be set'
 
1897
                    ' to append-revisions-only.  Try --default.'))
1843
1898
        if not is_quiet():
1844
1899
            from bzrlib.info import describe_layout, describe_format
1845
1900
            try:
1849
1904
            repository = branch.repository
1850
1905
            layout = describe_layout(repository, branch, tree).lower()
1851
1906
            format = describe_format(a_bzrdir, repository, branch, tree)
1852
 
            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))
1853
1909
            if repository.is_shared():
1854
1910
                #XXX: maybe this can be refactored into transport.path_or_url()
1855
1911
                url = repository.bzrdir.root_transport.external_url()
1857
1913
                    url = urlutils.local_path_from_url(url)
1858
1914
                except errors.InvalidURL:
1859
1915
                    pass
1860
 
                self.outf.write("Using shared repository: %s\n" % url)
 
1916
                self.outf.write(gettext("Using shared repository: %s\n") % url)
1861
1917
 
1862
1918
 
1863
1919
class cmd_init_repository(Command):
2054
2110
        elif ':' in prefix:
2055
2111
            old_label, new_label = prefix.split(":")
2056
2112
        else:
2057
 
            raise errors.BzrCommandError(
 
2113
            raise errors.BzrCommandError(gettext(
2058
2114
                '--prefix expects two values separated by a colon'
2059
 
                ' (eg "old/:new/")')
 
2115
                ' (eg "old/:new/")'))
2060
2116
 
2061
2117
        if revision and len(revision) > 2:
2062
 
            raise errors.BzrCommandError('bzr diff --revision takes exactly'
2063
 
                                         ' one or two revision specifiers')
 
2118
            raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
 
2119
                                         ' one or two revision specifiers'))
2064
2120
 
2065
2121
        if using is not None and format is not None:
2066
 
            raise errors.BzrCommandError('--using and --format are mutually '
2067
 
                'exclusive.')
 
2122
            raise errors.BzrCommandError(gettext(
 
2123
                '{0} and {1} are mutually exclusive').format(
 
2124
                '--using', '--format'))
2068
2125
 
2069
2126
        (old_tree, new_tree,
2070
2127
         old_branch, new_branch,
2147
2204
        basis_inv = basis.inventory
2148
2205
        inv = wt.inventory
2149
2206
        for file_id in inv:
2150
 
            if file_id in basis_inv:
 
2207
            if basis_inv.has_id(file_id):
2151
2208
                continue
2152
2209
            if inv.is_root(file_id) and len(basis_inv) == 0:
2153
2210
                continue
2178
2235
    try:
2179
2236
        return int(limitstring)
2180
2237
    except ValueError:
2181
 
        msg = "The limit argument must be an integer."
 
2238
        msg = gettext("The limit argument must be an integer.")
2182
2239
        raise errors.BzrCommandError(msg)
2183
2240
 
2184
2241
 
2186
2243
    try:
2187
2244
        return int(s)
2188
2245
    except ValueError:
2189
 
        msg = "The levels argument must be an integer."
 
2246
        msg = gettext("The levels argument must be an integer.")
2190
2247
        raise errors.BzrCommandError(msg)
2191
2248
 
2192
2249
 
2302
2359
 
2303
2360
    :Other filtering:
2304
2361
 
2305
 
      The --message option can be used for finding revisions that match a
2306
 
      regular expression in a commit message.
 
2362
      The --match option can be used for finding revisions that match a
 
2363
      regular expression in a commit message, committer, author or bug.
 
2364
      Specifying the option several times will match any of the supplied
 
2365
      expressions. --match-author, --match-bugs, --match-committer and
 
2366
      --match-message can be used to only match a specific field.
2307
2367
 
2308
2368
    :Tips & tricks:
2309
2369
 
2369
2429
                   argname='N',
2370
2430
                   type=_parse_levels),
2371
2431
            Option('message',
2372
 
                   short_name='m',
2373
2432
                   help='Show revisions whose message matches this '
2374
2433
                        'regular expression.',
2375
 
                   type=str),
 
2434
                   type=str,
 
2435
                   hidden=True),
2376
2436
            Option('limit',
2377
2437
                   short_name='l',
2378
2438
                   help='Limit the output to the first N revisions.',
2381
2441
            Option('show-diff',
2382
2442
                   short_name='p',
2383
2443
                   help='Show changes made in each revision as a patch.'),
2384
 
            Option('include-merges',
 
2444
            Option('include-merged',
2385
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.'),
2386
2450
            Option('exclude-common-ancestry',
2387
2451
                   help='Display only the revisions that are not part'
2388
2452
                   ' of both ancestries (require -rX..Y)'
2389
 
                   )
 
2453
                   ),
 
2454
            Option('signatures',
 
2455
                   help='Show digital signature validity'),
 
2456
            ListOption('match',
 
2457
                short_name='m',
 
2458
                help='Show revisions whose properties match this '
 
2459
                'expression.',
 
2460
                type=str),
 
2461
            ListOption('match-message',
 
2462
                   help='Show revisions whose message matches this '
 
2463
                   'expression.',
 
2464
                type=str),
 
2465
            ListOption('match-committer',
 
2466
                   help='Show revisions whose committer matches this '
 
2467
                   'expression.',
 
2468
                type=str),
 
2469
            ListOption('match-author',
 
2470
                   help='Show revisions whose authors match this '
 
2471
                   'expression.',
 
2472
                type=str),
 
2473
            ListOption('match-bugs',
 
2474
                   help='Show revisions whose bugs match this '
 
2475
                   'expression.',
 
2476
                type=str)
2390
2477
            ]
2391
2478
    encoding_type = 'replace'
2392
2479
 
2402
2489
            message=None,
2403
2490
            limit=None,
2404
2491
            show_diff=False,
2405
 
            include_merges=False,
 
2492
            include_merged=None,
2406
2493
            authors=None,
2407
2494
            exclude_common_ancestry=False,
 
2495
            signatures=False,
 
2496
            match=None,
 
2497
            match_message=None,
 
2498
            match_committer=None,
 
2499
            match_author=None,
 
2500
            match_bugs=None,
 
2501
            omit_merges=False,
 
2502
            include_merges=symbol_versioning.DEPRECATED_PARAMETER,
2408
2503
            ):
2409
2504
        from bzrlib.log import (
2410
2505
            Logger,
2412
2507
            _get_info_for_log_files,
2413
2508
            )
2414
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
2415
2525
        if (exclude_common_ancestry
2416
2526
            and (revision is None or len(revision) != 2)):
2417
 
            raise errors.BzrCommandError(
2418
 
                '--exclude-common-ancestry requires -r with two revisions')
2419
 
        if include_merges:
 
2527
            raise errors.BzrCommandError(gettext(
 
2528
                '--exclude-common-ancestry requires -r with two revisions'))
 
2529
        if include_merged:
2420
2530
            if levels is None:
2421
2531
                levels = 0
2422
2532
            else:
2423
 
                raise errors.BzrCommandError(
2424
 
                    '--levels and --include-merges are mutually exclusive')
 
2533
                raise errors.BzrCommandError(gettext(
 
2534
                    '{0} and {1} are mutually exclusive').format(
 
2535
                    '--levels', '--include-merged'))
2425
2536
 
2426
2537
        if change is not None:
2427
2538
            if len(change) > 1:
2428
2539
                raise errors.RangeInChangeOption()
2429
2540
            if revision is not None:
2430
 
                raise errors.BzrCommandError(
2431
 
                    '--revision and --change are mutually exclusive')
 
2541
                raise errors.BzrCommandError(gettext(
 
2542
                    '{0} and {1} are mutually exclusive').format(
 
2543
                    '--revision', '--change'))
2432
2544
            else:
2433
2545
                revision = change
2434
2546
 
2440
2552
                revision, file_list, self.add_cleanup)
2441
2553
            for relpath, file_id, kind in file_info_list:
2442
2554
                if file_id is None:
2443
 
                    raise errors.BzrCommandError(
2444
 
                        "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") %
2445
2557
                        relpath)
2446
2558
                # If the relpath is the top of the tree, we log everything
2447
2559
                if relpath == '':
2464
2576
            self.add_cleanup(b.lock_read().unlock)
2465
2577
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2466
2578
 
 
2579
        if b.get_config().validate_signatures_in_log():
 
2580
            signatures = True
 
2581
 
 
2582
        if signatures:
 
2583
            if not gpg.GPGStrategy.verify_signatures_available():
 
2584
                raise errors.GpgmeNotInstalled(None)
 
2585
 
2467
2586
        # Decide on the type of delta & diff filtering to use
2468
2587
        # TODO: add an --all-files option to make this configurable & consistent
2469
2588
        if not verbose:
2506
2625
        match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2507
2626
            or delta_type or partial_history)
2508
2627
 
 
2628
        match_dict = {}
 
2629
        if match:
 
2630
            match_dict[''] = match
 
2631
        if match_message:
 
2632
            match_dict['message'] = match_message
 
2633
        if match_committer:
 
2634
            match_dict['committer'] = match_committer
 
2635
        if match_author:
 
2636
            match_dict['author'] = match_author
 
2637
        if match_bugs:
 
2638
            match_dict['bugs'] = match_bugs
 
2639
 
2509
2640
        # Build the LogRequest and execute it
2510
2641
        if len(file_ids) == 0:
2511
2642
            file_ids = None
2514
2645
            start_revision=rev1, end_revision=rev2, limit=limit,
2515
2646
            message_search=message, delta_type=delta_type,
2516
2647
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2517
 
            exclude_common_ancestry=exclude_common_ancestry,
 
2648
            exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
 
2649
            signature=signatures, omit_merges=omit_merges,
2518
2650
            )
2519
2651
        Logger(b, rqst).show(lf)
2520
2652
 
2537
2669
            # b is taken from revision[0].get_branch(), and
2538
2670
            # show_log will use its revision_history. Having
2539
2671
            # different branches will lead to weird behaviors.
2540
 
            raise errors.BzrCommandError(
 
2672
            raise errors.BzrCommandError(gettext(
2541
2673
                "bzr %s doesn't accept two revisions in different"
2542
 
                " branches." % command_name)
 
2674
                " branches.") % command_name)
2543
2675
        if start_spec.spec is None:
2544
2676
            # Avoid loading all the history.
2545
2677
            rev1 = RevisionInfo(branch, None, None)
2553
2685
        else:
2554
2686
            rev2 = end_spec.in_history(branch)
2555
2687
    else:
2556
 
        raise errors.BzrCommandError(
2557
 
            '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)
2558
2690
    return rev1, rev2
2559
2691
 
2560
2692
 
2631
2763
            null=False, kind=None, show_ids=False, path=None, directory=None):
2632
2764
 
2633
2765
        if kind and kind not in ('file', 'directory', 'symlink'):
2634
 
            raise errors.BzrCommandError('invalid kind specified')
 
2766
            raise errors.BzrCommandError(gettext('invalid kind specified'))
2635
2767
 
2636
2768
        if verbose and null:
2637
 
            raise errors.BzrCommandError('Cannot set both --verbose and --null')
 
2769
            raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2638
2770
        all = not (unknown or versioned or ignored)
2639
2771
 
2640
2772
        selection = {'I':ignored, '?':unknown, 'V':versioned}
2643
2775
            fs_path = '.'
2644
2776
        else:
2645
2777
            if from_root:
2646
 
                raise errors.BzrCommandError('cannot specify both --from-root'
2647
 
                                             ' and PATH')
 
2778
                raise errors.BzrCommandError(gettext('cannot specify both --from-root'
 
2779
                                             ' and PATH'))
2648
2780
            fs_path = path
2649
2781
        tree, branch, relpath = \
2650
2782
            _open_directory_or_containing_tree_or_branch(fs_path, directory)
2666
2798
            if view_files:
2667
2799
                apply_view = True
2668
2800
                view_str = views.view_display_str(view_files)
2669
 
                note("Ignoring files outside view. View is %s" % view_str)
 
2801
                note(gettext("Ignoring files outside view. View is %s") % view_str)
2670
2802
 
2671
2803
        self.add_cleanup(tree.lock_read().unlock)
2672
2804
        for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2819
2951
                self.outf.write("%s\n" % pattern)
2820
2952
            return
2821
2953
        if not name_pattern_list:
2822
 
            raise errors.BzrCommandError("ignore requires at least one "
2823
 
                "NAME_PATTERN or --default-rules.")
 
2954
            raise errors.BzrCommandError(gettext("ignore requires at least one "
 
2955
                "NAME_PATTERN or --default-rules."))
2824
2956
        name_pattern_list = [globbing.normalize_pattern(p)
2825
2957
                             for p in name_pattern_list]
2826
2958
        bad_patterns = ''
 
2959
        bad_patterns_count = 0
2827
2960
        for p in name_pattern_list:
2828
2961
            if not globbing.Globster.is_pattern_valid(p):
 
2962
                bad_patterns_count += 1
2829
2963
                bad_patterns += ('\n  %s' % p)
2830
2964
        if bad_patterns:
2831
 
            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)
2832
2968
            ui.ui_factory.show_error(msg)
2833
2969
            raise errors.InvalidPattern('')
2834
2970
        for name_pattern in name_pattern_list:
2835
2971
            if (name_pattern[0] == '/' or
2836
2972
                (len(name_pattern) > 1 and name_pattern[1] == ':')):
2837
 
                raise errors.BzrCommandError(
2838
 
                    "NAME_PATTERN should not be an absolute path")
 
2973
                raise errors.BzrCommandError(gettext(
 
2974
                    "NAME_PATTERN should not be an absolute path"))
2839
2975
        tree, relpath = WorkingTree.open_containing(directory)
2840
2976
        ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2841
2977
        ignored = globbing.Globster(name_pattern_list)
2848
2984
                if ignored.match(filename):
2849
2985
                    matches.append(filename)
2850
2986
        if len(matches) > 0:
2851
 
            self.outf.write("Warning: the following files are version controlled and"
2852
 
                  " 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"
2853
2989
                  "\nThese files will continue to be version controlled"
2854
 
                  " unless you 'bzr remove' them.\n" % ("\n".join(matches),))
 
2990
                  " unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2855
2991
 
2856
2992
 
2857
2993
class cmd_ignored(Command):
2896
3032
        try:
2897
3033
            revno = int(revno)
2898
3034
        except ValueError:
2899
 
            raise errors.BzrCommandError("not a valid revision-number: %r"
 
3035
            raise errors.BzrCommandError(gettext("not a valid revision-number: %r")
2900
3036
                                         % revno)
2901
3037
        revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
2902
3038
        self.outf.write("%s\n" % revid)
2963
3099
            export(rev_tree, dest, format, root, subdir, filtered=filters,
2964
3100
                   per_file_timestamps=per_file_timestamps)
2965
3101
        except errors.NoSuchExportFormat, e:
2966
 
            raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
 
3102
            raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
2967
3103
 
2968
3104
 
2969
3105
class cmd_cat(Command):
2989
3125
    def run(self, filename, revision=None, name_from_revision=False,
2990
3126
            filters=False, directory=None):
2991
3127
        if revision is not None and len(revision) != 1:
2992
 
            raise errors.BzrCommandError("bzr cat --revision takes exactly"
2993
 
                                         " one revision specifier")
 
3128
            raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
 
3129
                                         " one revision specifier"))
2994
3130
        tree, branch, relpath = \
2995
3131
            _open_directory_or_containing_tree_or_branch(filename, directory)
2996
3132
        self.add_cleanup(branch.lock_read().unlock)
3006
3142
 
3007
3143
        old_file_id = rev_tree.path2id(relpath)
3008
3144
 
 
3145
        # TODO: Split out this code to something that generically finds the
 
3146
        # best id for a path across one or more trees; it's like
 
3147
        # find_ids_across_trees but restricted to find just one. -- mbp
 
3148
        # 20110705.
3009
3149
        if name_from_revision:
3010
3150
            # Try in revision if requested
3011
3151
            if old_file_id is None:
3012
 
                raise errors.BzrCommandError(
3013
 
                    "%r is not present in revision %s" % (
 
3152
                raise errors.BzrCommandError(gettext(
 
3153
                    "{0!r} is not present in revision {1}").format(
3014
3154
                        filename, rev_tree.get_revision_id()))
3015
3155
            else:
3016
 
                content = rev_tree.get_file_text(old_file_id)
 
3156
                actual_file_id = old_file_id
3017
3157
        else:
3018
3158
            cur_file_id = tree.path2id(relpath)
3019
 
            found = False
3020
 
            if cur_file_id is not None:
3021
 
                # Then try with the actual file id
3022
 
                try:
3023
 
                    content = rev_tree.get_file_text(cur_file_id)
3024
 
                    found = True
3025
 
                except errors.NoSuchId:
3026
 
                    # The actual file id didn't exist at that time
3027
 
                    pass
3028
 
            if not found and old_file_id is not None:
3029
 
                # Finally try with the old file id
3030
 
                content = rev_tree.get_file_text(old_file_id)
3031
 
                found = True
3032
 
            if not found:
3033
 
                # Can't be found anywhere
3034
 
                raise errors.BzrCommandError(
3035
 
                    "%r is not present in revision %s" % (
 
3159
            if cur_file_id is not None and rev_tree.has_id(cur_file_id):
 
3160
                actual_file_id = cur_file_id
 
3161
            elif old_file_id is not None:
 
3162
                actual_file_id = old_file_id
 
3163
            else:
 
3164
                raise errors.BzrCommandError(gettext(
 
3165
                    "{0!r} is not present in revision {1}").format(
3036
3166
                        filename, rev_tree.get_revision_id()))
3037
3167
        if filtered:
3038
 
            from bzrlib.filters import (
3039
 
                ContentFilterContext,
3040
 
                filtered_output_bytes,
3041
 
                )
3042
 
            filters = rev_tree._content_filter_stack(relpath)
3043
 
            chunks = content.splitlines(True)
3044
 
            content = filtered_output_bytes(chunks, filters,
3045
 
                ContentFilterContext(relpath, rev_tree))
3046
 
            self.cleanup_now()
3047
 
            self.outf.writelines(content)
 
3168
            from bzrlib.filter_tree import ContentFilterTree
 
3169
            filter_tree = ContentFilterTree(rev_tree,
 
3170
                rev_tree._content_filter_stack)
 
3171
            content = filter_tree.get_file_text(actual_file_id)
3048
3172
        else:
3049
 
            self.cleanup_now()
3050
 
            self.outf.write(content)
 
3173
            content = rev_tree.get_file_text(actual_file_id)
 
3174
        self.cleanup_now()
 
3175
        self.outf.write(content)
3051
3176
 
3052
3177
 
3053
3178
class cmd_local_time_offset(Command):
3160
3285
    aliases = ['ci', 'checkin']
3161
3286
 
3162
3287
    def _iter_bug_fix_urls(self, fixes, branch):
 
3288
        default_bugtracker  = None
3163
3289
        # Configure the properties for bug fixing attributes.
3164
3290
        for fixed_bug in fixes:
3165
3291
            tokens = fixed_bug.split(':')
3166
 
            if len(tokens) != 2:
3167
 
                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(
3168
3308
                    "Invalid bug %s. Must be in the form of 'tracker:id'. "
3169
3309
                    "See \"bzr help bugs\" for more information on this "
3170
 
                    "feature.\nCommit refused." % fixed_bug)
3171
 
            tag, bug_id = tokens
 
3310
                    "feature.\nCommit refused.") % fixed_bug)
 
3311
            else:
 
3312
                tag, bug_id = tokens
3172
3313
            try:
3173
3314
                yield bugtracker.get_bug_url(tag, branch, bug_id)
3174
3315
            except errors.UnknownBugTrackerAbbreviation:
3175
 
                raise errors.BzrCommandError(
3176
 
                    'Unrecognized bug %s. Commit refused.' % fixed_bug)
 
3316
                raise errors.BzrCommandError(gettext(
 
3317
                    'Unrecognized bug %s. Commit refused.') % fixed_bug)
3177
3318
            except errors.MalformedBugIdentifier, e:
3178
 
                raise errors.BzrCommandError(
3179
 
                    "%s\nCommit refused." % (str(e),))
 
3319
                raise errors.BzrCommandError(gettext(
 
3320
                    "%s\nCommit refused.") % (str(e),))
3180
3321
 
3181
3322
    def run(self, message=None, file=None, verbose=False, selected_list=None,
3182
3323
            unchanged=False, strict=False, local=False, fixes=None,
3190
3331
        from bzrlib.msgeditor import (
3191
3332
            edit_commit_message_encoded,
3192
3333
            generate_commit_message_template,
3193
 
            make_commit_message_template_encoded
 
3334
            make_commit_message_template_encoded,
 
3335
            set_commit_message,
3194
3336
        )
3195
3337
 
3196
3338
        commit_stamp = offset = None
3198
3340
            try:
3199
3341
                commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3200
3342
            except ValueError, e:
3201
 
                raise errors.BzrCommandError(
3202
 
                    "Could not parse --commit-time: " + str(e))
 
3343
                raise errors.BzrCommandError(gettext(
 
3344
                    "Could not parse --commit-time: " + str(e)))
3203
3345
 
3204
3346
        properties = {}
3205
3347
 
3238
3380
                message = message.replace('\r\n', '\n')
3239
3381
                message = message.replace('\r', '\n')
3240
3382
            if file:
3241
 
                raise errors.BzrCommandError(
3242
 
                    "please specify either --message or --file")
 
3383
                raise errors.BzrCommandError(gettext(
 
3384
                    "please specify either --message or --file"))
3243
3385
 
3244
3386
        def get_message(commit_obj):
3245
3387
            """Callback to get commit message"""
3262
3404
                # make_commit_message_template_encoded returns user encoding.
3263
3405
                # We probably want to be using edit_commit_message instead to
3264
3406
                # avoid this.
3265
 
                start_message = generate_commit_message_template(commit_obj)
3266
 
                my_message = edit_commit_message_encoded(text,
3267
 
                    start_message=start_message)
3268
 
                if my_message is None:
3269
 
                    raise errors.BzrCommandError("please specify a commit"
3270
 
                        " message with either --message or --file")
3271
 
            if my_message == "":
3272
 
                raise errors.BzrCommandError("empty commit message specified")
 
3407
                my_message = set_commit_message(commit_obj)
 
3408
                if my_message is None:
 
3409
                    start_message = generate_commit_message_template(commit_obj)
 
3410
                    my_message = edit_commit_message_encoded(text,
 
3411
                        start_message=start_message)
 
3412
                if my_message is None:
 
3413
                    raise errors.BzrCommandError(gettext("please specify a commit"
 
3414
                        " message with either --message or --file"))
 
3415
                if my_message == "":
 
3416
                    raise errors.BzrCommandError(gettext("Empty commit message specified."
 
3417
                            " Please specify a commit message with either"
 
3418
                            " --message or --file or leave a blank message"
 
3419
                            " with --message \"\"."))
3273
3420
            return my_message
3274
3421
 
3275
3422
        # The API permits a commit with a filter of [] to mean 'select nothing'
3286
3433
                        exclude=tree.safe_relpath_files(exclude),
3287
3434
                        lossy=lossy)
3288
3435
        except PointlessCommit:
3289
 
            raise errors.BzrCommandError("No changes to commit."
 
3436
            raise errors.BzrCommandError(gettext("No changes to commit."
3290
3437
                " Please 'bzr add' the files you want to commit, or use"
3291
 
                " --unchanged to force an empty commit.")
 
3438
                " --unchanged to force an empty commit."))
3292
3439
        except ConflictsInTree:
3293
 
            raise errors.BzrCommandError('Conflicts detected in working '
 
3440
            raise errors.BzrCommandError(gettext('Conflicts detected in working '
3294
3441
                'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
3295
 
                ' resolve.')
 
3442
                ' resolve.'))
3296
3443
        except StrictCommitFailed:
3297
 
            raise errors.BzrCommandError("Commit refused because there are"
3298
 
                              " unknown files in the working tree.")
 
3444
            raise errors.BzrCommandError(gettext("Commit refused because there are"
 
3445
                              " unknown files in the working tree."))
3299
3446
        except errors.BoundBranchOutOfDate, e:
3300
 
            e.extra_help = ("\n"
 
3447
            e.extra_help = (gettext("\n"
3301
3448
                'To commit to master branch, run update and then commit.\n'
3302
3449
                'You can also pass --local to commit to continue working '
3303
 
                'disconnected.')
 
3450
                'disconnected.'))
3304
3451
            raise
3305
3452
 
3306
3453
 
3473
3620
            return
3474
3621
 
3475
3622
        if email:
3476
 
            raise errors.BzrCommandError("--email can only be used to display existing "
3477
 
                                         "identity")
 
3623
            raise errors.BzrCommandError(gettext("--email can only be used to display existing "
 
3624
                                         "identity"))
3478
3625
 
3479
3626
        # display a warning if an email address isn't included in the given name.
3480
3627
        try:
3559
3706
 
3560
3707
    def remove_alias(self, alias_name):
3561
3708
        if alias_name is None:
3562
 
            raise errors.BzrCommandError(
3563
 
                'bzr alias --remove expects an alias to remove.')
 
3709
            raise errors.BzrCommandError(gettext(
 
3710
                'bzr alias --remove expects an alias to remove.'))
3564
3711
        # If alias is not found, print something like:
3565
3712
        # unalias: foo: not found
3566
3713
        c = _mod_config.GlobalConfig()
3645
3792
        if typestring == "sftp":
3646
3793
            from bzrlib.tests import stub_sftp
3647
3794
            return stub_sftp.SFTPAbsoluteServer
3648
 
        if typestring == "memory":
 
3795
        elif typestring == "memory":
3649
3796
            from bzrlib.tests import test_server
3650
3797
            return memory.MemoryServer
3651
 
        if typestring == "fakenfs":
 
3798
        elif typestring == "fakenfs":
3652
3799
            from bzrlib.tests import test_server
3653
3800
            return test_server.FakeNFSServer
3654
3801
        msg = "No known transport type %s. Supported types are: sftp\n" %\
3688
3835
                     Option('randomize', type=str, argname="SEED",
3689
3836
                            help='Randomize the order of tests using the given'
3690
3837
                                 ' seed or "now" for the current time.'),
3691
 
                     Option('exclude', type=str, argname="PATTERN",
3692
 
                            short_name='x',
3693
 
                            help='Exclude tests that match this regular'
3694
 
                                 ' expression.'),
 
3838
                     ListOption('exclude', type=str, argname="PATTERN",
 
3839
                                short_name='x',
 
3840
                                help='Exclude tests that match this regular'
 
3841
                                ' expression.'),
3695
3842
                     Option('subunit',
3696
3843
                        help='Output test progress via subunit.'),
3697
3844
                     Option('strict', help='Fail on missing dependencies or '
3704
3851
                                param_name='starting_with', short_name='s',
3705
3852
                                help=
3706
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.")
3707
3857
                     ]
3708
3858
    encoding_type = 'replace'
3709
3859
 
3717
3867
            first=False, list_only=False,
3718
3868
            randomize=None, exclude=None, strict=False,
3719
3869
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3720
 
            parallel=None, lsprof_tests=False):
 
3870
            parallel=None, lsprof_tests=False,
 
3871
            sync=False):
3721
3872
        from bzrlib import tests
3722
3873
 
3723
3874
        if testspecs_list is not None:
3728
3879
            try:
3729
3880
                from bzrlib.tests import SubUnitBzrRunner
3730
3881
            except ImportError:
3731
 
                raise errors.BzrCommandError("subunit not available. subunit "
3732
 
                    "needs to be installed to use --subunit.")
 
3882
                raise errors.BzrCommandError(gettext("subunit not available. subunit "
 
3883
                    "needs to be installed to use --subunit."))
3733
3884
            self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3734
3885
            # On Windows, disable automatic conversion of '\n' to '\r\n' in
3735
3886
            # stdout, which would corrupt the subunit stream. 
3744
3895
            self.additional_selftest_args.setdefault(
3745
3896
                'suite_decorators', []).append(parallel)
3746
3897
        if benchmark:
3747
 
            raise errors.BzrCommandError(
 
3898
            raise errors.BzrCommandError(gettext(
3748
3899
                "--benchmark is no longer supported from bzr 2.2; "
3749
 
                "use bzr-usertest instead")
 
3900
                "use bzr-usertest instead"))
3750
3901
        test_suite_factory = None
 
3902
        if not exclude:
 
3903
            exclude_pattern = None
 
3904
        else:
 
3905
            exclude_pattern = '(' + '|'.join(exclude) + ')'
 
3906
        if not sync:
 
3907
            self._disable_fsync()
3751
3908
        selftest_kwargs = {"verbose": verbose,
3752
3909
                          "pattern": pattern,
3753
3910
                          "stop_on_failure": one,
3758
3915
                          "matching_tests_first": first,
3759
3916
                          "list_only": list_only,
3760
3917
                          "random_seed": randomize,
3761
 
                          "exclude_pattern": exclude,
 
3918
                          "exclude_pattern": exclude_pattern,
3762
3919
                          "strict": strict,
3763
3920
                          "load_list": load_list,
3764
3921
                          "debug_flags": debugflag,
3775
3932
            cleanup()
3776
3933
        return int(not result)
3777
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
 
3778
3944
 
3779
3945
class cmd_version(Command):
3780
3946
    __doc__ = """Show version of bzr."""
3800
3966
 
3801
3967
    @display_command
3802
3968
    def run(self):
3803
 
        self.outf.write("It sure does!\n")
 
3969
        self.outf.write(gettext("It sure does!\n"))
3804
3970
 
3805
3971
 
3806
3972
class cmd_find_merge_base(Command):
3824
3990
        graph = branch1.repository.get_graph(branch2.repository)
3825
3991
        base_rev_id = graph.find_unique_lca(last1, last2)
3826
3992
 
3827
 
        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)
3828
3994
 
3829
3995
 
3830
3996
class cmd_merge(Command):
3833
3999
    The source of the merge can be specified either in the form of a branch,
3834
4000
    or in the form of a path to a file containing a merge directive generated
3835
4001
    with bzr send. If neither is specified, the default is the upstream branch
3836
 
    or the branch most recently merged using --remember.
 
4002
    or the branch most recently merged using --remember.  The source of the
 
4003
    merge may also be specified in the form of a path to a file in another
 
4004
    branch:  in this case, only the modifications to that file are merged into
 
4005
    the current working tree.
3837
4006
 
3838
4007
    When merging from a branch, by default bzr will try to merge in all new
3839
4008
    work from the other branch, automatically determining an appropriate base
3846
4015
    through OTHER, excluding BASE but including OTHER, will be merged.  If this
3847
4016
    causes some revisions to be skipped, i.e. if the destination branch does
3848
4017
    not already contain revision BASE, such a merge is commonly referred to as
3849
 
    a "cherrypick".
 
4018
    a "cherrypick". Unlike a normal merge, Bazaar does not currently track
 
4019
    cherrypicks. The changes look like a normal commit, and the history of the
 
4020
    changes from the other branch is not stored in the commit.
3850
4021
 
3851
4022
    Revision numbers are always relative to the source branch.
3852
4023
 
3857
4028
 
3858
4029
    Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
3859
4030
 
3860
 
    If there is no default branch set, the first merge will set it. After
3861
 
    that, you can omit the branch to use the default.  To change the
3862
 
    default, use --remember. The value will only be saved if the remote
3863
 
    location can be accessed.
 
4031
    If there is no default branch set, the first merge will set it (use
 
4032
    --no-remember to avoid setting it). After that, you can omit the branch
 
4033
    to use the default.  To change the default, use --remember. The value will
 
4034
    only be saved if the remote location can be accessed.
3864
4035
 
3865
4036
    The results of the merge are placed into the destination working
3866
4037
    directory, where they can be reviewed (with bzr diff), tested, and then
3867
4038
    committed to record the result of the merge.
3868
4039
 
3869
4040
    merge refuses to run if there are any uncommitted changes, unless
3870
 
    --force is given. The --force option can also be used to create a
 
4041
    --force is given.  If --force is given, then the changes from the source 
 
4042
    will be merged with the current working tree, including any uncommitted
 
4043
    changes in the tree.  The --force option can also be used to create a
3871
4044
    merge revision which has more than two parents.
3872
4045
 
3873
4046
    If one would like to merge changes from the working tree of the other
3931
4104
    ]
3932
4105
 
3933
4106
    def run(self, location=None, revision=None, force=False,
3934
 
            merge_type=None, show_base=False, reprocess=None, remember=False,
 
4107
            merge_type=None, show_base=False, reprocess=None, remember=None,
3935
4108
            uncommitted=False, pull=False,
3936
4109
            directory=None,
3937
4110
            preview=False,
3945
4118
        merger = None
3946
4119
        allow_pending = True
3947
4120
        verified = 'inapplicable'
 
4121
 
3948
4122
        tree = WorkingTree.open_containing(directory)[0]
 
4123
        if tree.branch.revno() == 0:
 
4124
            raise errors.BzrCommandError(gettext('Merging into empty branches not currently supported, '
 
4125
                                         'https://bugs.launchpad.net/bzr/+bug/308562'))
3949
4126
 
3950
4127
        try:
3951
4128
            basis_tree = tree.revision_tree(tree.last_revision())
3971
4148
                mergeable = None
3972
4149
            else:
3973
4150
                if uncommitted:
3974
 
                    raise errors.BzrCommandError('Cannot use --uncommitted'
3975
 
                        ' with bundles or merge directives.')
 
4151
                    raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
 
4152
                        ' with bundles or merge directives.'))
3976
4153
 
3977
4154
                if revision is not None:
3978
 
                    raise errors.BzrCommandError(
3979
 
                        'Cannot use -r with merge directives or bundles')
 
4155
                    raise errors.BzrCommandError(gettext(
 
4156
                        'Cannot use -r with merge directives or bundles'))
3980
4157
                merger, verified = _mod_merge.Merger.from_mergeable(tree,
3981
4158
                   mergeable, None)
3982
4159
 
3983
4160
        if merger is None and uncommitted:
3984
4161
            if revision is not None and len(revision) > 0:
3985
 
                raise errors.BzrCommandError('Cannot use --uncommitted and'
3986
 
                    ' --revision at the same time.')
 
4162
                raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
 
4163
                    ' --revision at the same time.'))
3987
4164
            merger = self.get_merger_from_uncommitted(tree, location, None)
3988
4165
            allow_pending = False
3989
4166
 
3997
4174
        self.sanity_check_merger(merger)
3998
4175
        if (merger.base_rev_id == merger.other_rev_id and
3999
4176
            merger.other_rev_id is not None):
4000
 
            note('Nothing to do.')
 
4177
            # check if location is a nonexistent file (and not a branch) to
 
4178
            # disambiguate the 'Nothing to do'
 
4179
            if merger.interesting_files:
 
4180
                if not merger.other_tree.has_filename(
 
4181
                    merger.interesting_files[0]):
 
4182
                    note(gettext("merger: ") + str(merger))
 
4183
                    raise errors.PathsDoNotExist([location])
 
4184
            note(gettext('Nothing to do.'))
4001
4185
            return 0
4002
4186
        if pull and not preview:
4003
4187
            if merger.interesting_files is not None:
4004
 
                raise errors.BzrCommandError('Cannot pull individual files')
 
4188
                raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4005
4189
            if (merger.base_rev_id == tree.last_revision()):
4006
4190
                result = tree.pull(merger.other_branch, False,
4007
4191
                                   merger.other_rev_id)
4008
4192
                result.report(self.outf)
4009
4193
                return 0
4010
4194
        if merger.this_basis is None:
4011
 
            raise errors.BzrCommandError(
 
4195
            raise errors.BzrCommandError(gettext(
4012
4196
                "This branch has no commits."
4013
 
                " (perhaps you would prefer 'bzr pull')")
 
4197
                " (perhaps you would prefer 'bzr pull')"))
4014
4198
        if preview:
4015
4199
            return self._do_preview(merger)
4016
4200
        elif interactive:
4067
4251
    def sanity_check_merger(self, merger):
4068
4252
        if (merger.show_base and
4069
4253
            not merger.merge_type is _mod_merge.Merge3Merger):
4070
 
            raise errors.BzrCommandError("Show-base is not supported for this"
4071
 
                                         " 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)
4072
4256
        if merger.reprocess is None:
4073
4257
            if merger.show_base:
4074
4258
                merger.reprocess = False
4076
4260
                # Use reprocess if the merger supports it
4077
4261
                merger.reprocess = merger.merge_type.supports_reprocess
4078
4262
        if merger.reprocess and not merger.merge_type.supports_reprocess:
4079
 
            raise errors.BzrCommandError("Conflict reduction is not supported"
4080
 
                                         " for merge type %s." %
 
4263
            raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
 
4264
                                         " for merge type %s.") %
4081
4265
                                         merger.merge_type)
4082
4266
        if merger.reprocess and merger.show_base:
4083
 
            raise errors.BzrCommandError("Cannot do conflict reduction and"
4084
 
                                         " show base.")
 
4267
            raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
 
4268
                                         " show base."))
4085
4269
 
4086
4270
    def _get_merger_from_branch(self, tree, location, revision, remember,
4087
4271
                                possible_transports, pb):
4114
4298
        if other_revision_id is None:
4115
4299
            other_revision_id = _mod_revision.ensure_null(
4116
4300
                other_branch.last_revision())
4117
 
        # Remember where we merge from
4118
 
        if ((remember or tree.branch.get_submit_branch() is None) and
4119
 
             user_location is not None):
 
4301
        # Remember where we merge from. We need to remember if:
 
4302
        # - user specify a location (and we don't merge from the parent
 
4303
        #   branch)
 
4304
        # - user ask to remember or there is no previous location set to merge
 
4305
        #   from and user didn't ask to *not* remember
 
4306
        if (user_location is not None
 
4307
            and ((remember
 
4308
                  or (remember is None
 
4309
                      and tree.branch.get_submit_branch() is None)))):
4120
4310
            tree.branch.set_submit_branch(other_branch.base)
4121
4311
        # Merge tags (but don't set them in the master branch yet, the user
4122
4312
        # might revert this merge).  Commit will propagate them.
4185
4375
            stored_location_type = "parent"
4186
4376
        mutter("%s", stored_location)
4187
4377
        if stored_location is None:
4188
 
            raise errors.BzrCommandError("No location specified or remembered")
 
4378
            raise errors.BzrCommandError(gettext("No location specified or remembered"))
4189
4379
        display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4190
 
        note(u"%s remembered %s location %s", verb_string,
4191
 
                stored_location_type, display_url)
 
4380
        note(gettext("{0} remembered {1} location {2}").format(verb_string,
 
4381
                stored_location_type, display_url))
4192
4382
        return stored_location
4193
4383
 
4194
4384
 
4231
4421
        self.add_cleanup(tree.lock_write().unlock)
4232
4422
        parents = tree.get_parent_ids()
4233
4423
        if len(parents) != 2:
4234
 
            raise errors.BzrCommandError("Sorry, remerge only works after normal"
 
4424
            raise errors.BzrCommandError(gettext("Sorry, remerge only works after normal"
4235
4425
                                         " merges.  Not cherrypicking or"
4236
 
                                         " multi-merges.")
 
4426
                                         " multi-merges."))
4237
4427
        repository = tree.branch.repository
4238
4428
        interesting_ids = None
4239
4429
        new_conflicts = []
4458
4648
            type=_parse_revision_str,
4459
4649
            help='Filter on local branch revisions (inclusive). '
4460
4650
                'See "help revisionspec" for details.'),
4461
 
        Option('include-merges',
 
4651
        Option('include-merged',
4462
4652
               'Show all revisions in addition to the mainline ones.'),
 
4653
        Option('include-merges', hidden=True,
 
4654
               help='Historical alias for --include-merged.'),
4463
4655
        ]
4464
4656
    encoding_type = 'replace'
4465
4657
 
4468
4660
            theirs_only=False,
4469
4661
            log_format=None, long=False, short=False, line=False,
4470
4662
            show_ids=False, verbose=False, this=False, other=False,
4471
 
            include_merges=False, revision=None, my_revision=None,
4472
 
            directory=u'.'):
 
4663
            include_merged=None, revision=None, my_revision=None,
 
4664
            directory=u'.',
 
4665
            include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4473
4666
        from bzrlib.missing import find_unmerged, iter_log_revisions
4474
4667
        def message(s):
4475
4668
            if not is_quiet():
4476
4669
                self.outf.write(s)
4477
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
4478
4686
        if this:
4479
4687
            mine_only = this
4480
4688
        if other:
4495
4703
        if other_branch is None:
4496
4704
            other_branch = parent
4497
4705
            if other_branch is None:
4498
 
                raise errors.BzrCommandError("No peer location known"
4499
 
                                             " or specified.")
 
4706
                raise errors.BzrCommandError(gettext("No peer location known"
 
4707
                                             " or specified."))
4500
4708
            display_url = urlutils.unescape_for_display(parent,
4501
4709
                                                        self.outf.encoding)
4502
 
            message("Using saved parent location: "
4503
 
                    + display_url + "\n")
 
4710
            message(gettext("Using saved parent location: {0}\n").format(
 
4711
                    display_url))
4504
4712
 
4505
4713
        remote_branch = Branch.open(other_branch)
4506
4714
        if remote_branch.base == local_branch.base:
4519
4727
        local_extra, remote_extra = find_unmerged(
4520
4728
            local_branch, remote_branch, restrict,
4521
4729
            backward=not reverse,
4522
 
            include_merges=include_merges,
 
4730
            include_merged=include_merged,
4523
4731
            local_revid_range=local_revid_range,
4524
4732
            remote_revid_range=remote_revid_range)
4525
4733
 
4532
4740
 
4533
4741
        status_code = 0
4534
4742
        if local_extra and not theirs_only:
4535
 
            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)) %
4536
4746
                len(local_extra))
4537
4747
            for revision in iter_log_revisions(local_extra,
4538
4748
                                local_branch.repository,
4546
4756
        if remote_extra and not mine_only:
4547
4757
            if printed_local is True:
4548
4758
                message("\n\n\n")
4549
 
            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)) %
4550
4762
                len(remote_extra))
4551
4763
            for revision in iter_log_revisions(remote_extra,
4552
4764
                                remote_branch.repository,
4556
4768
 
4557
4769
        if mine_only and not local_extra:
4558
4770
            # We checked local, and found nothing extra
4559
 
            message('This branch is up to date.\n')
 
4771
            message(gettext('This branch has no new revisions.\n'))
4560
4772
        elif theirs_only and not remote_extra:
4561
4773
            # We checked remote, and found nothing extra
4562
 
            message('Other branch is up to date.\n')
 
4774
            message(gettext('Other branch has no new revisions.\n'))
4563
4775
        elif not (mine_only or theirs_only or local_extra or
4564
4776
                  remote_extra):
4565
4777
            # We checked both branches, and neither one had extra
4566
4778
            # revisions
4567
 
            message("Branches are up to date.\n")
 
4779
            message(gettext("Branches are up to date.\n"))
4568
4780
        self.cleanup_now()
4569
4781
        if not status_code and parent is None and other_branch is not None:
4570
4782
            self.add_cleanup(local_branch.lock_write().unlock)
4633
4845
    @display_command
4634
4846
    def run(self, verbose=False):
4635
4847
        from bzrlib import plugin
 
4848
        # Don't give writelines a generator as some codecs don't like that
4636
4849
        self.outf.writelines(
4637
 
            plugin.describe_plugins(show_paths=verbose))
 
4850
            list(plugin.describe_plugins(show_paths=verbose)))
4638
4851
 
4639
4852
 
4640
4853
class cmd_testament(Command):
4730
4943
 
4731
4944
    def run(self, revision_id_list=None, revision=None, directory=u'.'):
4732
4945
        if revision_id_list is not None and revision is not None:
4733
 
            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'))
4734
4947
        if revision_id_list is None and revision is None:
4735
 
            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'))
4736
4949
        b = WorkingTree.open_containing(directory)[0].branch
4737
4950
        self.add_cleanup(b.lock_write().unlock)
4738
4951
        return self._run(b, revision_id_list, revision)
4770
4983
                if to_revid is None:
4771
4984
                    to_revno = b.revno()
4772
4985
                if from_revno is None or to_revno is None:
4773
 
                    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'))
4774
4987
                b.repository.start_write_group()
4775
4988
                try:
4776
4989
                    for revno in range(from_revno, to_revno + 1):
4782
4995
                else:
4783
4996
                    b.repository.commit_write_group()
4784
4997
            else:
4785
 
                raise errors.BzrCommandError('Please supply either one revision, or a range.')
 
4998
                raise errors.BzrCommandError(gettext('Please supply either one revision, or a range.'))
4786
4999
 
4787
5000
 
4788
5001
class cmd_bind(Command):
4807
5020
            try:
4808
5021
                location = b.get_old_bound_location()
4809
5022
            except errors.UpgradeRequired:
4810
 
                raise errors.BzrCommandError('No location supplied.  '
4811
 
                    'This format does not remember old locations.')
 
5023
                raise errors.BzrCommandError(gettext('No location supplied.  '
 
5024
                    'This format does not remember old locations.'))
4812
5025
            else:
4813
5026
                if location is None:
4814
5027
                    if b.get_bound_location() is not None:
4815
 
                        raise errors.BzrCommandError('Branch is already bound')
 
5028
                        raise errors.BzrCommandError(gettext('Branch is already bound'))
4816
5029
                    else:
4817
 
                        raise errors.BzrCommandError('No location supplied '
4818
 
                            'and no previous location known')
 
5030
                        raise errors.BzrCommandError(gettext('No location supplied '
 
5031
                            'and no previous location known'))
4819
5032
        b_other = Branch.open(location)
4820
5033
        try:
4821
5034
            b.bind(b_other)
4822
5035
        except errors.DivergedBranches:
4823
 
            raise errors.BzrCommandError('These branches have diverged.'
4824
 
                                         ' Try merging, and then bind again.')
 
5036
            raise errors.BzrCommandError(gettext('These branches have diverged.'
 
5037
                                         ' Try merging, and then bind again.'))
4825
5038
        if b.get_config().has_explicit_nickname():
4826
5039
            b.nick = b_other.nick
4827
5040
 
4840
5053
    def run(self, directory=u'.'):
4841
5054
        b, relpath = Branch.open_containing(directory)
4842
5055
        if not b.unbind():
4843
 
            raise errors.BzrCommandError('Local branch is not bound')
 
5056
            raise errors.BzrCommandError(gettext('Local branch is not bound'))
4844
5057
 
4845
5058
 
4846
5059
class cmd_uncommit(Command):
4867
5080
    takes_options = ['verbose', 'revision',
4868
5081
                    Option('dry-run', help='Don\'t actually make changes.'),
4869
5082
                    Option('force', help='Say yes to all questions.'),
 
5083
                    Option('keep-tags',
 
5084
                           help='Keep tags that point to removed revisions.'),
4870
5085
                    Option('local',
4871
5086
                           help="Only remove the commits from the local branch"
4872
5087
                                " when in a checkout."
4876
5091
    aliases = []
4877
5092
    encoding_type = 'replace'
4878
5093
 
4879
 
    def run(self, location=None,
4880
 
            dry_run=False, verbose=False,
4881
 
            revision=None, force=False, local=False):
 
5094
    def run(self, location=None, dry_run=False, verbose=False,
 
5095
            revision=None, force=False, local=False, keep_tags=False):
4882
5096
        if location is None:
4883
5097
            location = u'.'
4884
5098
        control, relpath = bzrdir.BzrDir.open_containing(location)
4893
5107
            self.add_cleanup(tree.lock_write().unlock)
4894
5108
        else:
4895
5109
            self.add_cleanup(b.lock_write().unlock)
4896
 
        return self._run(b, tree, dry_run, verbose, revision, force, local=local)
 
5110
        return self._run(b, tree, dry_run, verbose, revision, force,
 
5111
                         local, keep_tags)
4897
5112
 
4898
 
    def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
 
5113
    def _run(self, b, tree, dry_run, verbose, revision, force, local,
 
5114
             keep_tags):
4899
5115
        from bzrlib.log import log_formatter, show_log
4900
5116
        from bzrlib.uncommit import uncommit
4901
5117
 
4916
5132
                rev_id = b.get_rev_id(revno)
4917
5133
 
4918
5134
        if rev_id is None or _mod_revision.is_null(rev_id):
4919
 
            self.outf.write('No revisions to uncommit.\n')
 
5135
            self.outf.write(gettext('No revisions to uncommit.\n'))
4920
5136
            return 1
4921
5137
 
4922
5138
        lf = log_formatter('short',
4931
5147
                 end_revision=last_revno)
4932
5148
 
4933
5149
        if dry_run:
4934
 
            self.outf.write('Dry-run, pretending to remove'
4935
 
                            ' the above revisions.\n')
 
5150
            self.outf.write(gettext('Dry-run, pretending to remove'
 
5151
                            ' the above revisions.\n'))
4936
5152
        else:
4937
 
            self.outf.write('The above revision(s) will be removed.\n')
 
5153
            self.outf.write(gettext('The above revision(s) will be removed.\n'))
4938
5154
 
4939
5155
        if not force:
4940
5156
            if not ui.ui_factory.confirm_action(
4941
 
                    'Uncommit these revisions',
 
5157
                    gettext(u'Uncommit these revisions'),
4942
5158
                    'bzrlib.builtins.uncommit',
4943
5159
                    {}):
4944
 
                self.outf.write('Canceled\n')
 
5160
                self.outf.write(gettext('Canceled\n'))
4945
5161
                return 0
4946
5162
 
4947
5163
        mutter('Uncommitting from {%s} to {%s}',
4948
5164
               last_rev_id, rev_id)
4949
5165
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
4950
 
                 revno=revno, local=local)
4951
 
        self.outf.write('You can restore the old tip by running:\n'
4952
 
             '  bzr pull . -r revid:%s\n' % last_rev_id)
 
5166
                 revno=revno, local=local, keep_tags=keep_tags)
 
5167
        self.outf.write(gettext('You can restore the old tip by running:\n'
 
5168
             '  bzr pull . -r revid:%s\n') % last_rev_id)
4953
5169
 
4954
5170
 
4955
5171
class cmd_break_lock(Command):
5101
5317
        containing_tree = WorkingTree.open_containing(parent_dir)[0]
5102
5318
        repo = containing_tree.branch.repository
5103
5319
        if not repo.supports_rich_root():
5104
 
            raise errors.BzrCommandError(
 
5320
            raise errors.BzrCommandError(gettext(
5105
5321
                "Can't join trees because %s doesn't support rich root data.\n"
5106
 
                "You can use bzr upgrade on the repository."
 
5322
                "You can use bzr upgrade on the repository.")
5107
5323
                % (repo,))
5108
5324
        if reference:
5109
5325
            try:
5111
5327
            except errors.BadReferenceTarget, e:
5112
5328
                # XXX: Would be better to just raise a nicely printable
5113
5329
                # exception from the real origin.  Also below.  mbp 20070306
5114
 
                raise errors.BzrCommandError("Cannot join %s.  %s" %
5115
 
                                             (tree, e.reason))
 
5330
                raise errors.BzrCommandError(
 
5331
                       gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5116
5332
        else:
5117
5333
            try:
5118
5334
                containing_tree.subsume(sub_tree)
5119
5335
            except errors.BadSubsumeSource, e:
5120
 
                raise errors.BzrCommandError("Cannot join %s.  %s" %
5121
 
                                             (tree, e.reason))
 
5336
                raise errors.BzrCommandError(
 
5337
                       gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5122
5338
 
5123
5339
 
5124
5340
class cmd_split(Command):
5208
5424
        if submit_branch is None:
5209
5425
            submit_branch = branch.get_parent()
5210
5426
        if submit_branch is None:
5211
 
            raise errors.BzrCommandError('No submit branch specified or known')
 
5427
            raise errors.BzrCommandError(gettext('No submit branch specified or known'))
5212
5428
 
5213
5429
        stored_public_branch = branch.get_public_branch()
5214
5430
        if public_branch is None:
5216
5432
        elif stored_public_branch is None:
5217
5433
            branch.set_public_branch(public_branch)
5218
5434
        if not include_bundle and public_branch is None:
5219
 
            raise errors.BzrCommandError('No public branch specified or'
5220
 
                                         ' known')
 
5435
            raise errors.BzrCommandError(gettext('No public branch specified or'
 
5436
                                         ' known'))
5221
5437
        base_revision_id = None
5222
5438
        if revision is not None:
5223
5439
            if len(revision) > 2:
5224
 
                raise errors.BzrCommandError('bzr merge-directive takes '
5225
 
                    'at most two one revision identifiers')
 
5440
                raise errors.BzrCommandError(gettext('bzr merge-directive takes '
 
5441
                    'at most two one revision identifiers'))
5226
5442
            revision_id = revision[-1].as_revision_id(branch)
5227
5443
            if len(revision) == 2:
5228
5444
                base_revision_id = revision[0].as_revision_id(branch)
5230
5446
            revision_id = branch.last_revision()
5231
5447
        revision_id = ensure_null(revision_id)
5232
5448
        if revision_id == NULL_REVISION:
5233
 
            raise errors.BzrCommandError('No revisions to bundle.')
 
5449
            raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5234
5450
        directive = merge_directive.MergeDirective2.from_objects(
5235
5451
            branch.repository, revision_id, time.time(),
5236
5452
            osutils.local_time_offset(), submit_branch,
5280
5496
    source branch defaults to that containing the working directory, but can
5281
5497
    be changed using --from.
5282
5498
 
 
5499
    Both the submit branch and the public branch follow the usual behavior with
 
5500
    respect to --remember: If there is no default location set, the first send
 
5501
    will set it (use --no-remember to avoid setting it). After that, you can
 
5502
    omit the location to use the default.  To change the default, use
 
5503
    --remember. The value will only be saved if the location can be accessed.
 
5504
 
5283
5505
    In order to calculate those changes, bzr must analyse the submit branch.
5284
5506
    Therefore it is most efficient for the submit branch to be a local mirror.
5285
5507
    If a public location is known for the submit_branch, that location is used
5354
5576
        ]
5355
5577
 
5356
5578
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
5357
 
            no_patch=False, revision=None, remember=False, output=None,
 
5579
            no_patch=False, revision=None, remember=None, output=None,
5358
5580
            format=None, mail_to=None, message=None, body=None,
5359
5581
            strict=None, **kwargs):
5360
5582
        from bzrlib.send import send
5484
5706
        self.add_cleanup(branch.lock_write().unlock)
5485
5707
        if delete:
5486
5708
            if tag_name is None:
5487
 
                raise errors.BzrCommandError("No tag specified to delete.")
 
5709
                raise errors.BzrCommandError(gettext("No tag specified to delete."))
5488
5710
            branch.tags.delete_tag(tag_name)
5489
 
            note('Deleted tag %s.' % tag_name)
 
5711
            note(gettext('Deleted tag %s.') % tag_name)
5490
5712
        else:
5491
5713
            if revision:
5492
5714
                if len(revision) != 1:
5493
 
                    raise errors.BzrCommandError(
 
5715
                    raise errors.BzrCommandError(gettext(
5494
5716
                        "Tags can only be placed on a single revision, "
5495
 
                        "not on a range")
 
5717
                        "not on a range"))
5496
5718
                revision_id = revision[0].as_revision_id(branch)
5497
5719
            else:
5498
5720
                revision_id = branch.last_revision()
5499
5721
            if tag_name is None:
5500
5722
                tag_name = branch.automatic_tag_name(revision_id)
5501
5723
                if tag_name is None:
5502
 
                    raise errors.BzrCommandError(
5503
 
                        "Please specify a tag name.")
5504
 
            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):
5505
5731
                raise errors.TagAlreadyExists(tag_name)
5506
 
            branch.tags.set_tag(tag_name, revision_id)
5507
 
            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)
5508
5740
 
5509
5741
 
5510
5742
class cmd_tags(Command):
5536
5768
 
5537
5769
        self.add_cleanup(branch.lock_read().unlock)
5538
5770
        if revision:
5539
 
            graph = branch.repository.get_graph()
5540
 
            rev1, rev2 = _get_revision_range(revision, branch, self.name())
5541
 
            revid1, revid2 = rev1.rev_id, rev2.rev_id
5542
 
            # only show revisions between revid1 and revid2 (inclusive)
5543
 
            tags = [(tag, revid) for tag, revid in tags if
5544
 
                graph.is_between(revid, revid1, revid2)]
 
5771
            # Restrict to the specified range
 
5772
            tags = self._tags_for_range(branch, revision)
5545
5773
        if sort is None:
5546
5774
            sort = tag_sort_methods.get()
5547
5775
        sort(branch, tags)
5552
5780
                    revno = branch.revision_id_to_dotted_revno(revid)
5553
5781
                    if isinstance(revno, tuple):
5554
5782
                        revno = '.'.join(map(str, revno))
5555
 
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
 
5783
                except (errors.NoSuchRevision,
 
5784
                        errors.GhostRevisionsHaveNoRevno):
5556
5785
                    # Bad tag data/merges can lead to tagged revisions
5557
5786
                    # which are not in this branch. Fail gracefully ...
5558
5787
                    revno = '?'
5561
5790
        for tag, revspec in tags:
5562
5791
            self.outf.write('%-20s %s\n' % (tag, revspec))
5563
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
 
5564
5819
 
5565
5820
class cmd_reconfigure(Command):
5566
5821
    __doc__ = """Reconfigure the type of a bzr directory.
5580
5835
    takes_args = ['location?']
5581
5836
    takes_options = [
5582
5837
        RegistryOption.from_kwargs(
5583
 
            'target_type',
5584
 
            title='Target type',
5585
 
            help='The type to reconfigure the directory to.',
 
5838
            'tree_type',
 
5839
            title='Tree type',
 
5840
            help='The relation between branch and tree.',
5586
5841
            value_switches=True, enum_switch=False,
5587
5842
            branch='Reconfigure to be an unbound branch with no working tree.',
5588
5843
            tree='Reconfigure to be an unbound branch with a working tree.',
5589
5844
            checkout='Reconfigure to be a bound branch with a working tree.',
5590
5845
            lightweight_checkout='Reconfigure to be a lightweight'
5591
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,
5592
5853
            standalone='Reconfigure to be a standalone branch '
5593
5854
                '(i.e. stop using shared repository).',
5594
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,
5595
5862
            with_trees='Reconfigure repository to create '
5596
5863
                'working trees on branches by default.',
5597
5864
            with_no_trees='Reconfigure repository to not create '
5611
5878
            ),
5612
5879
        ]
5613
5880
 
5614
 
    def run(self, location=None, target_type=None, bind_to=None, force=False,
5615
 
            stacked_on=None,
5616
 
            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):
5617
5884
        directory = bzrdir.BzrDir.open(location)
5618
5885
        if stacked_on and unstacked:
5619
 
            raise BzrCommandError("Can't use both --stacked-on and --unstacked")
 
5886
            raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5620
5887
        elif stacked_on is not None:
5621
5888
            reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5622
5889
        elif unstacked:
5624
5891
        # At the moment you can use --stacked-on and a different
5625
5892
        # reconfiguration shape at the same time; there seems no good reason
5626
5893
        # to ban it.
5627
 
        if target_type is None:
 
5894
        if (tree_type is None and
 
5895
            repository_type is None and
 
5896
            repository_trees is None):
5628
5897
            if stacked_on or unstacked:
5629
5898
                return
5630
5899
            else:
5631
 
                raise errors.BzrCommandError('No target configuration '
5632
 
                    'specified')
5633
 
        elif target_type == 'branch':
 
5900
                raise errors.BzrCommandError(gettext('No target configuration '
 
5901
                    'specified'))
 
5902
        reconfiguration = None
 
5903
        if tree_type == 'branch':
5634
5904
            reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5635
 
        elif target_type == 'tree':
 
5905
        elif tree_type == 'tree':
5636
5906
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5637
 
        elif target_type == 'checkout':
 
5907
        elif tree_type == 'checkout':
5638
5908
            reconfiguration = reconfigure.Reconfigure.to_checkout(
5639
5909
                directory, bind_to)
5640
 
        elif target_type == 'lightweight-checkout':
 
5910
        elif tree_type == 'lightweight-checkout':
5641
5911
            reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5642
5912
                directory, bind_to)
5643
 
        elif target_type == 'use-shared':
 
5913
        if reconfiguration:
 
5914
            reconfiguration.apply(force)
 
5915
            reconfiguration = None
 
5916
        if repository_type == 'use-shared':
5644
5917
            reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5645
 
        elif target_type == 'standalone':
 
5918
        elif repository_type == 'standalone':
5646
5919
            reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5647
 
        elif target_type == 'with-trees':
 
5920
        if reconfiguration:
 
5921
            reconfiguration.apply(force)
 
5922
            reconfiguration = None
 
5923
        if repository_trees == 'with-trees':
5648
5924
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5649
5925
                directory, True)
5650
 
        elif target_type == 'with-no-trees':
 
5926
        elif repository_trees == 'with-no-trees':
5651
5927
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5652
5928
                directory, False)
5653
 
        reconfiguration.apply(force)
 
5929
        if reconfiguration:
 
5930
            reconfiguration.apply(force)
 
5931
            reconfiguration = None
5654
5932
 
5655
5933
 
5656
5934
class cmd_switch(Command):
5694
5972
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
5695
5973
        if to_location is None:
5696
5974
            if revision is None:
5697
 
                raise errors.BzrCommandError('You must supply either a'
5698
 
                                             ' revision or a location')
 
5975
                raise errors.BzrCommandError(gettext('You must supply either a'
 
5976
                                             ' revision or a location'))
5699
5977
            to_location = tree_location
5700
5978
        try:
5701
5979
            branch = control_dir.open_branch()
5705
5983
            had_explicit_nick = False
5706
5984
        if create_branch:
5707
5985
            if branch is None:
5708
 
                raise errors.BzrCommandError('cannot create branch without'
5709
 
                                             ' source branch')
 
5986
                raise errors.BzrCommandError(gettext('cannot create branch without'
 
5987
                                             ' source branch'))
5710
5988
            to_location = directory_service.directories.dereference(
5711
5989
                              to_location)
5712
5990
            if '/' not in to_location and '\\' not in to_location:
5729
6007
        if had_explicit_nick:
5730
6008
            branch = control_dir.open_branch() #get the new branch!
5731
6009
            branch.nick = to_branch.nick
5732
 
        note('Switched to branch: %s',
 
6010
        note(gettext('Switched to branch: %s'),
5733
6011
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5734
6012
 
5735
6013
    def _get_branch_location(self, control_dir):
5844
6122
            name = current_view
5845
6123
        if delete:
5846
6124
            if file_list:
5847
 
                raise errors.BzrCommandError(
5848
 
                    "Both --delete and a file list specified")
 
6125
                raise errors.BzrCommandError(gettext(
 
6126
                    "Both --delete and a file list specified"))
5849
6127
            elif switch:
5850
 
                raise errors.BzrCommandError(
5851
 
                    "Both --delete and --switch specified")
 
6128
                raise errors.BzrCommandError(gettext(
 
6129
                    "Both --delete and --switch specified"))
5852
6130
            elif all:
5853
6131
                tree.views.set_view_info(None, {})
5854
 
                self.outf.write("Deleted all views.\n")
 
6132
                self.outf.write(gettext("Deleted all views.\n"))
5855
6133
            elif name is None:
5856
 
                raise errors.BzrCommandError("No current view to delete")
 
6134
                raise errors.BzrCommandError(gettext("No current view to delete"))
5857
6135
            else:
5858
6136
                tree.views.delete_view(name)
5859
 
                self.outf.write("Deleted '%s' view.\n" % name)
 
6137
                self.outf.write(gettext("Deleted '%s' view.\n") % name)
5860
6138
        elif switch:
5861
6139
            if file_list:
5862
 
                raise errors.BzrCommandError(
5863
 
                    "Both --switch and a file list specified")
 
6140
                raise errors.BzrCommandError(gettext(
 
6141
                    "Both --switch and a file list specified"))
5864
6142
            elif all:
5865
 
                raise errors.BzrCommandError(
5866
 
                    "Both --switch and --all specified")
 
6143
                raise errors.BzrCommandError(gettext(
 
6144
                    "Both --switch and --all specified"))
5867
6145
            elif switch == 'off':
5868
6146
                if current_view is None:
5869
 
                    raise errors.BzrCommandError("No current view to disable")
 
6147
                    raise errors.BzrCommandError(gettext("No current view to disable"))
5870
6148
                tree.views.set_view_info(None, view_dict)
5871
 
                self.outf.write("Disabled '%s' view.\n" % (current_view))
 
6149
                self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
5872
6150
            else:
5873
6151
                tree.views.set_view_info(switch, view_dict)
5874
6152
                view_str = views.view_display_str(tree.views.lookup_view())
5875
 
                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))
5876
6154
        elif all:
5877
6155
            if view_dict:
5878
 
                self.outf.write('Views defined:\n')
 
6156
                self.outf.write(gettext('Views defined:\n'))
5879
6157
                for view in sorted(view_dict):
5880
6158
                    if view == current_view:
5881
6159
                        active = "=>"
5884
6162
                    view_str = views.view_display_str(view_dict[view])
5885
6163
                    self.outf.write('%s %-20s %s\n' % (active, view, view_str))
5886
6164
            else:
5887
 
                self.outf.write('No views defined.\n')
 
6165
                self.outf.write(gettext('No views defined.\n'))
5888
6166
        elif file_list:
5889
6167
            if name is None:
5890
6168
                # No name given and no current view set
5891
6169
                name = 'my'
5892
6170
            elif name == 'off':
5893
 
                raise errors.BzrCommandError(
5894
 
                    "Cannot change the 'off' pseudo view")
 
6171
                raise errors.BzrCommandError(gettext(
 
6172
                    "Cannot change the 'off' pseudo view"))
5895
6173
            tree.views.set_view(name, sorted(file_list))
5896
6174
            view_str = views.view_display_str(tree.views.lookup_view())
5897
 
            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))
5898
6176
        else:
5899
6177
            # list the files
5900
6178
            if name is None:
5901
6179
                # No name given and no current view set
5902
 
                self.outf.write('No current view.\n')
 
6180
                self.outf.write(gettext('No current view.\n'))
5903
6181
            else:
5904
6182
                view_str = views.view_display_str(tree.views.lookup_view(name))
5905
 
                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))
5906
6184
 
5907
6185
 
5908
6186
class cmd_hooks(Command):
5922
6200
                        self.outf.write("    %s\n" %
5923
6201
                                        (some_hooks.get_hook_name(hook),))
5924
6202
                else:
5925
 
                    self.outf.write("    <no hooks installed>\n")
 
6203
                    self.outf.write(gettext("    <no hooks installed>\n"))
5926
6204
 
5927
6205
 
5928
6206
class cmd_remove_branch(Command):
6029
6307
        manager = tree.get_shelf_manager()
6030
6308
        shelves = manager.active_shelves()
6031
6309
        if len(shelves) == 0:
6032
 
            note('No shelved changes.')
 
6310
            note(gettext('No shelved changes.'))
6033
6311
            return 0
6034
6312
        for shelf_id in reversed(shelves):
6035
6313
            message = manager.get_metadata(shelf_id).get('message')
6154
6432
            self.outf.write('%s %s\n' % (path, location))
6155
6433
 
6156
6434
 
 
6435
class cmd_export_pot(Command):
 
6436
    __doc__ = """Export command helps and error messages in po format."""
 
6437
 
 
6438
    hidden = True
 
6439
 
 
6440
    def run(self):
 
6441
        from bzrlib.export_pot import export_pot
 
6442
        export_pot(self.outf)
 
6443
 
 
6444
 
6157
6445
def _register_lazy_builtins():
6158
6446
    # register lazy builtins from other modules; called at startup and should
6159
6447
    # be only called once.
6164
6452
        ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6165
6453
        ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6166
6454
        ('cmd_conflicts', [], 'bzrlib.conflicts'),
6167
 
        ('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
 
6455
        ('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
 
6456
        ('cmd_verify_signatures', [],
 
6457
                                        'bzrlib.commit_signature_commands'),
6168
6458
        ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6169
6459
        ]:
6170
6460
        builtin_command_registry.register_lazy(name, aliases, module_name)