~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""builtin bzr commands"""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import os
20
22
 
21
 
from bzrlib.lazy_import import lazy_import
22
 
lazy_import(globals(), """
 
23
import bzrlib.bzrdir
 
24
 
 
25
from bzrlib import lazy_import
 
26
lazy_import.lazy_import(globals(), """
23
27
import cStringIO
 
28
import errno
24
29
import sys
25
30
import time
26
31
 
29
34
    bugtracker,
30
35
    bundle,
31
36
    btree_index,
32
 
    bzrdir,
 
37
    controldir,
33
38
    directory_service,
34
39
    delta,
35
40
    config as _mod_config,
57
62
from bzrlib.revisionspec import RevisionSpec, RevisionInfo
58
63
from bzrlib.smtp_connection import SMTPConnection
59
64
from bzrlib.workingtree import WorkingTree
 
65
from bzrlib.i18n import gettext, ngettext
60
66
""")
61
67
 
62
68
from bzrlib.commands import (
77
83
    )
78
84
 
79
85
 
 
86
def _get_branch_location(control_dir, possible_transports=None):
 
87
    """Return location of branch for this control dir."""
 
88
    try:
 
89
        this_branch = control_dir.open_branch(
 
90
            possible_transports=possible_transports)
 
91
        # This may be a heavy checkout, where we want the master branch
 
92
        master_location = this_branch.get_bound_location()
 
93
        if master_location is not None:
 
94
            return master_location
 
95
        # If not, use a local sibling
 
96
        return this_branch.base
 
97
    except errors.NotBranchError:
 
98
        format = control_dir.find_branch_format()
 
99
        if getattr(format, 'get_reference', None) is not None:
 
100
            return format.get_reference(control_dir)
 
101
        else:
 
102
            return control_dir.root_transport.base
 
103
 
 
104
 
 
105
def _is_colocated(control_dir, possible_transports=None):
 
106
    """Check if the branch in control_dir is colocated.
 
107
 
 
108
    :param control_dir: Control directory
 
109
    :return: Boolean indicating whether 
 
110
    """
 
111
    # This path is meant to be relative to the existing branch
 
112
    this_url = _get_branch_location(control_dir,
 
113
        possible_transports=possible_transports)
 
114
    # Perhaps the target control dir supports colocated branches?
 
115
    try:
 
116
        root = controldir.ControlDir.open(this_url,
 
117
            possible_transports=possible_transports)
 
118
    except errors.NotBranchError:
 
119
        return (False, this_url)
 
120
    else:
 
121
        try:
 
122
            wt = control_dir.open_workingtree()
 
123
        except (errors.NoWorkingTree, errors.NotLocalUrl):
 
124
            return (False, this_url)
 
125
        else:
 
126
            return (
 
127
                root._format.colocated_branches and
 
128
                control_dir.control_url == root.control_url,
 
129
                this_url)
 
130
 
 
131
 
 
132
def lookup_new_sibling_branch(control_dir, location, possible_transports=None):
 
133
    """Lookup the location for a new sibling branch.
 
134
 
 
135
    :param control_dir: Control directory relative to which to look up
 
136
        the name.
 
137
    :param location: Name of the new branch
 
138
    :return: Full location to the new branch
 
139
    """
 
140
    location = directory_service.directories.dereference(location)
 
141
    if '/' not in location and '\\' not in location:
 
142
        (colocated, this_url) = _is_colocated(control_dir, possible_transports)
 
143
 
 
144
        if colocated:
 
145
            return urlutils.join_segment_parameters(this_url,
 
146
                {"branch": urlutils.escape(location)})
 
147
        else:
 
148
            return urlutils.join(this_url, '..', urlutils.escape(location))
 
149
    return location
 
150
 
 
151
 
 
152
def lookup_sibling_branch(control_dir, location, possible_transports=None):
 
153
    """Lookup sibling branch.
 
154
    
 
155
    :param control_dir: Control directory relative to which to lookup the
 
156
        location.
 
157
    :param location: Location to look up
 
158
    :return: branch to open
 
159
    """
 
160
    try:
 
161
        # Perhaps it's a colocated branch?
 
162
        return control_dir.open_branch(location, 
 
163
            possible_transports=possible_transports)
 
164
    except (errors.NotBranchError, errors.NoColocatedBranchSupport):
 
165
        try:
 
166
            return Branch.open(location)
 
167
        except errors.NotBranchError:
 
168
            this_url = _get_branch_location(control_dir)
 
169
            return Branch.open(
 
170
                urlutils.join(
 
171
                    this_url, '..', urlutils.escape(location)))
 
172
 
 
173
 
80
174
@symbol_versioning.deprecated_function(symbol_versioning.deprecated_in((2, 3, 0)))
81
175
def tree_files(file_list, default_branch=u'.', canonicalize=True,
82
176
    apply_view=True):
112
206
            if view_files:
113
207
                file_list = view_files
114
208
                view_str = views.view_display_str(view_files)
115
 
                note("Ignoring files outside view. View is %s" % view_str)
 
209
                note(gettext("Ignoring files outside view. View is %s") % view_str)
116
210
    return tree, file_list
117
211
 
118
212
 
120
214
    if revisions is None:
121
215
        return None
122
216
    if len(revisions) != 1:
123
 
        raise errors.BzrCommandError(
124
 
            'bzr %s --revision takes exactly one revision identifier' % (
 
217
        raise errors.BzrCommandError(gettext(
 
218
            'bzr %s --revision takes exactly one revision identifier') % (
125
219
                command_name,))
126
220
    return revisions[0]
127
221
 
196
290
    the --directory option is used to specify a different branch."""
197
291
    if directory is not None:
198
292
        return (None, Branch.open(directory), filename)
199
 
    return bzrdir.BzrDir.open_containing_tree_or_branch(filename)
 
293
    return controldir.ControlDir.open_containing_tree_or_branch(filename)
200
294
 
201
295
 
202
296
# TODO: Make sure no commands unconditionally use the working directory as a
288
382
        from bzrlib.status import show_tree_status
289
383
 
290
384
        if revision and len(revision) > 2:
291
 
            raise errors.BzrCommandError('bzr status --revision takes exactly'
292
 
                                         ' one or two revision specifiers')
 
385
            raise errors.BzrCommandError(gettext('bzr status --revision takes exactly'
 
386
                                         ' one or two revision specifiers'))
293
387
 
294
388
        tree, relfile_list = WorkingTree.open_containing_paths(file_list)
295
389
        # Avoid asking for specific files when that is not needed.
332
426
    @display_command
333
427
    def run(self, revision_id=None, revision=None, directory=u'.'):
334
428
        if revision_id is not None and revision is not None:
335
 
            raise errors.BzrCommandError('You can only supply one of'
336
 
                                         ' revision_id or --revision')
 
429
            raise errors.BzrCommandError(gettext('You can only supply one of'
 
430
                                         ' revision_id or --revision'))
337
431
        if revision_id is None and revision is None:
338
 
            raise errors.BzrCommandError('You must supply either'
339
 
                                         ' --revision or a revision_id')
 
432
            raise errors.BzrCommandError(gettext('You must supply either'
 
433
                                         ' --revision or a revision_id'))
340
434
 
341
 
        b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
 
435
        b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
342
436
 
343
437
        revisions = b.repository.revisions
344
438
        if revisions is None:
345
 
            raise errors.BzrCommandError('Repository %r does not support '
346
 
                'access to raw revision texts')
 
439
            raise errors.BzrCommandError(gettext('Repository %r does not support '
 
440
                'access to raw revision texts'))
347
441
 
348
442
        b.repository.lock_read()
349
443
        try:
353
447
                try:
354
448
                    self.print_revision(revisions, revision_id)
355
449
                except errors.NoSuchRevision:
356
 
                    msg = "The repository %s contains no revision %s." % (
 
450
                    msg = gettext("The repository {0} contains no revision {1}.").format(
357
451
                        b.repository.base, revision_id)
358
452
                    raise errors.BzrCommandError(msg)
359
453
            elif revision is not None:
360
454
                for rev in revision:
361
455
                    if rev is None:
362
456
                        raise errors.BzrCommandError(
363
 
                            'You cannot specify a NULL revision.')
 
457
                            gettext('You cannot specify a NULL revision.'))
364
458
                    rev_id = rev.as_revision_id(b)
365
459
                    self.print_revision(revisions, rev_id)
366
460
        finally:
472
566
            location_list=['.']
473
567
 
474
568
        for location in location_list:
475
 
            d = bzrdir.BzrDir.open(location)
476
 
            
 
569
            d = controldir.ControlDir.open(location)
 
570
 
477
571
            try:
478
572
                working = d.open_workingtree()
479
573
            except errors.NoWorkingTree:
480
 
                raise errors.BzrCommandError("No working tree to remove")
 
574
                raise errors.BzrCommandError(gettext("No working tree to remove"))
481
575
            except errors.NotLocalUrl:
482
 
                raise errors.BzrCommandError("You cannot remove the working tree"
483
 
                                             " of a remote path")
 
576
                raise errors.BzrCommandError(gettext("You cannot remove the working tree"
 
577
                                             " of a remote path"))
484
578
            if not force:
485
579
                if (working.has_changes()):
486
580
                    raise errors.UncommittedChanges(working)
488
582
                    raise errors.ShelvedChanges(working)
489
583
 
490
584
            if working.user_url != working.branch.user_url:
491
 
                raise errors.BzrCommandError("You cannot remove the working tree"
492
 
                                             " from a lightweight checkout")
 
585
                raise errors.BzrCommandError(gettext("You cannot remove the working tree"
 
586
                                             " from a lightweight checkout"))
493
587
 
494
588
            d.destroy_workingtree()
495
589
 
527
621
                pass # There seems to be a real error here, so we'll reset
528
622
            else:
529
623
                # Refuse
530
 
                raise errors.BzrCommandError(
 
624
                raise errors.BzrCommandError(gettext(
531
625
                    'The tree does not appear to be corrupt. You probably'
532
626
                    ' want "bzr revert" instead. Use "--force" if you are'
533
 
                    ' sure you want to reset the working tree.')
 
627
                    ' sure you want to reset the working tree.'))
534
628
        if revision is None:
535
629
            revision_ids = None
536
630
        else:
539
633
            tree.reset_state(revision_ids)
540
634
        except errors.BzrError, e:
541
635
            if revision_ids is None:
542
 
                extra = (', the header appears corrupt, try passing -r -1'
543
 
                         ' to set the state to the last commit')
 
636
                extra = (gettext(', the header appears corrupt, try passing -r -1'
 
637
                         ' to set the state to the last commit'))
544
638
            else:
545
639
                extra = ''
546
 
            raise errors.BzrCommandError('failed to reset the tree state'
547
 
                                         + extra)
 
640
            raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
548
641
 
549
642
 
550
643
class cmd_revno(Command):
556
649
    _see_also = ['info']
557
650
    takes_args = ['location?']
558
651
    takes_options = [
559
 
        Option('tree', help='Show revno of working tree'),
 
652
        Option('tree', help='Show revno of working tree.'),
 
653
        'revision',
560
654
        ]
561
655
 
562
656
    @display_command
563
 
    def run(self, tree=False, location=u'.'):
 
657
    def run(self, tree=False, location=u'.', revision=None):
 
658
        if revision is not None and tree:
 
659
            raise errors.BzrCommandError(gettext("--tree and --revision can "
 
660
                "not be used together"))
 
661
 
564
662
        if tree:
565
663
            try:
566
664
                wt = WorkingTree.open_containing(location)[0]
567
665
                self.add_cleanup(wt.lock_read().unlock)
568
666
            except (errors.NoWorkingTree, errors.NotLocalUrl):
569
667
                raise errors.NoWorkingTree(location)
 
668
            b = wt.branch
570
669
            revid = wt.last_revision()
571
 
            try:
572
 
                revno_t = wt.branch.revision_id_to_dotted_revno(revid)
573
 
            except errors.NoSuchRevision:
574
 
                revno_t = ('???',)
575
 
            revno = ".".join(str(n) for n in revno_t)
576
670
        else:
577
671
            b = Branch.open_containing(location)[0]
578
672
            self.add_cleanup(b.lock_read().unlock)
579
 
            revno = b.revno()
 
673
            if revision:
 
674
                if len(revision) != 1:
 
675
                    raise errors.BzrCommandError(gettext(
 
676
                        "Tags can only be placed on a single revision, "
 
677
                        "not on a range"))
 
678
                revid = revision[0].as_revision_id(b)
 
679
            else:
 
680
                revid = b.last_revision()
 
681
        try:
 
682
            revno_t = b.revision_id_to_dotted_revno(revid)
 
683
        except errors.NoSuchRevision:
 
684
            revno_t = ('???',)
 
685
        revno = ".".join(str(n) for n in revno_t)
580
686
        self.cleanup_now()
581
 
        self.outf.write(str(revno) + '\n')
 
687
        self.outf.write(revno + '\n')
582
688
 
583
689
 
584
690
class cmd_revision_info(Command):
591
697
        custom_help('directory',
592
698
            help='Branch to examine, '
593
699
                 'rather than the one containing the working directory.'),
594
 
        Option('tree', help='Show revno of working tree'),
 
700
        Option('tree', help='Show revno of working tree.'),
595
701
        ]
596
702
 
597
703
    @display_command
653
759
    are added.  This search proceeds recursively into versioned
654
760
    directories.  If no names are given '.' is assumed.
655
761
 
 
762
    A warning will be printed when nested trees are encountered,
 
763
    unless they are explicitly ignored.
 
764
 
656
765
    Therefore simply saying 'bzr add' will version all files that
657
766
    are currently unknown.
658
767
 
723
832
            if verbose:
724
833
                for glob in sorted(ignored.keys()):
725
834
                    for path in ignored[glob]:
726
 
                        self.outf.write("ignored %s matching \"%s\"\n"
727
 
                                        % (path, glob))
 
835
                        self.outf.write(
 
836
                         gettext("ignored {0} matching \"{1}\"\n").format(
 
837
                         path, glob))
728
838
 
729
839
 
730
840
class cmd_mkdir(Command):
734
844
    """
735
845
 
736
846
    takes_args = ['dir+']
 
847
    takes_options = [
 
848
        Option(
 
849
            'parents',
 
850
            help='No error if existing, make parent directories as needed.',
 
851
            short_name='p'
 
852
            )
 
853
        ]
737
854
    encoding_type = 'replace'
738
855
 
739
 
    def run(self, dir_list):
740
 
        for d in dir_list:
741
 
            wt, dd = WorkingTree.open_containing(d)
742
 
            base = os.path.dirname(dd)
743
 
            id = wt.path2id(base)
744
 
            if id != None:
745
 
                os.mkdir(d)
746
 
                wt.add([dd])
747
 
                self.outf.write('added %s\n' % d)
 
856
    @classmethod
 
857
    def add_file_with_parents(cls, wt, relpath):
 
858
        if wt.path2id(relpath) is not None:
 
859
            return
 
860
        cls.add_file_with_parents(wt, osutils.dirname(relpath))
 
861
        wt.add([relpath])
 
862
 
 
863
    @classmethod
 
864
    def add_file_single(cls, wt, relpath):
 
865
        wt.add([relpath])
 
866
 
 
867
    def run(self, dir_list, parents=False):
 
868
        if parents:
 
869
            add_file = self.add_file_with_parents
 
870
        else:
 
871
            add_file = self.add_file_single
 
872
        for dir in dir_list:
 
873
            wt, relpath = WorkingTree.open_containing(dir)
 
874
            if parents:
 
875
                try:
 
876
                    os.makedirs(dir)
 
877
                except OSError, e:
 
878
                    if e.errno != errno.EEXIST:
 
879
                        raise
748
880
            else:
749
 
                raise errors.NotVersionedError(path=base)
 
881
                os.mkdir(dir)
 
882
            add_file(wt, relpath)
 
883
            if not is_quiet():
 
884
                self.outf.write(gettext('added %s\n') % dir)
750
885
 
751
886
 
752
887
class cmd_relpath(Command):
788
923
    @display_command
789
924
    def run(self, revision=None, show_ids=False, kind=None, file_list=None):
790
925
        if kind and kind not in ['file', 'directory', 'symlink']:
791
 
            raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
 
926
            raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
792
927
 
793
928
        revision = _get_one_revision('inventory', revision)
794
929
        work_tree, file_list = WorkingTree.open_containing_paths(file_list)
858
993
        if auto:
859
994
            return self.run_auto(names_list, after, dry_run)
860
995
        elif dry_run:
861
 
            raise errors.BzrCommandError('--dry-run requires --auto.')
 
996
            raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
862
997
        if names_list is None:
863
998
            names_list = []
864
999
        if len(names_list) < 2:
865
 
            raise errors.BzrCommandError("missing file argument")
 
1000
            raise errors.BzrCommandError(gettext("missing file argument"))
866
1001
        tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
 
1002
        for file_name in rel_names[0:-1]:
 
1003
            if file_name == '':
 
1004
                raise errors.BzrCommandError(gettext("can not move root of branch"))
867
1005
        self.add_cleanup(tree.lock_tree_write().unlock)
868
1006
        self._run(tree, names_list, rel_names, after)
869
1007
 
870
1008
    def run_auto(self, names_list, after, dry_run):
871
1009
        if names_list is not None and len(names_list) > 1:
872
 
            raise errors.BzrCommandError('Only one path may be specified to'
873
 
                                         ' --auto.')
 
1010
            raise errors.BzrCommandError(gettext('Only one path may be specified to'
 
1011
                                         ' --auto.'))
874
1012
        if after:
875
 
            raise errors.BzrCommandError('--after cannot be specified with'
876
 
                                         ' --auto.')
 
1013
            raise errors.BzrCommandError(gettext('--after cannot be specified with'
 
1014
                                         ' --auto.'))
877
1015
        work_tree, file_list = WorkingTree.open_containing_paths(
878
1016
            names_list, default_directory='.')
879
1017
        self.add_cleanup(work_tree.lock_tree_write().unlock)
909
1047
                    self.outf.write("%s => %s\n" % (src, dest))
910
1048
        else:
911
1049
            if len(names_list) != 2:
912
 
                raise errors.BzrCommandError('to mv multiple files the'
 
1050
                raise errors.BzrCommandError(gettext('to mv multiple files the'
913
1051
                                             ' destination must be a versioned'
914
 
                                             ' directory')
 
1052
                                             ' directory'))
915
1053
 
916
1054
            # for cicp file-systems: the src references an existing inventory
917
1055
            # item:
977
1115
    branches have diverged.
978
1116
 
979
1117
    If there is no default location set, the first pull will set it (use
980
 
    --no-remember to avoid settting it). After that, you can omit the
 
1118
    --no-remember to avoid setting it). After that, you can omit the
981
1119
    location to use the default.  To change the default, use --remember. The
982
1120
    value will only be saved if the remote location can be accessed.
983
1121
 
 
1122
    The --verbose option will display the revisions pulled using the log_format
 
1123
    configuration option. You can use a different format by overriding it with
 
1124
    -Olog_format=<other_format>.
 
1125
 
984
1126
    Note: The location can be specified either in the form of a branch,
985
1127
    or in the form of a path to a file containing a merge directive generated
986
1128
    with bzr send.
1023
1165
            self.add_cleanup(branch_to.lock_write().unlock)
1024
1166
 
1025
1167
        if tree_to is None and show_base:
1026
 
            raise errors.BzrCommandError("Need working tree for --show-base.")
 
1168
            raise errors.BzrCommandError(gettext("Need working tree for --show-base."))
1027
1169
 
1028
1170
        if local and not branch_to.get_bound_location():
1029
1171
            raise errors.LocalRequiresBoundBranch()
1039
1181
        stored_loc = branch_to.get_parent()
1040
1182
        if location is None:
1041
1183
            if stored_loc is None:
1042
 
                raise errors.BzrCommandError("No pull location known or"
1043
 
                                             " specified.")
 
1184
                raise errors.BzrCommandError(gettext("No pull location known or"
 
1185
                                             " specified."))
1044
1186
            else:
1045
1187
                display_url = urlutils.unescape_for_display(stored_loc,
1046
1188
                        self.outf.encoding)
1047
1189
                if not is_quiet():
1048
 
                    self.outf.write("Using saved parent location: %s\n" % display_url)
 
1190
                    self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1049
1191
                location = stored_loc
1050
1192
 
1051
1193
        revision = _get_one_revision('pull', revision)
1052
1194
        if mergeable is not None:
1053
1195
            if revision is not None:
1054
 
                raise errors.BzrCommandError(
1055
 
                    'Cannot use -r with merge directives or bundles')
 
1196
                raise errors.BzrCommandError(gettext(
 
1197
                    'Cannot use -r with merge directives or bundles'))
1056
1198
            mergeable.install_revisions(branch_to.repository)
1057
1199
            base_revision_id, revision_id, verified = \
1058
1200
                mergeable.get_merge_request(branch_to.repository)
1076
1218
                view_info=view_info)
1077
1219
            result = tree_to.pull(
1078
1220
                branch_from, overwrite, revision_id, change_reporter,
1079
 
                possible_transports=possible_transports, local=local,
1080
 
                show_base=show_base)
 
1221
                local=local, show_base=show_base)
1081
1222
        else:
1082
1223
            result = branch_to.pull(
1083
1224
                branch_from, overwrite, revision_id, local=local)
1114
1255
    After that you will be able to do a push without '--overwrite'.
1115
1256
 
1116
1257
    If there is no default push location set, the first push will set it (use
1117
 
    --no-remember to avoid settting it).  After that, you can omit the
 
1258
    --no-remember to avoid setting it).  After that, you can omit the
1118
1259
    location to use the default.  To change the default, use --remember. The
1119
1260
    value will only be saved if the remote location can be accessed.
 
1261
 
 
1262
    The --verbose option will display the revisions pushed using the log_format
 
1263
    configuration option. You can use a different format by overriding it with
 
1264
    -Olog_format=<other_format>.
1120
1265
    """
1121
1266
 
1122
1267
    _see_also = ['pull', 'update', 'working-trees']
1160
1305
            directory = '.'
1161
1306
        # Get the source branch
1162
1307
        (tree, br_from,
1163
 
         _unused) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
 
1308
         _unused) = controldir.ControlDir.open_containing_tree_or_branch(directory)
1164
1309
        # Get the tip's revision_id
1165
1310
        revision = _get_one_revision('push', revision)
1166
1311
        if revision is not None:
1187
1332
                    # error by the feedback given to them. RBC 20080227.
1188
1333
                    stacked_on = parent_url
1189
1334
            if not stacked_on:
1190
 
                raise errors.BzrCommandError(
1191
 
                    "Could not determine branch to refer to.")
 
1335
                raise errors.BzrCommandError(gettext(
 
1336
                    "Could not determine branch to refer to."))
1192
1337
 
1193
1338
        # Get the destination location
1194
1339
        if location is None:
1195
1340
            stored_loc = br_from.get_push_location()
1196
1341
            if stored_loc is None:
1197
 
                raise errors.BzrCommandError(
1198
 
                    "No push location known or specified.")
 
1342
                parent_loc = br_from.get_parent()
 
1343
                if parent_loc:
 
1344
                    raise errors.BzrCommandError(gettext(
 
1345
                        "No push location known or specified. To push to the "
 
1346
                        "parent branch (at %s), use 'bzr push :parent'." %
 
1347
                        urlutils.unescape_for_display(parent_loc,
 
1348
                            self.outf.encoding)))
 
1349
                else:
 
1350
                    raise errors.BzrCommandError(gettext(
 
1351
                        "No push location known or specified."))
1199
1352
            else:
1200
1353
                display_url = urlutils.unescape_for_display(stored_loc,
1201
1354
                        self.outf.encoding)
1202
 
                note("Using saved push location: %s" % display_url)
 
1355
                note(gettext("Using saved push location: %s") % display_url)
1203
1356
                location = stored_loc
1204
1357
 
1205
1358
        _show_push_branch(br_from, revision_id, location, self.outf,
1263
1416
                deprecated_name=self.invoked_as,
1264
1417
                recommended_name='branch',
1265
1418
                deprecated_in_version='2.4')
1266
 
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
 
1419
        accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
1267
1420
            from_location)
1268
1421
        if not (hardlink or files_from):
1269
1422
            # accelerator_tree is usually slower because you have to read N
1282
1435
            # RBC 20060209
1283
1436
            revision_id = br_from.last_revision()
1284
1437
        if to_location is None:
1285
 
            to_location = urlutils.derive_to_location(from_location)
 
1438
            to_location = getattr(br_from, "name", None)
 
1439
            if not to_location:
 
1440
                to_location = urlutils.derive_to_location(from_location)
1286
1441
        to_transport = transport.get_transport(to_location)
1287
1442
        try:
1288
1443
            to_transport.mkdir('.')
1289
1444
        except errors.FileExists:
1290
 
            if not use_existing_dir:
1291
 
                raise errors.BzrCommandError('Target directory "%s" '
1292
 
                    'already exists.' % to_location)
 
1445
            try:
 
1446
                to_dir = controldir.ControlDir.open_from_transport(
 
1447
                    to_transport)
 
1448
            except errors.NotBranchError:
 
1449
                if not use_existing_dir:
 
1450
                    raise errors.BzrCommandError(gettext('Target directory "%s" '
 
1451
                        'already exists.') % to_location)
 
1452
                else:
 
1453
                    to_dir = None
1293
1454
            else:
1294
1455
                try:
1295
 
                    bzrdir.BzrDir.open_from_transport(to_transport)
 
1456
                    to_dir.open_branch()
1296
1457
                except errors.NotBranchError:
1297
1458
                    pass
1298
1459
                else:
1299
1460
                    raise errors.AlreadyBranchError(to_location)
1300
1461
        except errors.NoSuchFile:
1301
 
            raise errors.BzrCommandError('Parent of "%s" does not exist.'
 
1462
            raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1302
1463
                                         % to_location)
1303
 
        try:
1304
 
            # preserve whatever source format we have.
1305
 
            dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1306
 
                                        possible_transports=[to_transport],
1307
 
                                        accelerator_tree=accelerator_tree,
1308
 
                                        hardlink=hardlink, stacked=stacked,
1309
 
                                        force_new_repo=standalone,
1310
 
                                        create_tree_if_local=not no_tree,
1311
 
                                        source_branch=br_from)
1312
 
            branch = dir.open_branch()
1313
 
        except errors.NoSuchRevision:
1314
 
            to_transport.delete_tree('.')
1315
 
            msg = "The branch %s has no revision %s." % (from_location,
1316
 
                revision)
1317
 
            raise errors.BzrCommandError(msg)
 
1464
        else:
 
1465
            to_dir = None
 
1466
        if to_dir is None:
 
1467
            try:
 
1468
                # preserve whatever source format we have.
 
1469
                to_dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
 
1470
                                            possible_transports=[to_transport],
 
1471
                                            accelerator_tree=accelerator_tree,
 
1472
                                            hardlink=hardlink, stacked=stacked,
 
1473
                                            force_new_repo=standalone,
 
1474
                                            create_tree_if_local=not no_tree,
 
1475
                                            source_branch=br_from)
 
1476
                branch = to_dir.open_branch(
 
1477
                    possible_transports=[
 
1478
                        br_from.bzrdir.root_transport, to_transport])
 
1479
            except errors.NoSuchRevision:
 
1480
                to_transport.delete_tree('.')
 
1481
                msg = gettext("The branch {0} has no revision {1}.").format(
 
1482
                    from_location, revision)
 
1483
                raise errors.BzrCommandError(msg)
 
1484
        else:
 
1485
            try:
 
1486
                to_repo = to_dir.open_repository()
 
1487
            except errors.NoRepositoryPresent:
 
1488
                to_repo = to_dir.create_repository()
 
1489
            to_repo.fetch(br_from.repository, revision_id=revision_id)
 
1490
            branch = br_from.sprout(to_dir, revision_id=revision_id)
1318
1491
        _merge_tags_if_possible(br_from, branch)
1319
1492
        # If the source branch is stacked, the new branch may
1320
1493
        # be stacked whether we asked for that explicitly or not.
1321
1494
        # We therefore need a try/except here and not just 'if stacked:'
1322
1495
        try:
1323
 
            note('Created new stacked branch referring to %s.' %
 
1496
            note(gettext('Created new stacked branch referring to %s.') %
1324
1497
                branch.get_stacked_on_url())
1325
1498
        except (errors.NotStacked, errors.UnstackableBranchFormat,
1326
1499
            errors.UnstackableRepositoryFormat), e:
1327
 
            note('Branched %d revision(s).' % branch.revno())
 
1500
            note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1328
1501
        if bind:
1329
1502
            # Bind to the parent
1330
1503
            parent_branch = Branch.open(from_location)
1331
1504
            branch.bind(parent_branch)
1332
 
            note('New branch bound to %s' % from_location)
 
1505
            note(gettext('New branch bound to %s') % from_location)
1333
1506
        if switch:
1334
1507
            # Switch to the new branch
1335
1508
            wt, _ = WorkingTree.open_containing('.')
1336
1509
            _mod_switch.switch(wt.bzrdir, branch)
1337
 
            note('Switched to branch: %s',
 
1510
            note(gettext('Switched to branch: %s'),
1338
1511
                urlutils.unescape_for_display(branch.base, 'utf-8'))
1339
1512
 
1340
1513
 
1341
1514
class cmd_branches(Command):
1342
1515
    __doc__ = """List the branches available at the current location.
1343
1516
 
1344
 
    This command will print the names of all the branches at the current location.
 
1517
    This command will print the names of all the branches at the current
 
1518
    location.
1345
1519
    """
1346
1520
 
1347
1521
    takes_args = ['location?']
 
1522
    takes_options = [
 
1523
                  Option('recursive', short_name='R',
 
1524
                         help='Recursively scan for branches rather than '
 
1525
                              'just looking in the specified location.')]
1348
1526
 
1349
 
    def run(self, location="."):
1350
 
        dir = bzrdir.BzrDir.open_containing(location)[0]
1351
 
        for branch in dir.list_branches():
1352
 
            if branch.name is None:
1353
 
                self.outf.write(" (default)\n")
1354
 
            else:
1355
 
                self.outf.write(" %s\n" % branch.name.encode(self.outf.encoding))
 
1527
    def run(self, location=".", recursive=False):
 
1528
        if recursive:
 
1529
            t = transport.get_transport(location)
 
1530
            if not t.listable():
 
1531
                raise errors.BzrCommandError(
 
1532
                    "Can't scan this type of location.")
 
1533
            for b in controldir.ControlDir.find_branches(t):
 
1534
                self.outf.write("%s\n" % urlutils.unescape_for_display(
 
1535
                    urlutils.relative_url(t.base, b.base),
 
1536
                    self.outf.encoding).rstrip("/"))
 
1537
        else:
 
1538
            dir = controldir.ControlDir.open_containing(location)[0]
 
1539
            try:
 
1540
                active_branch = dir.open_branch(name="")
 
1541
            except errors.NotBranchError:
 
1542
                active_branch = None
 
1543
            branches = dir.get_branches()
 
1544
            names = {}
 
1545
            for name, branch in branches.iteritems():
 
1546
                if name == "":
 
1547
                    continue
 
1548
                active = (active_branch is not None and
 
1549
                          active_branch.base == branch.base)
 
1550
                names[name] = active
 
1551
            # Only mention the current branch explicitly if it's not
 
1552
            # one of the colocated branches
 
1553
            if not any(names.values()) and active_branch is not None:
 
1554
                self.outf.write("* %s\n" % gettext("(default)"))
 
1555
            for name in sorted(names.keys()):
 
1556
                active = names[name]
 
1557
                if active:
 
1558
                    prefix = "*"
 
1559
                else:
 
1560
                    prefix = " "
 
1561
                self.outf.write("%s %s\n" % (
 
1562
                    prefix, name.encode(self.outf.encoding)))
1356
1563
 
1357
1564
 
1358
1565
class cmd_checkout(Command):
1399
1606
        if branch_location is None:
1400
1607
            branch_location = osutils.getcwd()
1401
1608
            to_location = branch_location
1402
 
        accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(
 
1609
        accelerator_tree, source = controldir.ControlDir.open_tree_or_branch(
1403
1610
            branch_location)
1404
1611
        if not (hardlink or files_from):
1405
1612
            # accelerator_tree is usually slower because you have to read N
1460
1667
 
1461
1668
 
1462
1669
class cmd_update(Command):
1463
 
    __doc__ = """Update a tree to have the latest code committed to its branch.
1464
 
 
1465
 
    This will perform a merge into the working tree, and may generate
1466
 
    conflicts. If you have any local changes, you will still
1467
 
    need to commit them after the update for the update to be complete.
1468
 
 
1469
 
    If you want to discard your local changes, you can just do a
1470
 
    'bzr revert' instead of 'bzr commit' after the update.
1471
 
 
1472
 
    If you want to restore a file that has been removed locally, use
1473
 
    'bzr revert' instead of 'bzr update'.
1474
 
 
1475
 
    If the tree's branch is bound to a master branch, it will also update
 
1670
    __doc__ = """Update a working tree to a new revision.
 
1671
 
 
1672
    This will perform a merge of the destination revision (the tip of the
 
1673
    branch, or the specified revision) into the working tree, and then make
 
1674
    that revision the basis revision for the working tree.  
 
1675
 
 
1676
    You can use this to visit an older revision, or to update a working tree
 
1677
    that is out of date from its branch.
 
1678
    
 
1679
    If there are any uncommitted changes in the tree, they will be carried
 
1680
    across and remain as uncommitted changes after the update.  To discard
 
1681
    these changes, use 'bzr revert'.  The uncommitted changes may conflict
 
1682
    with the changes brought in by the change in basis revision.
 
1683
 
 
1684
    If the tree's branch is bound to a master branch, bzr will also update
1476
1685
    the branch from the master.
 
1686
 
 
1687
    You cannot update just a single file or directory, because each Bazaar
 
1688
    working tree has just a single basis revision.  If you want to restore a
 
1689
    file that has been removed locally, use 'bzr revert' instead of 'bzr
 
1690
    update'.  If you want to restore a file to its state in a previous
 
1691
    revision, use 'bzr revert' with a '-r' option, or use 'bzr cat' to write
 
1692
    out the old content of that file to a new location.
 
1693
 
 
1694
    The 'dir' argument, if given, must be the location of the root of a
 
1695
    working tree to update.  By default, the working tree that contains the 
 
1696
    current working directory is used.
1477
1697
    """
1478
1698
 
1479
1699
    _see_also = ['pull', 'working-trees', 'status-flags']
1484
1704
                     ]
1485
1705
    aliases = ['up']
1486
1706
 
1487
 
    def run(self, dir='.', revision=None, show_base=None):
 
1707
    def run(self, dir=None, revision=None, show_base=None):
1488
1708
        if revision is not None and len(revision) != 1:
1489
 
            raise errors.BzrCommandError(
1490
 
                        "bzr update --revision takes exactly one revision")
1491
 
        tree = WorkingTree.open_containing(dir)[0]
 
1709
            raise errors.BzrCommandError(gettext(
 
1710
                "bzr update --revision takes exactly one revision"))
 
1711
        if dir is None:
 
1712
            tree = WorkingTree.open_containing('.')[0]
 
1713
        else:
 
1714
            tree, relpath = WorkingTree.open_containing(dir)
 
1715
            if relpath:
 
1716
                # See bug 557886.
 
1717
                raise errors.BzrCommandError(gettext(
 
1718
                    "bzr update can only update a whole tree, "
 
1719
                    "not a file or subdirectory"))
1492
1720
        branch = tree.branch
1493
1721
        possible_transports = []
1494
1722
        master = branch.get_master_branch(
1518
1746
            revision_id = branch.last_revision()
1519
1747
        if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1520
1748
            revno = branch.revision_id_to_dotted_revno(revision_id)
1521
 
            note("Tree is up to date at revision %s of branch %s" %
1522
 
                ('.'.join(map(str, revno)), branch_location))
 
1749
            note(gettext("Tree is up to date at revision {0} of branch {1}"
 
1750
                        ).format('.'.join(map(str, revno)), branch_location))
1523
1751
            return 0
1524
1752
        view_info = _get_view_info_for_change_reporter(tree)
1525
1753
        change_reporter = delta._ChangeReporter(
1533
1761
                old_tip=old_tip,
1534
1762
                show_base=show_base)
1535
1763
        except errors.NoSuchRevision, e:
1536
 
            raise errors.BzrCommandError(
 
1764
            raise errors.BzrCommandError(gettext(
1537
1765
                                  "branch has no revision %s\n"
1538
1766
                                  "bzr update --revision only works"
1539
 
                                  " for a revision in the branch history"
 
1767
                                  " for a revision in the branch history")
1540
1768
                                  % (e.revision))
1541
1769
        revno = tree.branch.revision_id_to_dotted_revno(
1542
1770
            _mod_revision.ensure_null(tree.last_revision()))
1543
 
        note('Updated to revision %s of branch %s' %
1544
 
             ('.'.join(map(str, revno)), branch_location))
 
1771
        note(gettext('Updated to revision {0} of branch {1}').format(
 
1772
             '.'.join(map(str, revno)), branch_location))
1545
1773
        parent_ids = tree.get_parent_ids()
1546
1774
        if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1547
 
            note('Your local commits will now show as pending merges with '
1548
 
                 "'bzr status', and can be committed with 'bzr commit'.")
 
1775
            note(gettext('Your local commits will now show as pending merges with '
 
1776
                 "'bzr status', and can be committed with 'bzr commit'."))
1549
1777
        if conflicts != 0:
1550
1778
            return 1
1551
1779
        else:
1592
1820
        else:
1593
1821
            noise_level = 0
1594
1822
        from bzrlib.info import show_bzrdir_info
1595
 
        show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
 
1823
        show_bzrdir_info(controldir.ControlDir.open_containing(location)[0],
1596
1824
                         verbose=noise_level, outfile=self.outf)
1597
1825
 
1598
1826
 
1623
1851
    def run(self, file_list, verbose=False, new=False,
1624
1852
        file_deletion_strategy='safe'):
1625
1853
        if file_deletion_strategy == 'force':
1626
 
            note("(The --force option is deprecated, rather use --no-backup "
1627
 
                "in future.)")
 
1854
            note(gettext("(The --force option is deprecated, rather use --no-backup "
 
1855
                "in future.)"))
1628
1856
            file_deletion_strategy = 'no-backup'
1629
1857
 
1630
1858
        tree, file_list = WorkingTree.open_containing_paths(file_list)
1640
1868
                specific_files=file_list).added
1641
1869
            file_list = sorted([f[0] for f in added], reverse=True)
1642
1870
            if len(file_list) == 0:
1643
 
                raise errors.BzrCommandError('No matching files.')
 
1871
                raise errors.BzrCommandError(gettext('No matching files.'))
1644
1872
        elif file_list is None:
1645
1873
            # missing files show up in iter_changes(basis) as
1646
1874
            # versioned-with-no-kind.
1730
1958
 
1731
1959
    def run(self, branch=".", canonicalize_chks=False):
1732
1960
        from bzrlib.reconcile import reconcile
1733
 
        dir = bzrdir.BzrDir.open(branch)
 
1961
        dir = controldir.ControlDir.open(branch)
1734
1962
        reconcile(dir, canonicalize_chks=canonicalize_chks)
1735
1963
 
1736
1964
 
1745
1973
    @display_command
1746
1974
    def run(self, location="."):
1747
1975
        branch = Branch.open_containing(location)[0]
1748
 
        for revid in branch.revision_history():
 
1976
        self.add_cleanup(branch.lock_read().unlock)
 
1977
        graph = branch.repository.get_graph()
 
1978
        history = list(graph.iter_lefthand_ancestry(branch.last_revision(),
 
1979
            [_mod_revision.NULL_REVISION]))
 
1980
        for revid in reversed(history):
1749
1981
            self.outf.write(revid)
1750
1982
            self.outf.write('\n')
1751
1983
 
1812
2044
                help='Specify a format for this branch. '
1813
2045
                'See "help formats".',
1814
2046
                lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1815
 
                converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
2047
                converter=lambda name: controldir.format_registry.make_bzrdir(name),
1816
2048
                value_switches=True,
1817
2049
                title="Branch format",
1818
2050
                ),
1825
2057
    def run(self, location=None, format=None, append_revisions_only=False,
1826
2058
            create_prefix=False, no_tree=False):
1827
2059
        if format is None:
1828
 
            format = bzrdir.format_registry.make_bzrdir('default')
 
2060
            format = controldir.format_registry.make_bzrdir('default')
1829
2061
        if location is None:
1830
2062
            location = u'.'
1831
2063
 
1840
2072
            to_transport.ensure_base()
1841
2073
        except errors.NoSuchFile:
1842
2074
            if not create_prefix:
1843
 
                raise errors.BzrCommandError("Parent directory of %s"
 
2075
                raise errors.BzrCommandError(gettext("Parent directory of %s"
1844
2076
                    " does not exist."
1845
2077
                    "\nYou may supply --create-prefix to create all"
1846
 
                    " leading parent directories."
 
2078
                    " leading parent directories.")
1847
2079
                    % location)
1848
2080
            to_transport.create_prefix()
1849
2081
 
1850
2082
        try:
1851
 
            a_bzrdir = bzrdir.BzrDir.open_from_transport(to_transport)
 
2083
            a_bzrdir = controldir.ControlDir.open_from_transport(to_transport)
1852
2084
        except errors.NotBranchError:
1853
2085
            # really a NotBzrDir error...
1854
 
            create_branch = bzrdir.BzrDir.create_branch_convenience
 
2086
            create_branch = controldir.ControlDir.create_branch_convenience
1855
2087
            if no_tree:
1856
2088
                force_new_tree = False
1857
2089
            else:
1868
2100
                        raise errors.BranchExistsWithoutWorkingTree(location)
1869
2101
                raise errors.AlreadyBranchError(location)
1870
2102
            branch = a_bzrdir.create_branch()
1871
 
            if not no_tree:
 
2103
            if not no_tree and not a_bzrdir.has_workingtree():
1872
2104
                a_bzrdir.create_workingtree()
1873
2105
        if append_revisions_only:
1874
2106
            try:
1875
2107
                branch.set_append_revisions_only(True)
1876
2108
            except errors.UpgradeRequired:
1877
 
                raise errors.BzrCommandError('This branch format cannot be set'
1878
 
                    ' to append-revisions-only.  Try --default.')
 
2109
                raise errors.BzrCommandError(gettext('This branch format cannot be set'
 
2110
                    ' to append-revisions-only.  Try --default.'))
1879
2111
        if not is_quiet():
1880
2112
            from bzrlib.info import describe_layout, describe_format
1881
2113
            try:
1885
2117
            repository = branch.repository
1886
2118
            layout = describe_layout(repository, branch, tree).lower()
1887
2119
            format = describe_format(a_bzrdir, repository, branch, tree)
1888
 
            self.outf.write("Created a %s (format: %s)\n" % (layout, format))
 
2120
            self.outf.write(gettext("Created a {0} (format: {1})\n").format(
 
2121
                  layout, format))
1889
2122
            if repository.is_shared():
1890
2123
                #XXX: maybe this can be refactored into transport.path_or_url()
1891
2124
                url = repository.bzrdir.root_transport.external_url()
1893
2126
                    url = urlutils.local_path_from_url(url)
1894
2127
                except errors.InvalidURL:
1895
2128
                    pass
1896
 
                self.outf.write("Using shared repository: %s\n" % url)
 
2129
                self.outf.write(gettext("Using shared repository: %s\n") % url)
1897
2130
 
1898
2131
 
1899
2132
class cmd_init_repository(Command):
1929
2162
    takes_options = [RegistryOption('format',
1930
2163
                            help='Specify a format for this repository. See'
1931
2164
                                 ' "bzr help formats" for details.',
1932
 
                            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
1933
 
                            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
2165
                            lazy_registry=('bzrlib.controldir', 'format_registry'),
 
2166
                            converter=lambda name: controldir.format_registry.make_bzrdir(name),
1934
2167
                            value_switches=True, title='Repository format'),
1935
2168
                     Option('no-trees',
1936
2169
                             help='Branches in the repository will default to'
1940
2173
 
1941
2174
    def run(self, location, format=None, no_trees=False):
1942
2175
        if format is None:
1943
 
            format = bzrdir.format_registry.make_bzrdir('default')
 
2176
            format = controldir.format_registry.make_bzrdir('default')
1944
2177
 
1945
2178
        if location is None:
1946
2179
            location = '.'
1947
2180
 
1948
2181
        to_transport = transport.get_transport(location)
1949
 
        to_transport.ensure_base()
1950
2182
 
1951
 
        newdir = format.initialize_on_transport(to_transport)
1952
 
        repo = newdir.create_repository(shared=True)
1953
 
        repo.set_make_working_trees(not no_trees)
 
2183
        (repo, newdir, require_stacking, repository_policy) = (
 
2184
            format.initialize_on_transport_ex(to_transport,
 
2185
            create_prefix=True, make_working_trees=not no_trees,
 
2186
            shared_repo=True, force_new_repo=True,
 
2187
            use_existing_dir=True,
 
2188
            repo_format_name=format.repository_format.get_format_string()))
1954
2189
        if not is_quiet():
1955
2190
            from bzrlib.info import show_bzrdir_info
1956
 
            show_bzrdir_info(repo.bzrdir, verbose=0, outfile=self.outf)
 
2191
            show_bzrdir_info(newdir, verbose=0, outfile=self.outf)
1957
2192
 
1958
2193
 
1959
2194
class cmd_diff(Command):
2090
2325
        elif ':' in prefix:
2091
2326
            old_label, new_label = prefix.split(":")
2092
2327
        else:
2093
 
            raise errors.BzrCommandError(
 
2328
            raise errors.BzrCommandError(gettext(
2094
2329
                '--prefix expects two values separated by a colon'
2095
 
                ' (eg "old/:new/")')
 
2330
                ' (eg "old/:new/")'))
2096
2331
 
2097
2332
        if revision and len(revision) > 2:
2098
 
            raise errors.BzrCommandError('bzr diff --revision takes exactly'
2099
 
                                         ' one or two revision specifiers')
 
2333
            raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
 
2334
                                         ' one or two revision specifiers'))
2100
2335
 
2101
2336
        if using is not None and format is not None:
2102
 
            raise errors.BzrCommandError('--using and --format are mutually '
2103
 
                'exclusive.')
 
2337
            raise errors.BzrCommandError(gettext(
 
2338
                '{0} and {1} are mutually exclusive').format(
 
2339
                '--using', '--format'))
2104
2340
 
2105
2341
        (old_tree, new_tree,
2106
2342
         old_branch, new_branch,
2214
2450
    try:
2215
2451
        return int(limitstring)
2216
2452
    except ValueError:
2217
 
        msg = "The limit argument must be an integer."
 
2453
        msg = gettext("The limit argument must be an integer.")
2218
2454
        raise errors.BzrCommandError(msg)
2219
2455
 
2220
2456
 
2222
2458
    try:
2223
2459
        return int(s)
2224
2460
    except ValueError:
2225
 
        msg = "The levels argument must be an integer."
 
2461
        msg = gettext("The levels argument must be an integer.")
2226
2462
        raise errors.BzrCommandError(msg)
2227
2463
 
2228
2464
 
2420
2656
            Option('show-diff',
2421
2657
                   short_name='p',
2422
2658
                   help='Show changes made in each revision as a patch.'),
2423
 
            Option('include-merges',
 
2659
            Option('include-merged',
2424
2660
                   help='Show merged revisions like --levels 0 does.'),
 
2661
            Option('include-merges', hidden=True,
 
2662
                   help='Historical alias for --include-merged.'),
 
2663
            Option('omit-merges',
 
2664
                   help='Do not report commits with more than one parent.'),
2425
2665
            Option('exclude-common-ancestry',
2426
2666
                   help='Display only the revisions that are not part'
2427
 
                   ' of both ancestries (require -rX..Y)'
 
2667
                   ' of both ancestries (require -rX..Y).'
2428
2668
                   ),
2429
2669
            Option('signatures',
2430
 
                   help='Show digital signature validity'),
 
2670
                   help='Show digital signature validity.'),
2431
2671
            ListOption('match',
2432
2672
                short_name='m',
2433
2673
                help='Show revisions whose properties match this '
2464
2704
            message=None,
2465
2705
            limit=None,
2466
2706
            show_diff=False,
2467
 
            include_merges=False,
 
2707
            include_merged=None,
2468
2708
            authors=None,
2469
2709
            exclude_common_ancestry=False,
2470
2710
            signatures=False,
2473
2713
            match_committer=None,
2474
2714
            match_author=None,
2475
2715
            match_bugs=None,
 
2716
            omit_merges=False,
 
2717
            include_merges=symbol_versioning.DEPRECATED_PARAMETER,
2476
2718
            ):
2477
2719
        from bzrlib.log import (
2478
2720
            Logger,
2480
2722
            _get_info_for_log_files,
2481
2723
            )
2482
2724
        direction = (forward and 'forward') or 'reverse'
 
2725
        if symbol_versioning.deprecated_passed(include_merges):
 
2726
            ui.ui_factory.show_user_warning(
 
2727
                'deprecated_command_option',
 
2728
                deprecated_name='--include-merges',
 
2729
                recommended_name='--include-merged',
 
2730
                deprecated_in_version='2.5',
 
2731
                command=self.invoked_as)
 
2732
            if include_merged is None:
 
2733
                include_merged = include_merges
 
2734
            else:
 
2735
                raise errors.BzrCommandError(gettext(
 
2736
                    '{0} and {1} are mutually exclusive').format(
 
2737
                    '--include-merges', '--include-merged'))
 
2738
        if include_merged is None:
 
2739
            include_merged = False
2483
2740
        if (exclude_common_ancestry
2484
2741
            and (revision is None or len(revision) != 2)):
2485
 
            raise errors.BzrCommandError(
2486
 
                '--exclude-common-ancestry requires -r with two revisions')
2487
 
        if include_merges:
 
2742
            raise errors.BzrCommandError(gettext(
 
2743
                '--exclude-common-ancestry requires -r with two revisions'))
 
2744
        if include_merged:
2488
2745
            if levels is None:
2489
2746
                levels = 0
2490
2747
            else:
2491
 
                raise errors.BzrCommandError(
2492
 
                    '--levels and --include-merges are mutually exclusive')
 
2748
                raise errors.BzrCommandError(gettext(
 
2749
                    '{0} and {1} are mutually exclusive').format(
 
2750
                    '--levels', '--include-merged'))
2493
2751
 
2494
2752
        if change is not None:
2495
2753
            if len(change) > 1:
2496
2754
                raise errors.RangeInChangeOption()
2497
2755
            if revision is not None:
2498
 
                raise errors.BzrCommandError(
2499
 
                    '--revision and --change are mutually exclusive')
 
2756
                raise errors.BzrCommandError(gettext(
 
2757
                    '{0} and {1} are mutually exclusive').format(
 
2758
                    '--revision', '--change'))
2500
2759
            else:
2501
2760
                revision = change
2502
2761
 
2508
2767
                revision, file_list, self.add_cleanup)
2509
2768
            for relpath, file_id, kind in file_info_list:
2510
2769
                if file_id is None:
2511
 
                    raise errors.BzrCommandError(
2512
 
                        "Path unknown at end or start of revision range: %s" %
 
2770
                    raise errors.BzrCommandError(gettext(
 
2771
                        "Path unknown at end or start of revision range: %s") %
2513
2772
                        relpath)
2514
2773
                # If the relpath is the top of the tree, we log everything
2515
2774
                if relpath == '':
2527
2786
                location = revision[0].get_branch()
2528
2787
            else:
2529
2788
                location = '.'
2530
 
            dir, relpath = bzrdir.BzrDir.open_containing(location)
 
2789
            dir, relpath = controldir.ControlDir.open_containing(location)
2531
2790
            b = dir.open_branch()
2532
2791
            self.add_cleanup(b.lock_read().unlock)
2533
2792
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2592
2851
            match_dict['author'] = match_author
2593
2852
        if match_bugs:
2594
2853
            match_dict['bugs'] = match_bugs
2595
 
            
 
2854
 
2596
2855
        # Build the LogRequest and execute it
2597
2856
        if len(file_ids) == 0:
2598
2857
            file_ids = None
2602
2861
            message_search=message, delta_type=delta_type,
2603
2862
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2604
2863
            exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
2605
 
            signature=signatures
 
2864
            signature=signatures, omit_merges=omit_merges,
2606
2865
            )
2607
2866
        Logger(b, rqst).show(lf)
2608
2867
 
2625
2884
            # b is taken from revision[0].get_branch(), and
2626
2885
            # show_log will use its revision_history. Having
2627
2886
            # different branches will lead to weird behaviors.
2628
 
            raise errors.BzrCommandError(
 
2887
            raise errors.BzrCommandError(gettext(
2629
2888
                "bzr %s doesn't accept two revisions in different"
2630
 
                " branches." % command_name)
 
2889
                " branches.") % command_name)
2631
2890
        if start_spec.spec is None:
2632
2891
            # Avoid loading all the history.
2633
2892
            rev1 = RevisionInfo(branch, None, None)
2641
2900
        else:
2642
2901
            rev2 = end_spec.in_history(branch)
2643
2902
    else:
2644
 
        raise errors.BzrCommandError(
2645
 
            'bzr %s --revision takes one or two values.' % command_name)
 
2903
        raise errors.BzrCommandError(gettext(
 
2904
            'bzr %s --revision takes one or two values.') % command_name)
2646
2905
    return rev1, rev2
2647
2906
 
2648
2907
 
2719
2978
            null=False, kind=None, show_ids=False, path=None, directory=None):
2720
2979
 
2721
2980
        if kind and kind not in ('file', 'directory', 'symlink'):
2722
 
            raise errors.BzrCommandError('invalid kind specified')
 
2981
            raise errors.BzrCommandError(gettext('invalid kind specified'))
2723
2982
 
2724
2983
        if verbose and null:
2725
 
            raise errors.BzrCommandError('Cannot set both --verbose and --null')
 
2984
            raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2726
2985
        all = not (unknown or versioned or ignored)
2727
2986
 
2728
2987
        selection = {'I':ignored, '?':unknown, 'V':versioned}
2731
2990
            fs_path = '.'
2732
2991
        else:
2733
2992
            if from_root:
2734
 
                raise errors.BzrCommandError('cannot specify both --from-root'
2735
 
                                             ' and PATH')
 
2993
                raise errors.BzrCommandError(gettext('cannot specify both --from-root'
 
2994
                                             ' and PATH'))
2736
2995
            fs_path = path
2737
2996
        tree, branch, relpath = \
2738
2997
            _open_directory_or_containing_tree_or_branch(fs_path, directory)
2754
3013
            if view_files:
2755
3014
                apply_view = True
2756
3015
                view_str = views.view_display_str(view_files)
2757
 
                note("Ignoring files outside view. View is %s" % view_str)
 
3016
                note(gettext("Ignoring files outside view. View is %s") % view_str)
2758
3017
 
2759
3018
        self.add_cleanup(tree.lock_read().unlock)
2760
3019
        for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2907
3166
                self.outf.write("%s\n" % pattern)
2908
3167
            return
2909
3168
        if not name_pattern_list:
2910
 
            raise errors.BzrCommandError("ignore requires at least one "
2911
 
                "NAME_PATTERN or --default-rules.")
 
3169
            raise errors.BzrCommandError(gettext("ignore requires at least one "
 
3170
                "NAME_PATTERN or --default-rules."))
2912
3171
        name_pattern_list = [globbing.normalize_pattern(p)
2913
3172
                             for p in name_pattern_list]
2914
3173
        bad_patterns = ''
 
3174
        bad_patterns_count = 0
2915
3175
        for p in name_pattern_list:
2916
3176
            if not globbing.Globster.is_pattern_valid(p):
 
3177
                bad_patterns_count += 1
2917
3178
                bad_patterns += ('\n  %s' % p)
2918
3179
        if bad_patterns:
2919
 
            msg = ('Invalid ignore pattern(s) found. %s' % bad_patterns)
 
3180
            msg = (ngettext('Invalid ignore pattern found. %s', 
 
3181
                            'Invalid ignore patterns found. %s',
 
3182
                            bad_patterns_count) % bad_patterns)
2920
3183
            ui.ui_factory.show_error(msg)
2921
3184
            raise errors.InvalidPattern('')
2922
3185
        for name_pattern in name_pattern_list:
2923
3186
            if (name_pattern[0] == '/' or
2924
3187
                (len(name_pattern) > 1 and name_pattern[1] == ':')):
2925
 
                raise errors.BzrCommandError(
2926
 
                    "NAME_PATTERN should not be an absolute path")
 
3188
                raise errors.BzrCommandError(gettext(
 
3189
                    "NAME_PATTERN should not be an absolute path"))
2927
3190
        tree, relpath = WorkingTree.open_containing(directory)
2928
3191
        ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2929
3192
        ignored = globbing.Globster(name_pattern_list)
2936
3199
                if ignored.match(filename):
2937
3200
                    matches.append(filename)
2938
3201
        if len(matches) > 0:
2939
 
            self.outf.write("Warning: the following files are version controlled and"
2940
 
                  " match your ignore pattern:\n%s"
 
3202
            self.outf.write(gettext("Warning: the following files are version "
 
3203
                  "controlled and match your ignore pattern:\n%s"
2941
3204
                  "\nThese files will continue to be version controlled"
2942
 
                  " unless you 'bzr remove' them.\n" % ("\n".join(matches),))
 
3205
                  " unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2943
3206
 
2944
3207
 
2945
3208
class cmd_ignored(Command):
2984
3247
        try:
2985
3248
            revno = int(revno)
2986
3249
        except ValueError:
2987
 
            raise errors.BzrCommandError("not a valid revision-number: %r"
 
3250
            raise errors.BzrCommandError(gettext("not a valid revision-number: %r")
2988
3251
                                         % revno)
2989
3252
        revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
2990
3253
        self.outf.write("%s\n" % revid)
3033
3296
        Option('per-file-timestamps',
3034
3297
               help='Set modification time of files to that of the last '
3035
3298
                    'revision in which it was changed.'),
 
3299
        Option('uncommitted',
 
3300
               help='Export the working tree contents rather than that of the '
 
3301
                    'last revision.'),
3036
3302
        ]
3037
3303
    def run(self, dest, branch_or_subdir=None, revision=None, format=None,
3038
 
        root=None, filters=False, per_file_timestamps=False, directory=u'.'):
 
3304
        root=None, filters=False, per_file_timestamps=False, uncommitted=False,
 
3305
        directory=u'.'):
3039
3306
        from bzrlib.export import export
3040
3307
 
3041
3308
        if branch_or_subdir is None:
3042
 
            tree = WorkingTree.open_containing(directory)[0]
3043
 
            b = tree.branch
3044
 
            subdir = None
 
3309
            branch_or_subdir = directory
 
3310
 
 
3311
        (tree, b, subdir) = controldir.ControlDir.open_containing_tree_or_branch(
 
3312
            branch_or_subdir)
 
3313
        if tree is not None:
 
3314
            self.add_cleanup(tree.lock_read().unlock)
 
3315
 
 
3316
        if uncommitted:
 
3317
            if tree is None:
 
3318
                raise errors.BzrCommandError(
 
3319
                    gettext("--uncommitted requires a working tree"))
 
3320
            export_tree = tree
3045
3321
        else:
3046
 
            b, subdir = Branch.open_containing(branch_or_subdir)
3047
 
            tree = None
3048
 
 
3049
 
        rev_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
 
3322
            export_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
3050
3323
        try:
3051
 
            export(rev_tree, dest, format, root, subdir, filtered=filters,
 
3324
            export(export_tree, dest, format, root, subdir, filtered=filters,
3052
3325
                   per_file_timestamps=per_file_timestamps)
3053
3326
        except errors.NoSuchExportFormat, e:
3054
 
            raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
 
3327
            raise errors.BzrCommandError(
 
3328
                gettext('Unsupported export format: %s') % e.format)
3055
3329
 
3056
3330
 
3057
3331
class cmd_cat(Command):
3077
3351
    def run(self, filename, revision=None, name_from_revision=False,
3078
3352
            filters=False, directory=None):
3079
3353
        if revision is not None and len(revision) != 1:
3080
 
            raise errors.BzrCommandError("bzr cat --revision takes exactly"
3081
 
                                         " one revision specifier")
 
3354
            raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
 
3355
                                         " one revision specifier"))
3082
3356
        tree, branch, relpath = \
3083
3357
            _open_directory_or_containing_tree_or_branch(filename, directory)
3084
3358
        self.add_cleanup(branch.lock_read().unlock)
3101
3375
        if name_from_revision:
3102
3376
            # Try in revision if requested
3103
3377
            if old_file_id is None:
3104
 
                raise errors.BzrCommandError(
3105
 
                    "%r is not present in revision %s" % (
 
3378
                raise errors.BzrCommandError(gettext(
 
3379
                    "{0!r} is not present in revision {1}").format(
3106
3380
                        filename, rev_tree.get_revision_id()))
3107
3381
            else:
3108
3382
                actual_file_id = old_file_id
3113
3387
            elif old_file_id is not None:
3114
3388
                actual_file_id = old_file_id
3115
3389
            else:
3116
 
                raise errors.BzrCommandError(
3117
 
                    "%r is not present in revision %s" % (
 
3390
                raise errors.BzrCommandError(gettext(
 
3391
                    "{0!r} is not present in revision {1}").format(
3118
3392
                        filename, rev_tree.get_revision_id()))
3119
3393
        if filtered:
3120
3394
            from bzrlib.filter_tree import ContentFilterTree
3237
3511
    aliases = ['ci', 'checkin']
3238
3512
 
3239
3513
    def _iter_bug_fix_urls(self, fixes, branch):
 
3514
        default_bugtracker  = None
3240
3515
        # Configure the properties for bug fixing attributes.
3241
3516
        for fixed_bug in fixes:
3242
3517
            tokens = fixed_bug.split(':')
3243
 
            if len(tokens) != 2:
3244
 
                raise errors.BzrCommandError(
 
3518
            if len(tokens) == 1:
 
3519
                if default_bugtracker is None:
 
3520
                    branch_config = branch.get_config()
 
3521
                    default_bugtracker = branch_config.get_user_option(
 
3522
                        "bugtracker")
 
3523
                if default_bugtracker is None:
 
3524
                    raise errors.BzrCommandError(gettext(
 
3525
                        "No tracker specified for bug %s. Use the form "
 
3526
                        "'tracker:id' or specify a default bug tracker "
 
3527
                        "using the `bugtracker` option.\nSee "
 
3528
                        "\"bzr help bugs\" for more information on this "
 
3529
                        "feature. Commit refused.") % fixed_bug)
 
3530
                tag = default_bugtracker
 
3531
                bug_id = tokens[0]
 
3532
            elif len(tokens) != 2:
 
3533
                raise errors.BzrCommandError(gettext(
3245
3534
                    "Invalid bug %s. Must be in the form of 'tracker:id'. "
3246
3535
                    "See \"bzr help bugs\" for more information on this "
3247
 
                    "feature.\nCommit refused." % fixed_bug)
3248
 
            tag, bug_id = tokens
 
3536
                    "feature.\nCommit refused.") % fixed_bug)
 
3537
            else:
 
3538
                tag, bug_id = tokens
3249
3539
            try:
3250
3540
                yield bugtracker.get_bug_url(tag, branch, bug_id)
3251
3541
            except errors.UnknownBugTrackerAbbreviation:
3252
 
                raise errors.BzrCommandError(
3253
 
                    'Unrecognized bug %s. Commit refused.' % fixed_bug)
 
3542
                raise errors.BzrCommandError(gettext(
 
3543
                    'Unrecognized bug %s. Commit refused.') % fixed_bug)
3254
3544
            except errors.MalformedBugIdentifier, e:
3255
 
                raise errors.BzrCommandError(
3256
 
                    "%s\nCommit refused." % (str(e),))
 
3545
                raise errors.BzrCommandError(gettext(
 
3546
                    "%s\nCommit refused.") % (str(e),))
3257
3547
 
3258
3548
    def run(self, message=None, file=None, verbose=False, selected_list=None,
3259
3549
            unchanged=False, strict=False, local=False, fixes=None,
3276
3566
            try:
3277
3567
                commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3278
3568
            except ValueError, e:
3279
 
                raise errors.BzrCommandError(
3280
 
                    "Could not parse --commit-time: " + str(e))
 
3569
                raise errors.BzrCommandError(gettext(
 
3570
                    "Could not parse --commit-time: " + str(e)))
3281
3571
 
3282
3572
        properties = {}
3283
3573
 
3316
3606
                message = message.replace('\r\n', '\n')
3317
3607
                message = message.replace('\r', '\n')
3318
3608
            if file:
3319
 
                raise errors.BzrCommandError(
3320
 
                    "please specify either --message or --file")
 
3609
                raise errors.BzrCommandError(gettext(
 
3610
                    "please specify either --message or --file"))
3321
3611
 
3322
3612
        def get_message(commit_obj):
3323
3613
            """Callback to get commit message"""
3346
3636
                    my_message = edit_commit_message_encoded(text,
3347
3637
                        start_message=start_message)
3348
3638
                if my_message is None:
3349
 
                    raise errors.BzrCommandError("please specify a commit"
3350
 
                        " message with either --message or --file")
 
3639
                    raise errors.BzrCommandError(gettext("please specify a commit"
 
3640
                        " message with either --message or --file"))
3351
3641
                if my_message == "":
3352
 
                    raise errors.BzrCommandError("Empty commit message specified."
 
3642
                    raise errors.BzrCommandError(gettext("Empty commit message specified."
3353
3643
                            " Please specify a commit message with either"
3354
3644
                            " --message or --file or leave a blank message"
3355
 
                            " with --message \"\".")
 
3645
                            " with --message \"\"."))
3356
3646
            return my_message
3357
3647
 
3358
3648
        # The API permits a commit with a filter of [] to mean 'select nothing'
3369
3659
                        exclude=tree.safe_relpath_files(exclude),
3370
3660
                        lossy=lossy)
3371
3661
        except PointlessCommit:
3372
 
            raise errors.BzrCommandError("No changes to commit."
 
3662
            raise errors.BzrCommandError(gettext("No changes to commit."
3373
3663
                " Please 'bzr add' the files you want to commit, or use"
3374
 
                " --unchanged to force an empty commit.")
 
3664
                " --unchanged to force an empty commit."))
3375
3665
        except ConflictsInTree:
3376
 
            raise errors.BzrCommandError('Conflicts detected in working '
 
3666
            raise errors.BzrCommandError(gettext('Conflicts detected in working '
3377
3667
                'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
3378
 
                ' resolve.')
 
3668
                ' resolve.'))
3379
3669
        except StrictCommitFailed:
3380
 
            raise errors.BzrCommandError("Commit refused because there are"
3381
 
                              " unknown files in the working tree.")
 
3670
            raise errors.BzrCommandError(gettext("Commit refused because there are"
 
3671
                              " unknown files in the working tree."))
3382
3672
        except errors.BoundBranchOutOfDate, e:
3383
 
            e.extra_help = ("\n"
 
3673
            e.extra_help = (gettext("\n"
3384
3674
                'To commit to master branch, run update and then commit.\n'
3385
3675
                'You can also pass --local to commit to continue working '
3386
 
                'disconnected.')
 
3676
                'disconnected.'))
3387
3677
            raise
3388
3678
 
3389
3679
 
3496
3786
        RegistryOption('format',
3497
3787
            help='Upgrade to a specific format.  See "bzr help'
3498
3788
                 ' formats" for details.',
3499
 
            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3500
 
            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
3789
            lazy_registry=('bzrlib.controldir', 'format_registry'),
 
3790
            converter=lambda name: controldir.format_registry.make_bzrdir(name),
3501
3791
            value_switches=True, title='Branch format'),
3502
3792
        Option('clean',
3503
3793
            help='Remove the backup.bzr directory if successful.'),
3544
3834
            if directory is None:
3545
3835
                # use branch if we're inside one; otherwise global config
3546
3836
                try:
3547
 
                    c = Branch.open_containing(u'.')[0].get_config()
 
3837
                    c = Branch.open_containing(u'.')[0].get_config_stack()
3548
3838
                except errors.NotBranchError:
3549
 
                    c = _mod_config.GlobalConfig()
 
3839
                    c = _mod_config.GlobalStack()
3550
3840
            else:
3551
 
                c = Branch.open(directory).get_config()
 
3841
                c = Branch.open(directory).get_config_stack()
 
3842
            identity = c.get('email')
3552
3843
            if email:
3553
 
                self.outf.write(c.user_email() + '\n')
 
3844
                self.outf.write(_mod_config.extract_email_address(identity)
 
3845
                                + '\n')
3554
3846
            else:
3555
 
                self.outf.write(c.username() + '\n')
 
3847
                self.outf.write(identity + '\n')
3556
3848
            return
3557
3849
 
3558
3850
        if email:
3559
 
            raise errors.BzrCommandError("--email can only be used to display existing "
3560
 
                                         "identity")
 
3851
            raise errors.BzrCommandError(gettext("--email can only be used to display existing "
 
3852
                                         "identity"))
3561
3853
 
3562
3854
        # display a warning if an email address isn't included in the given name.
3563
3855
        try:
3569
3861
        # use global config unless --branch given
3570
3862
        if branch:
3571
3863
            if directory is None:
3572
 
                c = Branch.open_containing(u'.')[0].get_config()
 
3864
                c = Branch.open_containing(u'.')[0].get_config_stack()
3573
3865
            else:
3574
 
                c = Branch.open(directory).get_config()
 
3866
                c = Branch.open(directory).get_config_stack()
3575
3867
        else:
3576
 
            c = _mod_config.GlobalConfig()
3577
 
        c.set_user_option('email', name)
 
3868
            c = _mod_config.GlobalStack()
 
3869
        c.set('email', name)
3578
3870
 
3579
3871
 
3580
3872
class cmd_nick(Command):
3581
3873
    __doc__ = """Print or set the branch nickname.
3582
3874
 
3583
 
    If unset, the tree root directory name is used as the nickname.
3584
 
    To print the current nickname, execute with no argument.
 
3875
    If unset, the colocated branch name is used for colocated branches, and
 
3876
    the branch directory name is used for other branches.  To print the
 
3877
    current nickname, execute with no argument.
3585
3878
 
3586
3879
    Bound branches use the nickname of its master branch unless it is set
3587
3880
    locally.
3642
3935
 
3643
3936
    def remove_alias(self, alias_name):
3644
3937
        if alias_name is None:
3645
 
            raise errors.BzrCommandError(
3646
 
                'bzr alias --remove expects an alias to remove.')
 
3938
            raise errors.BzrCommandError(gettext(
 
3939
                'bzr alias --remove expects an alias to remove.'))
3647
3940
        # If alias is not found, print something like:
3648
3941
        # unalias: foo: not found
3649
3942
        c = _mod_config.GlobalConfig()
3787
4080
                                param_name='starting_with', short_name='s',
3788
4081
                                help=
3789
4082
                                'Load only the tests starting with TESTID.'),
 
4083
                     Option('sync',
 
4084
                            help="By default we disable fsync and fdatasync"
 
4085
                                 " while running the test suite.")
3790
4086
                     ]
3791
4087
    encoding_type = 'replace'
3792
4088
 
3800
4096
            first=False, list_only=False,
3801
4097
            randomize=None, exclude=None, strict=False,
3802
4098
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3803
 
            parallel=None, lsprof_tests=False):
 
4099
            parallel=None, lsprof_tests=False,
 
4100
            sync=False):
 
4101
 
 
4102
        # During selftest, disallow proxying, as it can cause severe
 
4103
        # performance penalties and is only needed for thread
 
4104
        # safety. The selftest command is assumed to not use threads
 
4105
        # too heavily. The call should be as early as possible, as
 
4106
        # error reporting for past duplicate imports won't have useful
 
4107
        # backtraces.
 
4108
        lazy_import.disallow_proxying()
 
4109
 
3804
4110
        from bzrlib import tests
3805
4111
 
3806
4112
        if testspecs_list is not None:
3811
4117
            try:
3812
4118
                from bzrlib.tests import SubUnitBzrRunner
3813
4119
            except ImportError:
3814
 
                raise errors.BzrCommandError("subunit not available. subunit "
3815
 
                    "needs to be installed to use --subunit.")
 
4120
                raise errors.BzrCommandError(gettext("subunit not available. subunit "
 
4121
                    "needs to be installed to use --subunit."))
3816
4122
            self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3817
4123
            # On Windows, disable automatic conversion of '\n' to '\r\n' in
3818
4124
            # stdout, which would corrupt the subunit stream. 
3827
4133
            self.additional_selftest_args.setdefault(
3828
4134
                'suite_decorators', []).append(parallel)
3829
4135
        if benchmark:
3830
 
            raise errors.BzrCommandError(
 
4136
            raise errors.BzrCommandError(gettext(
3831
4137
                "--benchmark is no longer supported from bzr 2.2; "
3832
 
                "use bzr-usertest instead")
 
4138
                "use bzr-usertest instead"))
3833
4139
        test_suite_factory = None
3834
4140
        if not exclude:
3835
4141
            exclude_pattern = None
3836
4142
        else:
3837
4143
            exclude_pattern = '(' + '|'.join(exclude) + ')'
 
4144
        if not sync:
 
4145
            self._disable_fsync()
3838
4146
        selftest_kwargs = {"verbose": verbose,
3839
4147
                          "pattern": pattern,
3840
4148
                          "stop_on_failure": one,
3862
4170
            cleanup()
3863
4171
        return int(not result)
3864
4172
 
 
4173
    def _disable_fsync(self):
 
4174
        """Change the 'os' functionality to not synchronize."""
 
4175
        self._orig_fsync = getattr(os, 'fsync', None)
 
4176
        if self._orig_fsync is not None:
 
4177
            os.fsync = lambda filedes: None
 
4178
        self._orig_fdatasync = getattr(os, 'fdatasync', None)
 
4179
        if self._orig_fdatasync is not None:
 
4180
            os.fdatasync = lambda filedes: None
 
4181
 
3865
4182
 
3866
4183
class cmd_version(Command):
3867
4184
    __doc__ = """Show version of bzr."""
3887
4204
 
3888
4205
    @display_command
3889
4206
    def run(self):
3890
 
        self.outf.write("It sure does!\n")
 
4207
        self.outf.write(gettext("It sure does!\n"))
3891
4208
 
3892
4209
 
3893
4210
class cmd_find_merge_base(Command):
3911
4228
        graph = branch1.repository.get_graph(branch2.repository)
3912
4229
        base_rev_id = graph.find_unique_lca(last1, last2)
3913
4230
 
3914
 
        self.outf.write('merge base is revision %s\n' % base_rev_id)
 
4231
        self.outf.write(gettext('merge base is revision %s\n') % base_rev_id)
3915
4232
 
3916
4233
 
3917
4234
class cmd_merge(Command):
3945
4262
    Merge will do its best to combine the changes in two branches, but there
3946
4263
    are some kinds of problems only a human can fix.  When it encounters those,
3947
4264
    it will mark a conflict.  A conflict means that you need to fix something,
3948
 
    before you should commit.
 
4265
    before you can commit.
3949
4266
 
3950
4267
    Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
3951
4268
 
3952
4269
    If there is no default branch set, the first merge will set it (use
3953
 
    --no-remember to avoid settting it). After that, you can omit the branch
 
4270
    --no-remember to avoid setting it). After that, you can omit the branch
3954
4271
    to use the default.  To change the default, use --remember. The value will
3955
4272
    only be saved if the remote location can be accessed.
3956
4273
 
4042
4359
 
4043
4360
        tree = WorkingTree.open_containing(directory)[0]
4044
4361
        if tree.branch.revno() == 0:
4045
 
            raise errors.BzrCommandError('Merging into empty branches not currently supported, '
4046
 
                                         'https://bugs.launchpad.net/bzr/+bug/308562')
 
4362
            raise errors.BzrCommandError(gettext('Merging into empty branches not currently supported, '
 
4363
                                         'https://bugs.launchpad.net/bzr/+bug/308562'))
4047
4364
 
4048
4365
        try:
4049
4366
            basis_tree = tree.revision_tree(tree.last_revision())
4069
4386
                mergeable = None
4070
4387
            else:
4071
4388
                if uncommitted:
4072
 
                    raise errors.BzrCommandError('Cannot use --uncommitted'
4073
 
                        ' with bundles or merge directives.')
 
4389
                    raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
 
4390
                        ' with bundles or merge directives.'))
4074
4391
 
4075
4392
                if revision is not None:
4076
 
                    raise errors.BzrCommandError(
4077
 
                        'Cannot use -r with merge directives or bundles')
 
4393
                    raise errors.BzrCommandError(gettext(
 
4394
                        'Cannot use -r with merge directives or bundles'))
4078
4395
                merger, verified = _mod_merge.Merger.from_mergeable(tree,
4079
4396
                   mergeable, None)
4080
4397
 
4081
4398
        if merger is None and uncommitted:
4082
4399
            if revision is not None and len(revision) > 0:
4083
 
                raise errors.BzrCommandError('Cannot use --uncommitted and'
4084
 
                    ' --revision at the same time.')
 
4400
                raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
 
4401
                    ' --revision at the same time.'))
4085
4402
            merger = self.get_merger_from_uncommitted(tree, location, None)
4086
4403
            allow_pending = False
4087
4404
 
4100
4417
            if merger.interesting_files:
4101
4418
                if not merger.other_tree.has_filename(
4102
4419
                    merger.interesting_files[0]):
4103
 
                    note("merger: " + str(merger))
 
4420
                    note(gettext("merger: ") + str(merger))
4104
4421
                    raise errors.PathsDoNotExist([location])
4105
 
            note('Nothing to do.')
 
4422
            note(gettext('Nothing to do.'))
4106
4423
            return 0
4107
4424
        if pull and not preview:
4108
4425
            if merger.interesting_files is not None:
4109
 
                raise errors.BzrCommandError('Cannot pull individual files')
 
4426
                raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4110
4427
            if (merger.base_rev_id == tree.last_revision()):
4111
4428
                result = tree.pull(merger.other_branch, False,
4112
4429
                                   merger.other_rev_id)
4113
4430
                result.report(self.outf)
4114
4431
                return 0
4115
4432
        if merger.this_basis is None:
4116
 
            raise errors.BzrCommandError(
 
4433
            raise errors.BzrCommandError(gettext(
4117
4434
                "This branch has no commits."
4118
 
                " (perhaps you would prefer 'bzr pull')")
 
4435
                " (perhaps you would prefer 'bzr pull')"))
4119
4436
        if preview:
4120
4437
            return self._do_preview(merger)
4121
4438
        elif interactive:
4172
4489
    def sanity_check_merger(self, merger):
4173
4490
        if (merger.show_base and
4174
4491
            not merger.merge_type is _mod_merge.Merge3Merger):
4175
 
            raise errors.BzrCommandError("Show-base is not supported for this"
4176
 
                                         " merge type. %s" % merger.merge_type)
 
4492
            raise errors.BzrCommandError(gettext("Show-base is not supported for this"
 
4493
                                         " merge type. %s") % merger.merge_type)
4177
4494
        if merger.reprocess is None:
4178
4495
            if merger.show_base:
4179
4496
                merger.reprocess = False
4181
4498
                # Use reprocess if the merger supports it
4182
4499
                merger.reprocess = merger.merge_type.supports_reprocess
4183
4500
        if merger.reprocess and not merger.merge_type.supports_reprocess:
4184
 
            raise errors.BzrCommandError("Conflict reduction is not supported"
4185
 
                                         " for merge type %s." %
 
4501
            raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
 
4502
                                         " for merge type %s.") %
4186
4503
                                         merger.merge_type)
4187
4504
        if merger.reprocess and merger.show_base:
4188
 
            raise errors.BzrCommandError("Cannot do conflict reduction and"
4189
 
                                         " show base.")
 
4505
            raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
 
4506
                                         " show base."))
4190
4507
 
4191
4508
    def _get_merger_from_branch(self, tree, location, revision, remember,
4192
4509
                                possible_transports, pb):
4296
4613
            stored_location_type = "parent"
4297
4614
        mutter("%s", stored_location)
4298
4615
        if stored_location is None:
4299
 
            raise errors.BzrCommandError("No location specified or remembered")
 
4616
            raise errors.BzrCommandError(gettext("No location specified or remembered"))
4300
4617
        display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4301
 
        note(u"%s remembered %s location %s", verb_string,
4302
 
                stored_location_type, display_url)
 
4618
        note(gettext("{0} remembered {1} location {2}").format(verb_string,
 
4619
                stored_location_type, display_url))
4303
4620
        return stored_location
4304
4621
 
4305
4622
 
4342
4659
        self.add_cleanup(tree.lock_write().unlock)
4343
4660
        parents = tree.get_parent_ids()
4344
4661
        if len(parents) != 2:
4345
 
            raise errors.BzrCommandError("Sorry, remerge only works after normal"
 
4662
            raise errors.BzrCommandError(gettext("Sorry, remerge only works after normal"
4346
4663
                                         " merges.  Not cherrypicking or"
4347
 
                                         " multi-merges.")
 
4664
                                         " multi-merges."))
4348
4665
        repository = tree.branch.repository
4349
4666
        interesting_ids = None
4350
4667
        new_conflicts = []
4509
4826
 
4510
4827
    @display_command
4511
4828
    def run(self, context=None):
4512
 
        import shellcomplete
 
4829
        from bzrlib import shellcomplete
4513
4830
        shellcomplete.shellcomplete(context)
4514
4831
 
4515
4832
 
4569
4886
            type=_parse_revision_str,
4570
4887
            help='Filter on local branch revisions (inclusive). '
4571
4888
                'See "help revisionspec" for details.'),
4572
 
        Option('include-merges',
 
4889
        Option('include-merged',
4573
4890
               'Show all revisions in addition to the mainline ones.'),
 
4891
        Option('include-merges', hidden=True,
 
4892
               help='Historical alias for --include-merged.'),
4574
4893
        ]
4575
4894
    encoding_type = 'replace'
4576
4895
 
4579
4898
            theirs_only=False,
4580
4899
            log_format=None, long=False, short=False, line=False,
4581
4900
            show_ids=False, verbose=False, this=False, other=False,
4582
 
            include_merges=False, revision=None, my_revision=None,
4583
 
            directory=u'.'):
 
4901
            include_merged=None, revision=None, my_revision=None,
 
4902
            directory=u'.',
 
4903
            include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4584
4904
        from bzrlib.missing import find_unmerged, iter_log_revisions
4585
4905
        def message(s):
4586
4906
            if not is_quiet():
4587
4907
                self.outf.write(s)
4588
4908
 
 
4909
        if symbol_versioning.deprecated_passed(include_merges):
 
4910
            ui.ui_factory.show_user_warning(
 
4911
                'deprecated_command_option',
 
4912
                deprecated_name='--include-merges',
 
4913
                recommended_name='--include-merged',
 
4914
                deprecated_in_version='2.5',
 
4915
                command=self.invoked_as)
 
4916
            if include_merged is None:
 
4917
                include_merged = include_merges
 
4918
            else:
 
4919
                raise errors.BzrCommandError(gettext(
 
4920
                    '{0} and {1} are mutually exclusive').format(
 
4921
                    '--include-merges', '--include-merged'))
 
4922
        if include_merged is None:
 
4923
            include_merged = False
4589
4924
        if this:
4590
4925
            mine_only = this
4591
4926
        if other:
4606
4941
        if other_branch is None:
4607
4942
            other_branch = parent
4608
4943
            if other_branch is None:
4609
 
                raise errors.BzrCommandError("No peer location known"
4610
 
                                             " or specified.")
 
4944
                raise errors.BzrCommandError(gettext("No peer location known"
 
4945
                                             " or specified."))
4611
4946
            display_url = urlutils.unescape_for_display(parent,
4612
4947
                                                        self.outf.encoding)
4613
 
            message("Using saved parent location: "
4614
 
                    + display_url + "\n")
 
4948
            message(gettext("Using saved parent location: {0}\n").format(
 
4949
                    display_url))
4615
4950
 
4616
4951
        remote_branch = Branch.open(other_branch)
4617
4952
        if remote_branch.base == local_branch.base:
4630
4965
        local_extra, remote_extra = find_unmerged(
4631
4966
            local_branch, remote_branch, restrict,
4632
4967
            backward=not reverse,
4633
 
            include_merges=include_merges,
 
4968
            include_merged=include_merged,
4634
4969
            local_revid_range=local_revid_range,
4635
4970
            remote_revid_range=remote_revid_range)
4636
4971
 
4643
4978
 
4644
4979
        status_code = 0
4645
4980
        if local_extra and not theirs_only:
4646
 
            message("You have %d extra revision(s):\n" %
 
4981
            message(ngettext("You have %d extra revision:\n",
 
4982
                             "You have %d extra revisions:\n", 
 
4983
                             len(local_extra)) %
4647
4984
                len(local_extra))
4648
4985
            for revision in iter_log_revisions(local_extra,
4649
4986
                                local_branch.repository,
4657
4994
        if remote_extra and not mine_only:
4658
4995
            if printed_local is True:
4659
4996
                message("\n\n\n")
4660
 
            message("You are missing %d revision(s):\n" %
 
4997
            message(ngettext("You are missing %d revision:\n",
 
4998
                             "You are missing %d revisions:\n",
 
4999
                             len(remote_extra)) %
4661
5000
                len(remote_extra))
4662
5001
            for revision in iter_log_revisions(remote_extra,
4663
5002
                                remote_branch.repository,
4667
5006
 
4668
5007
        if mine_only and not local_extra:
4669
5008
            # We checked local, and found nothing extra
4670
 
            message('This branch is up to date.\n')
 
5009
            message(gettext('This branch has no new revisions.\n'))
4671
5010
        elif theirs_only and not remote_extra:
4672
5011
            # We checked remote, and found nothing extra
4673
 
            message('Other branch is up to date.\n')
 
5012
            message(gettext('Other branch has no new revisions.\n'))
4674
5013
        elif not (mine_only or theirs_only or local_extra or
4675
5014
                  remote_extra):
4676
5015
            # We checked both branches, and neither one had extra
4677
5016
            # revisions
4678
 
            message("Branches are up to date.\n")
 
5017
            message(gettext("Branches are up to date.\n"))
4679
5018
        self.cleanup_now()
4680
5019
        if not status_code and parent is None and other_branch is not None:
4681
5020
            self.add_cleanup(local_branch.lock_write().unlock)
4711
5050
        ]
4712
5051
 
4713
5052
    def run(self, branch_or_repo='.', clean_obsolete_packs=False):
4714
 
        dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
 
5053
        dir = controldir.ControlDir.open_containing(branch_or_repo)[0]
4715
5054
        try:
4716
5055
            branch = dir.open_branch()
4717
5056
            repository = branch.repository
4842
5181
 
4843
5182
    def run(self, revision_id_list=None, revision=None, directory=u'.'):
4844
5183
        if revision_id_list is not None and revision is not None:
4845
 
            raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
 
5184
            raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
4846
5185
        if revision_id_list is None and revision is None:
4847
 
            raise errors.BzrCommandError('You must supply either --revision or a revision_id')
 
5186
            raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
4848
5187
        b = WorkingTree.open_containing(directory)[0].branch
4849
5188
        self.add_cleanup(b.lock_write().unlock)
4850
5189
        return self._run(b, revision_id_list, revision)
4851
5190
 
4852
5191
    def _run(self, b, revision_id_list, revision):
4853
5192
        import bzrlib.gpg as gpg
4854
 
        gpg_strategy = gpg.GPGStrategy(b.get_config())
 
5193
        gpg_strategy = gpg.GPGStrategy(b.get_config_stack())
4855
5194
        if revision_id_list is not None:
4856
5195
            b.repository.start_write_group()
4857
5196
            try:
4882
5221
                if to_revid is None:
4883
5222
                    to_revno = b.revno()
4884
5223
                if from_revno is None or to_revno is None:
4885
 
                    raise errors.BzrCommandError('Cannot sign a range of non-revision-history revisions')
 
5224
                    raise errors.BzrCommandError(gettext('Cannot sign a range of non-revision-history revisions'))
4886
5225
                b.repository.start_write_group()
4887
5226
                try:
4888
5227
                    for revno in range(from_revno, to_revno + 1):
4894
5233
                else:
4895
5234
                    b.repository.commit_write_group()
4896
5235
            else:
4897
 
                raise errors.BzrCommandError('Please supply either one revision, or a range.')
 
5236
                raise errors.BzrCommandError(gettext('Please supply either one revision, or a range.'))
4898
5237
 
4899
5238
 
4900
5239
class cmd_bind(Command):
4919
5258
            try:
4920
5259
                location = b.get_old_bound_location()
4921
5260
            except errors.UpgradeRequired:
4922
 
                raise errors.BzrCommandError('No location supplied.  '
4923
 
                    'This format does not remember old locations.')
 
5261
                raise errors.BzrCommandError(gettext('No location supplied.  '
 
5262
                    'This format does not remember old locations.'))
4924
5263
            else:
4925
5264
                if location is None:
4926
5265
                    if b.get_bound_location() is not None:
4927
 
                        raise errors.BzrCommandError('Branch is already bound')
 
5266
                        raise errors.BzrCommandError(gettext('Branch is already bound'))
4928
5267
                    else:
4929
 
                        raise errors.BzrCommandError('No location supplied '
4930
 
                            'and no previous location known')
 
5268
                        raise errors.BzrCommandError(gettext('No location supplied '
 
5269
                            'and no previous location known'))
4931
5270
        b_other = Branch.open(location)
4932
5271
        try:
4933
5272
            b.bind(b_other)
4934
5273
        except errors.DivergedBranches:
4935
 
            raise errors.BzrCommandError('These branches have diverged.'
4936
 
                                         ' Try merging, and then bind again.')
 
5274
            raise errors.BzrCommandError(gettext('These branches have diverged.'
 
5275
                                         ' Try merging, and then bind again.'))
4937
5276
        if b.get_config().has_explicit_nickname():
4938
5277
            b.nick = b_other.nick
4939
5278
 
4952
5291
    def run(self, directory=u'.'):
4953
5292
        b, relpath = Branch.open_containing(directory)
4954
5293
        if not b.unbind():
4955
 
            raise errors.BzrCommandError('Local branch is not bound')
 
5294
            raise errors.BzrCommandError(gettext('Local branch is not bound'))
4956
5295
 
4957
5296
 
4958
5297
class cmd_uncommit(Command):
4979
5318
    takes_options = ['verbose', 'revision',
4980
5319
                    Option('dry-run', help='Don\'t actually make changes.'),
4981
5320
                    Option('force', help='Say yes to all questions.'),
 
5321
                    Option('keep-tags',
 
5322
                           help='Keep tags that point to removed revisions.'),
4982
5323
                    Option('local',
4983
5324
                           help="Only remove the commits from the local branch"
4984
5325
                                " when in a checkout."
4988
5329
    aliases = []
4989
5330
    encoding_type = 'replace'
4990
5331
 
4991
 
    def run(self, location=None,
4992
 
            dry_run=False, verbose=False,
4993
 
            revision=None, force=False, local=False):
 
5332
    def run(self, location=None, dry_run=False, verbose=False,
 
5333
            revision=None, force=False, local=False, keep_tags=False):
4994
5334
        if location is None:
4995
5335
            location = u'.'
4996
 
        control, relpath = bzrdir.BzrDir.open_containing(location)
 
5336
        control, relpath = controldir.ControlDir.open_containing(location)
4997
5337
        try:
4998
5338
            tree = control.open_workingtree()
4999
5339
            b = tree.branch
5005
5345
            self.add_cleanup(tree.lock_write().unlock)
5006
5346
        else:
5007
5347
            self.add_cleanup(b.lock_write().unlock)
5008
 
        return self._run(b, tree, dry_run, verbose, revision, force, local=local)
 
5348
        return self._run(b, tree, dry_run, verbose, revision, force,
 
5349
                         local, keep_tags)
5009
5350
 
5010
 
    def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
 
5351
    def _run(self, b, tree, dry_run, verbose, revision, force, local,
 
5352
             keep_tags):
5011
5353
        from bzrlib.log import log_formatter, show_log
5012
5354
        from bzrlib.uncommit import uncommit
5013
5355
 
5028
5370
                rev_id = b.get_rev_id(revno)
5029
5371
 
5030
5372
        if rev_id is None or _mod_revision.is_null(rev_id):
5031
 
            self.outf.write('No revisions to uncommit.\n')
 
5373
            self.outf.write(gettext('No revisions to uncommit.\n'))
5032
5374
            return 1
5033
5375
 
5034
5376
        lf = log_formatter('short',
5043
5385
                 end_revision=last_revno)
5044
5386
 
5045
5387
        if dry_run:
5046
 
            self.outf.write('Dry-run, pretending to remove'
5047
 
                            ' the above revisions.\n')
 
5388
            self.outf.write(gettext('Dry-run, pretending to remove'
 
5389
                            ' the above revisions.\n'))
5048
5390
        else:
5049
 
            self.outf.write('The above revision(s) will be removed.\n')
 
5391
            self.outf.write(gettext('The above revision(s) will be removed.\n'))
5050
5392
 
5051
5393
        if not force:
5052
5394
            if not ui.ui_factory.confirm_action(
5053
 
                    u'Uncommit these revisions',
 
5395
                    gettext(u'Uncommit these revisions'),
5054
5396
                    'bzrlib.builtins.uncommit',
5055
5397
                    {}):
5056
 
                self.outf.write('Canceled\n')
 
5398
                self.outf.write(gettext('Canceled\n'))
5057
5399
                return 0
5058
5400
 
5059
5401
        mutter('Uncommitting from {%s} to {%s}',
5060
5402
               last_rev_id, rev_id)
5061
5403
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5062
 
                 revno=revno, local=local)
5063
 
        self.outf.write('You can restore the old tip by running:\n'
5064
 
             '  bzr pull . -r revid:%s\n' % last_rev_id)
 
5404
                 revno=revno, local=local, keep_tags=keep_tags)
 
5405
        self.outf.write(gettext('You can restore the old tip by running:\n'
 
5406
             '  bzr pull . -r revid:%s\n') % last_rev_id)
5065
5407
 
5066
5408
 
5067
5409
class cmd_break_lock(Command):
5101
5443
            conf = _mod_config.LockableConfig(file_name=location)
5102
5444
            conf.break_lock()
5103
5445
        else:
5104
 
            control, relpath = bzrdir.BzrDir.open_containing(location)
 
5446
            control, relpath = controldir.ControlDir.open_containing(location)
5105
5447
            try:
5106
5448
                control.break_lock()
5107
5449
            except NotImplementedError:
5151
5493
                    'option leads to global uncontrolled write access to your '
5152
5494
                    'file system.'
5153
5495
                ),
 
5496
        Option('client-timeout', type=float,
 
5497
               help='Override the default idle client timeout (5min).'),
5154
5498
        ]
5155
5499
 
5156
5500
    def get_host_and_port(self, port):
5173
5517
        return host, port
5174
5518
 
5175
5519
    def run(self, port=None, inet=False, directory=None, allow_writes=False,
5176
 
            protocol=None):
 
5520
            protocol=None, client_timeout=None):
5177
5521
        from bzrlib import transport
5178
5522
        if directory is None:
5179
5523
            directory = os.getcwd()
5180
5524
        if protocol is None:
5181
5525
            protocol = transport.transport_server_registry.get()
5182
5526
        host, port = self.get_host_and_port(port)
5183
 
        url = urlutils.local_path_to_url(directory)
 
5527
        url = transport.location_to_url(directory)
5184
5528
        if not allow_writes:
5185
5529
            url = 'readonly+' + url
5186
 
        t = transport.get_transport(url)
5187
 
        protocol(t, host, port, inet)
 
5530
        t = transport.get_transport_from_url(url)
 
5531
        try:
 
5532
            protocol(t, host, port, inet, client_timeout)
 
5533
        except TypeError, e:
 
5534
            # We use symbol_versioning.deprecated_in just so that people
 
5535
            # grepping can find it here.
 
5536
            # symbol_versioning.deprecated_in((2, 5, 0))
 
5537
            symbol_versioning.warn(
 
5538
                'Got TypeError(%s)\ntrying to call protocol: %s.%s\n'
 
5539
                'Most likely it needs to be updated to support a'
 
5540
                ' "timeout" parameter (added in bzr 2.5.0)'
 
5541
                % (e, protocol.__module__, protocol),
 
5542
                DeprecationWarning)
 
5543
            protocol(t, host, port, inet)
5188
5544
 
5189
5545
 
5190
5546
class cmd_join(Command):
5213
5569
        containing_tree = WorkingTree.open_containing(parent_dir)[0]
5214
5570
        repo = containing_tree.branch.repository
5215
5571
        if not repo.supports_rich_root():
5216
 
            raise errors.BzrCommandError(
 
5572
            raise errors.BzrCommandError(gettext(
5217
5573
                "Can't join trees because %s doesn't support rich root data.\n"
5218
 
                "You can use bzr upgrade on the repository."
 
5574
                "You can use bzr upgrade on the repository.")
5219
5575
                % (repo,))
5220
5576
        if reference:
5221
5577
            try:
5223
5579
            except errors.BadReferenceTarget, e:
5224
5580
                # XXX: Would be better to just raise a nicely printable
5225
5581
                # exception from the real origin.  Also below.  mbp 20070306
5226
 
                raise errors.BzrCommandError("Cannot join %s.  %s" %
5227
 
                                             (tree, e.reason))
 
5582
                raise errors.BzrCommandError(
 
5583
                       gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5228
5584
        else:
5229
5585
            try:
5230
5586
                containing_tree.subsume(sub_tree)
5231
5587
            except errors.BadSubsumeSource, e:
5232
 
                raise errors.BzrCommandError("Cannot join %s.  %s" %
5233
 
                                             (tree, e.reason))
 
5588
                raise errors.BzrCommandError(
 
5589
                       gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5234
5590
 
5235
5591
 
5236
5592
class cmd_split(Command):
5320
5676
        if submit_branch is None:
5321
5677
            submit_branch = branch.get_parent()
5322
5678
        if submit_branch is None:
5323
 
            raise errors.BzrCommandError('No submit branch specified or known')
 
5679
            raise errors.BzrCommandError(gettext('No submit branch specified or known'))
5324
5680
 
5325
5681
        stored_public_branch = branch.get_public_branch()
5326
5682
        if public_branch is None:
5328
5684
        elif stored_public_branch is None:
5329
5685
            branch.set_public_branch(public_branch)
5330
5686
        if not include_bundle and public_branch is None:
5331
 
            raise errors.BzrCommandError('No public branch specified or'
5332
 
                                         ' known')
 
5687
            raise errors.BzrCommandError(gettext('No public branch specified or'
 
5688
                                         ' known'))
5333
5689
        base_revision_id = None
5334
5690
        if revision is not None:
5335
5691
            if len(revision) > 2:
5336
 
                raise errors.BzrCommandError('bzr merge-directive takes '
5337
 
                    'at most two one revision identifiers')
 
5692
                raise errors.BzrCommandError(gettext('bzr merge-directive takes '
 
5693
                    'at most two one revision identifiers'))
5338
5694
            revision_id = revision[-1].as_revision_id(branch)
5339
5695
            if len(revision) == 2:
5340
5696
                base_revision_id = revision[0].as_revision_id(branch)
5342
5698
            revision_id = branch.last_revision()
5343
5699
        revision_id = ensure_null(revision_id)
5344
5700
        if revision_id == NULL_REVISION:
5345
 
            raise errors.BzrCommandError('No revisions to bundle.')
 
5701
            raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5346
5702
        directive = merge_directive.MergeDirective2.from_objects(
5347
5703
            branch.repository, revision_id, time.time(),
5348
5704
            osutils.local_time_offset(), submit_branch,
5356
5712
                self.outf.writelines(directive.to_lines())
5357
5713
        else:
5358
5714
            message = directive.to_email(mail_to, branch, sign)
5359
 
            s = SMTPConnection(branch.get_config())
 
5715
            s = SMTPConnection(branch.get_config_stack())
5360
5716
            s.send_email(message)
5361
5717
 
5362
5718
 
5394
5750
 
5395
5751
    Both the submit branch and the public branch follow the usual behavior with
5396
5752
    respect to --remember: If there is no default location set, the first send
5397
 
    will set it (use --no-remember to avoid settting it). After that, you can
 
5753
    will set it (use --no-remember to avoid setting it). After that, you can
5398
5754
    omit the location to use the default.  To change the default, use
5399
5755
    --remember. The value will only be saved if the location can be accessed.
5400
5756
 
5602
5958
        self.add_cleanup(branch.lock_write().unlock)
5603
5959
        if delete:
5604
5960
            if tag_name is None:
5605
 
                raise errors.BzrCommandError("No tag specified to delete.")
 
5961
                raise errors.BzrCommandError(gettext("No tag specified to delete."))
5606
5962
            branch.tags.delete_tag(tag_name)
5607
 
            note('Deleted tag %s.' % tag_name)
 
5963
            note(gettext('Deleted tag %s.') % tag_name)
5608
5964
        else:
5609
5965
            if revision:
5610
5966
                if len(revision) != 1:
5611
 
                    raise errors.BzrCommandError(
 
5967
                    raise errors.BzrCommandError(gettext(
5612
5968
                        "Tags can only be placed on a single revision, "
5613
 
                        "not on a range")
 
5969
                        "not on a range"))
5614
5970
                revision_id = revision[0].as_revision_id(branch)
5615
5971
            else:
5616
5972
                revision_id = branch.last_revision()
5617
5973
            if tag_name is None:
5618
5974
                tag_name = branch.automatic_tag_name(revision_id)
5619
5975
                if tag_name is None:
5620
 
                    raise errors.BzrCommandError(
5621
 
                        "Please specify a tag name.")
5622
 
            if (not force) and branch.tags.has_tag(tag_name):
 
5976
                    raise errors.BzrCommandError(gettext(
 
5977
                        "Please specify a tag name."))
 
5978
            try:
 
5979
                existing_target = branch.tags.lookup_tag(tag_name)
 
5980
            except errors.NoSuchTag:
 
5981
                existing_target = None
 
5982
            if not force and existing_target not in (None, revision_id):
5623
5983
                raise errors.TagAlreadyExists(tag_name)
5624
 
            branch.tags.set_tag(tag_name, revision_id)
5625
 
            note('Created tag %s.' % tag_name)
 
5984
            if existing_target == revision_id:
 
5985
                note(gettext('Tag %s already exists for that revision.') % tag_name)
 
5986
            else:
 
5987
                branch.tags.set_tag(tag_name, revision_id)
 
5988
                if existing_target is None:
 
5989
                    note(gettext('Created tag %s.') % tag_name)
 
5990
                else:
 
5991
                    note(gettext('Updated tag %s.') % tag_name)
5626
5992
 
5627
5993
 
5628
5994
class cmd_tags(Command):
5654
6020
 
5655
6021
        self.add_cleanup(branch.lock_read().unlock)
5656
6022
        if revision:
5657
 
            graph = branch.repository.get_graph()
5658
 
            rev1, rev2 = _get_revision_range(revision, branch, self.name())
5659
 
            revid1, revid2 = rev1.rev_id, rev2.rev_id
5660
 
            # only show revisions between revid1 and revid2 (inclusive)
5661
 
            tags = [(tag, revid) for tag, revid in tags if
5662
 
                graph.is_between(revid, revid1, revid2)]
 
6023
            # Restrict to the specified range
 
6024
            tags = self._tags_for_range(branch, revision)
5663
6025
        if sort is None:
5664
6026
            sort = tag_sort_methods.get()
5665
6027
        sort(branch, tags)
5670
6032
                    revno = branch.revision_id_to_dotted_revno(revid)
5671
6033
                    if isinstance(revno, tuple):
5672
6034
                        revno = '.'.join(map(str, revno))
5673
 
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
 
6035
                except (errors.NoSuchRevision,
 
6036
                        errors.GhostRevisionsHaveNoRevno,
 
6037
                        errors.UnsupportedOperation):
5674
6038
                    # Bad tag data/merges can lead to tagged revisions
5675
6039
                    # which are not in this branch. Fail gracefully ...
5676
6040
                    revno = '?'
5679
6043
        for tag, revspec in tags:
5680
6044
            self.outf.write('%-20s %s\n' % (tag, revspec))
5681
6045
 
 
6046
    def _tags_for_range(self, branch, revision):
 
6047
        range_valid = True
 
6048
        rev1, rev2 = _get_revision_range(revision, branch, self.name())
 
6049
        revid1, revid2 = rev1.rev_id, rev2.rev_id
 
6050
        # _get_revision_range will always set revid2 if it's not specified.
 
6051
        # If revid1 is None, it means we want to start from the branch
 
6052
        # origin which is always a valid ancestor. If revid1 == revid2, the
 
6053
        # ancestry check is useless.
 
6054
        if revid1 and revid1 != revid2:
 
6055
            # FIXME: We really want to use the same graph than
 
6056
            # branch.iter_merge_sorted_revisions below, but this is not
 
6057
            # easily available -- vila 2011-09-23
 
6058
            if branch.repository.get_graph().is_ancestor(revid2, revid1):
 
6059
                # We don't want to output anything in this case...
 
6060
                return []
 
6061
        # only show revisions between revid1 and revid2 (inclusive)
 
6062
        tagged_revids = branch.tags.get_reverse_tag_dict()
 
6063
        found = []
 
6064
        for r in branch.iter_merge_sorted_revisions(
 
6065
            start_revision_id=revid2, stop_revision_id=revid1,
 
6066
            stop_rule='include'):
 
6067
            revid_tags = tagged_revids.get(r[0], None)
 
6068
            if revid_tags:
 
6069
                found.extend([(tag, r[0]) for tag in revid_tags])
 
6070
        return found
 
6071
 
5682
6072
 
5683
6073
class cmd_reconfigure(Command):
5684
6074
    __doc__ = """Reconfigure the type of a bzr directory.
5698
6088
    takes_args = ['location?']
5699
6089
    takes_options = [
5700
6090
        RegistryOption.from_kwargs(
5701
 
            'target_type',
5702
 
            title='Target type',
5703
 
            help='The type to reconfigure the directory to.',
 
6091
            'tree_type',
 
6092
            title='Tree type',
 
6093
            help='The relation between branch and tree.',
5704
6094
            value_switches=True, enum_switch=False,
5705
6095
            branch='Reconfigure to be an unbound branch with no working tree.',
5706
6096
            tree='Reconfigure to be an unbound branch with a working tree.',
5707
6097
            checkout='Reconfigure to be a bound branch with a working tree.',
5708
6098
            lightweight_checkout='Reconfigure to be a lightweight'
5709
6099
                ' checkout (with no local history).',
 
6100
            ),
 
6101
        RegistryOption.from_kwargs(
 
6102
            'repository_type',
 
6103
            title='Repository type',
 
6104
            help='Location fo the repository.',
 
6105
            value_switches=True, enum_switch=False,
5710
6106
            standalone='Reconfigure to be a standalone branch '
5711
6107
                '(i.e. stop using shared repository).',
5712
6108
            use_shared='Reconfigure to use a shared repository.',
 
6109
            ),
 
6110
        RegistryOption.from_kwargs(
 
6111
            'repository_trees',
 
6112
            title='Trees in Repository',
 
6113
            help='Whether new branches in the repository have trees.',
 
6114
            value_switches=True, enum_switch=False,
5713
6115
            with_trees='Reconfigure repository to create '
5714
6116
                'working trees on branches by default.',
5715
6117
            with_no_trees='Reconfigure repository to not create '
5729
6131
            ),
5730
6132
        ]
5731
6133
 
5732
 
    def run(self, location=None, target_type=None, bind_to=None, force=False,
5733
 
            stacked_on=None,
5734
 
            unstacked=None):
5735
 
        directory = bzrdir.BzrDir.open(location)
 
6134
    def run(self, location=None, bind_to=None, force=False,
 
6135
            tree_type=None, repository_type=None, repository_trees=None,
 
6136
            stacked_on=None, unstacked=None):
 
6137
        directory = controldir.ControlDir.open(location)
5736
6138
        if stacked_on and unstacked:
5737
 
            raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
 
6139
            raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5738
6140
        elif stacked_on is not None:
5739
6141
            reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5740
6142
        elif unstacked:
5742
6144
        # At the moment you can use --stacked-on and a different
5743
6145
        # reconfiguration shape at the same time; there seems no good reason
5744
6146
        # to ban it.
5745
 
        if target_type is None:
 
6147
        if (tree_type is None and
 
6148
            repository_type is None and
 
6149
            repository_trees is None):
5746
6150
            if stacked_on or unstacked:
5747
6151
                return
5748
6152
            else:
5749
 
                raise errors.BzrCommandError('No target configuration '
5750
 
                    'specified')
5751
 
        elif target_type == 'branch':
 
6153
                raise errors.BzrCommandError(gettext('No target configuration '
 
6154
                    'specified'))
 
6155
        reconfiguration = None
 
6156
        if tree_type == 'branch':
5752
6157
            reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5753
 
        elif target_type == 'tree':
 
6158
        elif tree_type == 'tree':
5754
6159
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5755
 
        elif target_type == 'checkout':
 
6160
        elif tree_type == 'checkout':
5756
6161
            reconfiguration = reconfigure.Reconfigure.to_checkout(
5757
6162
                directory, bind_to)
5758
 
        elif target_type == 'lightweight-checkout':
 
6163
        elif tree_type == 'lightweight-checkout':
5759
6164
            reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5760
6165
                directory, bind_to)
5761
 
        elif target_type == 'use-shared':
 
6166
        if reconfiguration:
 
6167
            reconfiguration.apply(force)
 
6168
            reconfiguration = None
 
6169
        if repository_type == 'use-shared':
5762
6170
            reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5763
 
        elif target_type == 'standalone':
 
6171
        elif repository_type == 'standalone':
5764
6172
            reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5765
 
        elif target_type == 'with-trees':
 
6173
        if reconfiguration:
 
6174
            reconfiguration.apply(force)
 
6175
            reconfiguration = None
 
6176
        if repository_trees == 'with-trees':
5766
6177
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5767
6178
                directory, True)
5768
 
        elif target_type == 'with-no-trees':
 
6179
        elif repository_trees == 'with-no-trees':
5769
6180
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5770
6181
                directory, False)
5771
 
        reconfiguration.apply(force)
 
6182
        if reconfiguration:
 
6183
            reconfiguration.apply(force)
 
6184
            reconfiguration = None
5772
6185
 
5773
6186
 
5774
6187
class cmd_switch(Command):
5809
6222
        from bzrlib import switch
5810
6223
        tree_location = directory
5811
6224
        revision = _get_one_revision('switch', revision)
5812
 
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
 
6225
        possible_transports = []
 
6226
        control_dir = controldir.ControlDir.open_containing(tree_location,
 
6227
            possible_transports=possible_transports)[0]
5813
6228
        if to_location is None:
5814
6229
            if revision is None:
5815
 
                raise errors.BzrCommandError('You must supply either a'
5816
 
                                             ' revision or a location')
 
6230
                raise errors.BzrCommandError(gettext('You must supply either a'
 
6231
                                             ' revision or a location'))
5817
6232
            to_location = tree_location
5818
6233
        try:
5819
 
            branch = control_dir.open_branch()
 
6234
            branch = control_dir.open_branch(
 
6235
                possible_transports=possible_transports)
5820
6236
            had_explicit_nick = branch.get_config().has_explicit_nickname()
5821
6237
        except errors.NotBranchError:
5822
6238
            branch = None
5823
6239
            had_explicit_nick = False
5824
6240
        if create_branch:
5825
6241
            if branch is None:
5826
 
                raise errors.BzrCommandError('cannot create branch without'
5827
 
                                             ' source branch')
5828
 
            to_location = directory_service.directories.dereference(
5829
 
                              to_location)
5830
 
            if '/' not in to_location and '\\' not in to_location:
5831
 
                # This path is meant to be relative to the existing branch
5832
 
                this_url = self._get_branch_location(control_dir)
5833
 
                to_location = urlutils.join(this_url, '..', to_location)
 
6242
                raise errors.BzrCommandError(
 
6243
                    gettext('cannot create branch without source branch'))
 
6244
            to_location = lookup_new_sibling_branch(control_dir, to_location,
 
6245
                 possible_transports=possible_transports)
5834
6246
            to_branch = branch.bzrdir.sprout(to_location,
5835
 
                                 possible_transports=[branch.bzrdir.root_transport],
5836
 
                                 source_branch=branch).open_branch()
 
6247
                 possible_transports=possible_transports,
 
6248
                 source_branch=branch).open_branch()
5837
6249
        else:
5838
 
            try:
5839
 
                to_branch = Branch.open(to_location)
5840
 
            except errors.NotBranchError:
5841
 
                this_url = self._get_branch_location(control_dir)
5842
 
                to_branch = Branch.open(
5843
 
                    urlutils.join(this_url, '..', to_location))
 
6250
            to_branch = lookup_sibling_branch(control_dir, to_location)
5844
6251
        if revision is not None:
5845
6252
            revision = revision.as_revision_id(to_branch)
5846
6253
        switch.switch(control_dir, to_branch, force, revision_id=revision)
5847
6254
        if had_explicit_nick:
5848
6255
            branch = control_dir.open_branch() #get the new branch!
5849
6256
            branch.nick = to_branch.nick
5850
 
        note('Switched to branch: %s',
 
6257
        note(gettext('Switched to branch: %s'),
5851
6258
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5852
6259
 
5853
 
    def _get_branch_location(self, control_dir):
5854
 
        """Return location of branch for this control dir."""
5855
 
        try:
5856
 
            this_branch = control_dir.open_branch()
5857
 
            # This may be a heavy checkout, where we want the master branch
5858
 
            master_location = this_branch.get_bound_location()
5859
 
            if master_location is not None:
5860
 
                return master_location
5861
 
            # If not, use a local sibling
5862
 
            return this_branch.base
5863
 
        except errors.NotBranchError:
5864
 
            format = control_dir.find_branch_format()
5865
 
            if getattr(format, 'get_reference', None) is not None:
5866
 
                return format.get_reference(control_dir)
5867
 
            else:
5868
 
                return control_dir.root_transport.base
5869
6260
 
5870
6261
 
5871
6262
class cmd_view(Command):
5962
6353
            name = current_view
5963
6354
        if delete:
5964
6355
            if file_list:
5965
 
                raise errors.BzrCommandError(
5966
 
                    "Both --delete and a file list specified")
 
6356
                raise errors.BzrCommandError(gettext(
 
6357
                    "Both --delete and a file list specified"))
5967
6358
            elif switch:
5968
 
                raise errors.BzrCommandError(
5969
 
                    "Both --delete and --switch specified")
 
6359
                raise errors.BzrCommandError(gettext(
 
6360
                    "Both --delete and --switch specified"))
5970
6361
            elif all:
5971
6362
                tree.views.set_view_info(None, {})
5972
 
                self.outf.write("Deleted all views.\n")
 
6363
                self.outf.write(gettext("Deleted all views.\n"))
5973
6364
            elif name is None:
5974
 
                raise errors.BzrCommandError("No current view to delete")
 
6365
                raise errors.BzrCommandError(gettext("No current view to delete"))
5975
6366
            else:
5976
6367
                tree.views.delete_view(name)
5977
 
                self.outf.write("Deleted '%s' view.\n" % name)
 
6368
                self.outf.write(gettext("Deleted '%s' view.\n") % name)
5978
6369
        elif switch:
5979
6370
            if file_list:
5980
 
                raise errors.BzrCommandError(
5981
 
                    "Both --switch and a file list specified")
 
6371
                raise errors.BzrCommandError(gettext(
 
6372
                    "Both --switch and a file list specified"))
5982
6373
            elif all:
5983
 
                raise errors.BzrCommandError(
5984
 
                    "Both --switch and --all specified")
 
6374
                raise errors.BzrCommandError(gettext(
 
6375
                    "Both --switch and --all specified"))
5985
6376
            elif switch == 'off':
5986
6377
                if current_view is None:
5987
 
                    raise errors.BzrCommandError("No current view to disable")
 
6378
                    raise errors.BzrCommandError(gettext("No current view to disable"))
5988
6379
                tree.views.set_view_info(None, view_dict)
5989
 
                self.outf.write("Disabled '%s' view.\n" % (current_view))
 
6380
                self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
5990
6381
            else:
5991
6382
                tree.views.set_view_info(switch, view_dict)
5992
6383
                view_str = views.view_display_str(tree.views.lookup_view())
5993
 
                self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
 
6384
                self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
5994
6385
        elif all:
5995
6386
            if view_dict:
5996
 
                self.outf.write('Views defined:\n')
 
6387
                self.outf.write(gettext('Views defined:\n'))
5997
6388
                for view in sorted(view_dict):
5998
6389
                    if view == current_view:
5999
6390
                        active = "=>"
6002
6393
                    view_str = views.view_display_str(view_dict[view])
6003
6394
                    self.outf.write('%s %-20s %s\n' % (active, view, view_str))
6004
6395
            else:
6005
 
                self.outf.write('No views defined.\n')
 
6396
                self.outf.write(gettext('No views defined.\n'))
6006
6397
        elif file_list:
6007
6398
            if name is None:
6008
6399
                # No name given and no current view set
6009
6400
                name = 'my'
6010
6401
            elif name == 'off':
6011
 
                raise errors.BzrCommandError(
6012
 
                    "Cannot change the 'off' pseudo view")
 
6402
                raise errors.BzrCommandError(gettext(
 
6403
                    "Cannot change the 'off' pseudo view"))
6013
6404
            tree.views.set_view(name, sorted(file_list))
6014
6405
            view_str = views.view_display_str(tree.views.lookup_view())
6015
 
            self.outf.write("Using '%s' view: %s\n" % (name, view_str))
 
6406
            self.outf.write(gettext("Using '{0}' view: {1}\n").format(name, view_str))
6016
6407
        else:
6017
6408
            # list the files
6018
6409
            if name is None:
6019
6410
                # No name given and no current view set
6020
 
                self.outf.write('No current view.\n')
 
6411
                self.outf.write(gettext('No current view.\n'))
6021
6412
            else:
6022
6413
                view_str = views.view_display_str(tree.views.lookup_view(name))
6023
 
                self.outf.write("'%s' view is: %s\n" % (name, view_str))
 
6414
                self.outf.write(gettext("'{0}' view is: {1}\n").format(name, view_str))
6024
6415
 
6025
6416
 
6026
6417
class cmd_hooks(Command):
6040
6431
                        self.outf.write("    %s\n" %
6041
6432
                                        (some_hooks.get_hook_name(hook),))
6042
6433
                else:
6043
 
                    self.outf.write("    <no hooks installed>\n")
 
6434
                    self.outf.write(gettext("    <no hooks installed>\n"))
6044
6435
 
6045
6436
 
6046
6437
class cmd_remove_branch(Command):
6064
6455
    def run(self, location=None):
6065
6456
        if location is None:
6066
6457
            location = "."
6067
 
        branch = Branch.open_containing(location)[0]
6068
 
        branch.bzrdir.destroy_branch()
 
6458
        cdir = controldir.ControlDir.open_containing(location)[0]
 
6459
        cdir.destroy_branch()
6069
6460
 
6070
6461
 
6071
6462
class cmd_shelve(Command):
6147
6538
        manager = tree.get_shelf_manager()
6148
6539
        shelves = manager.active_shelves()
6149
6540
        if len(shelves) == 0:
6150
 
            note('No shelved changes.')
 
6541
            note(gettext('No shelved changes.'))
6151
6542
            return 0
6152
6543
        for shelf_id in reversed(shelves):
6153
6544
            message = manager.get_metadata(shelf_id).get('message')
6242
6633
        if path is not None:
6243
6634
            branchdir = path
6244
6635
        tree, branch, relpath =(
6245
 
            bzrdir.BzrDir.open_containing_tree_or_branch(branchdir))
 
6636
            controldir.ControlDir.open_containing_tree_or_branch(branchdir))
6246
6637
        if path is not None:
6247
6638
            path = relpath
6248
6639
        if tree is None:
6276
6667
    __doc__ = """Export command helps and error messages in po format."""
6277
6668
 
6278
6669
    hidden = True
 
6670
    takes_options = [Option('plugin', 
 
6671
                            help='Export help text from named command '\
 
6672
                                 '(defaults to all built in commands).',
 
6673
                            type=str),
 
6674
                     Option('include-duplicates',
 
6675
                            help='Output multiple copies of the same msgid '
 
6676
                                 'string if it appears more than once.'),
 
6677
                            ]
6279
6678
 
6280
 
    def run(self):
 
6679
    def run(self, plugin=None, include_duplicates=False):
6281
6680
        from bzrlib.export_pot import export_pot
6282
 
        export_pot(self.outf)
 
6681
        export_pot(self.outf, plugin, include_duplicates)
6283
6682
 
6284
6683
 
6285
6684
def _register_lazy_builtins():