/brz/remove-bazaar

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

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2009-02-25 14:36:59 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4049.
  • Revision ID: jelmer@samba.org-20090225143659-vx6cbqtmyicuzfyf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    tree as _mod_tree,
47
47
    ui,
48
48
    urlutils,
 
49
    views,
49
50
    )
50
51
from bzrlib.branch import Branch
51
52
from bzrlib.conflicts import ConflictList
65
66
from bzrlib.trace import mutter, note, warning, is_quiet, get_verbosity_level
66
67
 
67
68
 
68
 
def tree_files(file_list, default_branch=u'.', canonicalize=True):
 
69
def tree_files(file_list, default_branch=u'.', canonicalize=True,
 
70
    apply_view=True):
69
71
    try:
70
 
        return internal_tree_files(file_list, default_branch, canonicalize)
 
72
        return internal_tree_files(file_list, default_branch, canonicalize,
 
73
            apply_view)
71
74
    except errors.FileInWrongBranch, e:
72
75
        raise errors.BzrCommandError("%s is not in the same branch as %s" %
73
76
                                     (e.path, file_list[0]))
74
77
 
75
78
 
 
79
def tree_files_for_add(file_list):
 
80
    """Add handles files a bit differently so it a custom implementation."""
 
81
    if file_list:
 
82
        tree = WorkingTree.open_containing(file_list[0])[0]
 
83
        if tree.supports_views():
 
84
            view_files = tree.views.lookup_view()
 
85
            for filename in file_list:
 
86
                if not osutils.is_inside_any(view_files, filename):
 
87
                    raise errors.FileOutsideView(filename, view_files)
 
88
    else:
 
89
        tree = WorkingTree.open_containing(u'.')[0]
 
90
        if tree.supports_views():
 
91
            view_files = tree.views.lookup_view()
 
92
            if view_files:
 
93
                file_list = view_files
 
94
                view_str = views.view_display_str(view_files)
 
95
                note("ignoring files outside view: %s" % view_str)
 
96
    return tree, file_list
 
97
 
 
98
 
76
99
def _get_one_revision(command_name, revisions):
77
100
    if revisions is None:
78
101
        return None
99
122
 
100
123
# XXX: Bad function name; should possibly also be a class method of
101
124
# WorkingTree rather than a function.
102
 
def internal_tree_files(file_list, default_branch=u'.', canonicalize=True):
 
125
def internal_tree_files(file_list, default_branch=u'.', canonicalize=True,
 
126
    apply_view=True):
103
127
    """Convert command-line paths to a WorkingTree and relative paths.
104
128
 
105
129
    This is typically used for command-line processors that take one or
107
131
 
108
132
    The filenames given are not required to exist.
109
133
 
110
 
    :param file_list: Filenames to convert.  
 
134
    :param file_list: Filenames to convert.
111
135
 
112
136
    :param default_branch: Fallback tree path to use if file_list is empty or
113
137
        None.
114
138
 
 
139
    :param apply_view: if True and a view is set, apply it or check that
 
140
        specified files are within it
 
141
 
115
142
    :return: workingtree, [relative_paths]
116
143
    """
117
144
    if file_list is None or len(file_list) == 0:
118
 
        return WorkingTree.open_containing(default_branch)[0], file_list
 
145
        tree = WorkingTree.open_containing(default_branch)[0]
 
146
        if tree.supports_views() and apply_view:
 
147
            view_files = tree.views.lookup_view()
 
148
            if view_files:
 
149
                file_list = view_files
 
150
                view_str = views.view_display_str(view_files)
 
151
                note("ignoring files outside view: %s" % view_str)
 
152
        return tree, file_list
119
153
    tree = WorkingTree.open_containing(osutils.realpath(file_list[0]))[0]
120
 
    return tree, safe_relpath_files(tree, file_list, canonicalize)
121
 
 
122
 
 
123
 
def safe_relpath_files(tree, file_list, canonicalize=True):
 
154
    return tree, safe_relpath_files(tree, file_list, canonicalize,
 
155
        apply_view=apply_view)
 
156
 
 
157
 
 
158
def safe_relpath_files(tree, file_list, canonicalize=True, apply_view=True):
124
159
    """Convert file_list into a list of relpaths in tree.
125
160
 
126
161
    :param tree: A tree to operate on.
127
162
    :param file_list: A list of user provided paths or None.
 
163
    :param apply_view: if True and a view is set, apply it or check that
 
164
        specified files are within it
128
165
    :return: A list of relative paths.
129
166
    :raises errors.PathNotChild: When a provided path is in a different tree
130
167
        than tree.
131
168
    """
132
169
    if file_list is None:
133
170
        return None
 
171
    if tree.supports_views() and apply_view:
 
172
        view_files = tree.views.lookup_view()
 
173
    else:
 
174
        view_files = []
134
175
    new_list = []
135
176
    # tree.relpath exists as a "thunk" to osutils, but canonical_relpath
136
177
    # doesn't - fix that up here before we enter the loop.
140
181
        fixer = tree.relpath
141
182
    for filename in file_list:
142
183
        try:
143
 
            new_list.append(fixer(osutils.dereference_path(filename)))
 
184
            relpath = fixer(osutils.dereference_path(filename))
 
185
            if  view_files and not osutils.is_inside_any(view_files, relpath):
 
186
                raise errors.FileOutsideView(filename, view_files)
 
187
            new_list.append(relpath)
144
188
        except errors.PathNotChild:
145
189
            raise errors.FileInWrongBranch(tree.branch, filename)
146
190
    return new_list
147
191
 
148
192
 
 
193
def _get_view_info_for_change_reporter(tree):
 
194
    """Get the view information from a tree for change reporting."""
 
195
    view_info = None
 
196
    try:
 
197
        current_view = tree.views.get_view_info()[0]
 
198
        if current_view is not None:
 
199
            view_info = (current_view, tree.views.lookup_view())
 
200
    except errors.ViewsNotSupported:
 
201
        pass
 
202
    return view_info
 
203
 
 
204
 
149
205
# TODO: Make sure no commands unconditionally use the working directory as a
150
206
# branch.  If a filename argument is used, the first of them should be used to
151
207
# specify the branch.  (Perhaps this can be factored out into some kind of
181
237
 
182
238
    To see ignored files use 'bzr ignored'.  For details on the
183
239
    changes to file texts, use 'bzr diff'.
184
 
    
 
240
 
185
241
    Note that --short or -S gives status flags for each item, similar
186
242
    to Subversion's status command. To get output similar to svn -q,
187
243
    use bzr status -SV.
199
255
    If a revision argument is given, the status is calculated against
200
256
    that revision, or between two revisions if two are provided.
201
257
    """
202
 
    
 
258
 
203
259
    # TODO: --no-recurse, --recurse options
204
 
    
 
260
 
205
261
    takes_args = ['file*']
206
262
    takes_options = ['show-ids', 'revision', 'change', 'verbose',
207
263
                     Option('short', help='Use short status indicators.',
215
271
 
216
272
    encoding_type = 'replace'
217
273
    _see_also = ['diff', 'revert', 'status-flags']
218
 
    
 
274
 
219
275
    @display_command
220
276
    def run(self, show_ids=False, file_list=None, revision=None, short=False,
221
277
            versioned=False, no_pending=False, verbose=False):
243
299
 
244
300
class cmd_cat_revision(Command):
245
301
    """Write out metadata for a revision.
246
 
    
 
302
 
247
303
    The revision to print can either be specified by a specific
248
304
    revision identifier, or you can use --revision.
249
305
    """
253
309
    takes_options = ['revision']
254
310
    # cat-revision is more for frontends so should be exact
255
311
    encoding = 'strict'
256
 
    
 
312
 
257
313
    @display_command
258
314
    def run(self, revision_id=None, revision=None):
259
315
        if revision_id is not None and revision is not None:
374
430
 
375
431
    def run(self, location='.', force=False):
376
432
        d = bzrdir.BzrDir.open(location)
377
 
        
 
433
 
378
434
        try:
379
435
            working = d.open_workingtree()
380
436
        except errors.NoWorkingTree:
392
448
        if working_path != branch_path:
393
449
            raise errors.BzrCommandError("You cannot remove the working tree from "
394
450
                                         "a lightweight checkout")
395
 
        
 
451
 
396
452
        d.destroy_workingtree()
397
 
        
 
453
 
398
454
 
399
455
class cmd_revno(Command):
400
456
    """Show current revision number.
450
506
                revno = '.'.join(str(i) for i in dotted_map[revision_id])
451
507
            print '%s %s' % (revno, revision_id)
452
508
 
453
 
    
 
509
 
454
510
class cmd_add(Command):
455
511
    """Add specified files or directories.
456
512
 
474
530
    you should never need to explicitly add a directory, they'll just
475
531
    get added when you add a file in the directory.
476
532
 
477
 
    --dry-run will show which files would be added, but not actually 
 
533
    --dry-run will show which files would be added, but not actually
478
534
    add them.
479
535
 
480
536
    --file-ids-from will try to use the file ids from the supplied path.
523
579
            base_tree.lock_read()
524
580
        try:
525
581
            file_list = self._maybe_expand_globs(file_list)
526
 
            if file_list:
527
 
                tree = WorkingTree.open_containing(file_list[0])[0]
528
 
            else:
529
 
                tree = WorkingTree.open_containing(u'.')[0]
 
582
            tree, file_list = tree_files_for_add(file_list)
530
583
            added, ignored = tree.smart_add(file_list, not
531
584
                no_recurse, action=action, save=not dry_run)
532
585
        finally:
538
591
            if verbose:
539
592
                for glob in sorted(ignored.keys()):
540
593
                    for path in ignored[glob]:
541
 
                        self.outf.write("ignored %s matching \"%s\"\n" 
 
594
                        self.outf.write("ignored %s matching \"%s\"\n"
542
595
                                        % (path, glob))
543
596
            else:
544
597
                match_len = 0
571
624
 
572
625
    takes_args = ['filename']
573
626
    hidden = True
574
 
    
 
627
 
575
628
    @display_command
576
629
    def run(self, filename):
577
630
        # TODO: jam 20050106 Can relpath return a munged path if
748
801
                        # pathjoin with an empty tail adds a slash, which breaks
749
802
                        # relpath :(
750
803
                        dest_parent_fq = tree.basedir
751
 
    
 
804
 
752
805
                    dest_tail = osutils.canonical_relpath(
753
806
                                    dest_parent_fq,
754
807
                                    osutils.pathjoin(dest_parent_fq, spec_tail))
859
912
        branch_to.lock_write()
860
913
        try:
861
914
            if tree_to is not None:
 
915
                view_info = _get_view_info_for_change_reporter(tree_to)
862
916
                change_reporter = delta._ChangeReporter(
863
 
                    unversioned_filter=tree_to.is_ignored)
 
917
                    unversioned_filter=tree_to.is_ignored, view_info=view_info)
864
918
                result = tree_to.pull(branch_from, overwrite, revision_id,
865
919
                                      change_reporter,
866
920
                                      possible_transports=possible_transports)
877
931
 
878
932
class cmd_push(Command):
879
933
    """Update a mirror of this branch.
880
 
    
 
934
 
881
935
    The target branch will not have its working tree populated because this
882
936
    is both expensive, and is not supported on remote file systems.
883
 
    
 
937
 
884
938
    Some smart servers or protocols *may* put the working tree in place in
885
939
    the future.
886
940
 
890
944
 
891
945
    If branches have diverged, you can use 'bzr push --overwrite' to replace
892
946
    the other branch completely, discarding its unmerged changes.
893
 
    
 
947
 
894
948
    If you want to ensure you have the different changes in the other branch,
895
949
    do a merge (see bzr help merge) from the other branch, and commit that.
896
950
    After that you will be able to do a push without '--overwrite'.
1073
1127
    the branch found in '.'. This is useful if you have removed the working tree
1074
1128
    or if it was never created - i.e. if you pushed the branch to its current
1075
1129
    location using SFTP.
1076
 
    
 
1130
 
1077
1131
    If the TO_LOCATION is omitted, the last component of the BRANCH_LOCATION will
1078
1132
    be used.  In other words, "checkout ../foo/bar" will attempt to create ./bar.
1079
1133
    If the BRANCH_LOCATION has no / or path separator embedded, the TO_LOCATION
1121
1175
            revision_id = None
1122
1176
        if to_location is None:
1123
1177
            to_location = urlutils.derive_to_location(branch_location)
1124
 
        # if the source and to_location are the same, 
 
1178
        # if the source and to_location are the same,
1125
1179
        # and there is no working tree,
1126
1180
        # then reconstitute a branch
1127
1181
        if (osutils.abspath(to_location) ==
1173
1227
 
1174
1228
class cmd_update(Command):
1175
1229
    """Update a tree to have the latest code committed to its branch.
1176
 
    
 
1230
 
1177
1231
    This will perform a merge into the working tree, and may generate
1178
 
    conflicts. If you have any local changes, you will still 
 
1232
    conflicts. If you have any local changes, you will still
1179
1233
    need to commit them after the update for the update to be complete.
1180
 
    
1181
 
    If you want to discard your local changes, you can just do a 
 
1234
 
 
1235
    If you want to discard your local changes, you can just do a
1182
1236
    'bzr revert' instead of 'bzr commit' after the update.
1183
1237
    """
1184
1238
 
1206
1260
                    revno = tree.branch.revision_id_to_revno(last_rev)
1207
1261
                    note("Tree is up to date at revision %d." % (revno,))
1208
1262
                    return 0
 
1263
            view_info = _get_view_info_for_change_reporter(tree)
1209
1264
            conflicts = tree.update(
1210
 
                delta._ChangeReporter(unversioned_filter=tree.is_ignored),
1211
 
                possible_transports=possible_transports)
 
1265
                delta._ChangeReporter(unversioned_filter=tree.is_ignored,
 
1266
                view_info=view_info), possible_transports=possible_transports)
1212
1267
            revno = tree.branch.revision_id_to_revno(
1213
1268
                _mod_revision.ensure_null(tree.last_revision()))
1214
1269
            note('Updated to revision %d.' % (revno,))
1227
1282
    """Show information about a working tree, branch or repository.
1228
1283
 
1229
1284
    This command will show all known locations and formats associated to the
1230
 
    tree, branch or repository.  Statistical information is included with
1231
 
    each report.
 
1285
    tree, branch or repository.
 
1286
 
 
1287
    In verbose mode, statistical information is included with each report.
 
1288
    To see extended statistic information, use a verbosity level of 2 or
 
1289
    higher by specifying the verbose option multiple times, e.g. -vv.
1232
1290
 
1233
1291
    Branches and working trees will also report any missing revisions.
 
1292
 
 
1293
    :Examples:
 
1294
 
 
1295
      Display information on the format and related locations:
 
1296
 
 
1297
        bzr info
 
1298
 
 
1299
      Display the above together with extended format information and
 
1300
      basic statistics (like the number of files in the working tree and
 
1301
      number of revisions in the branch and repository):
 
1302
 
 
1303
        bzr -v info
 
1304
 
 
1305
      Display the above together with number of committers to the branch:
 
1306
 
 
1307
        bzr -vv info
1234
1308
    """
1235
1309
    _see_also = ['revno', 'working-trees', 'repositories']
1236
1310
    takes_args = ['location?']
1240
1314
    @display_command
1241
1315
    def run(self, location=None, verbose=False):
1242
1316
        if verbose:
1243
 
            noise_level = 2
 
1317
            noise_level = get_verbosity_level()
1244
1318
        else:
1245
1319
            noise_level = 0
1246
1320
        from bzrlib.info import show_bzrdir_info
1353
1427
 
1354
1428
    This can correct data mismatches that may have been caused by
1355
1429
    previous ghost operations or bzr upgrades. You should only
1356
 
    need to run this command if 'bzr check' or a bzr developer 
 
1430
    need to run this command if 'bzr check' or a bzr developer
1357
1431
    advises you to run it.
1358
1432
 
1359
1433
    If a second branch is provided, cross-branch reconciliation is
1361
1435
    id which was not present in very early bzr versions is represented
1362
1436
    correctly in both branches.
1363
1437
 
1364
 
    At the same time it is run it may recompress data resulting in 
 
1438
    At the same time it is run it may recompress data resulting in
1365
1439
    a potential saving in disk space or performance gain.
1366
1440
 
1367
1441
    The branch *MUST* be on a listable system such as local disk or sftp.
1423
1497
    Use this to create an empty branch, or before importing an
1424
1498
    existing project.
1425
1499
 
1426
 
    If there is a repository in a parent directory of the location, then 
 
1500
    If there is a repository in a parent directory of the location, then
1427
1501
    the history of the branch will be stored in the repository.  Otherwise
1428
1502
    init creates a standalone branch which carries its own history
1429
1503
    in the .bzr directory.
1582
1656
 
1583
1657
class cmd_diff(Command):
1584
1658
    """Show differences in the working tree, between revisions or branches.
1585
 
    
 
1659
 
1586
1660
    If no arguments are given, all changes for the current tree are listed.
1587
1661
    If files are given, only the changes in those files are listed.
1588
1662
    Remote and multiple branches can be compared by using the --old and
1687
1761
                                         ' one or two revision specifiers')
1688
1762
 
1689
1763
        old_tree, new_tree, specific_files, extra_trees = \
1690
 
                _get_trees_to_diff(file_list, revision, old, new)
1691
 
        return show_diff_trees(old_tree, new_tree, sys.stdout, 
 
1764
                _get_trees_to_diff(file_list, revision, old, new,
 
1765
                apply_view=True)
 
1766
        return show_diff_trees(old_tree, new_tree, sys.stdout,
1692
1767
                               specific_files=specific_files,
1693
1768
                               external_diff_options=diff_options,
1694
1769
                               old_label=old_label, new_label=new_label,
1841
1916
    were merged.
1842
1917
 
1843
1918
    :Output control:
1844
 
 
 
1919
 
1845
1920
      The log format controls how information about each revision is
1846
1921
      displayed. The standard log formats are called ``long``, ``short``
1847
1922
      and ``line``. The default is long. See ``bzr help log-formats``
1849
1924
 
1850
1925
      The following options can be used to control what information is
1851
1926
      displayed::
1852
 
  
 
1927
 
1853
1928
        -l N        display a maximum of N revisions
1854
1929
        -n N        display N levels of revisions (0 for all, 1 for collapsed)
1855
1930
        -v          display a status summary (delta) for each revision
1856
1931
        -p          display a diff (patch) for each revision
1857
1932
        --show-ids  display revision-ids (and file-ids), not just revnos
1858
 
  
 
1933
 
1859
1934
      Note that the default number of levels to display is a function of the
1860
1935
      log format. If the -n option is not used, ``short`` and ``line`` show
1861
1936
      just the top level (mainline) while ``long`` shows all levels of merged
1862
1937
      revisions.
1863
 
  
 
1938
 
1864
1939
      Status summaries are shown using status flags like A, M, etc. To see
1865
1940
      the changes explained using words like ``added`` and ``modified``
1866
1941
      instead, use the -vv option.
1867
 
  
 
1942
 
1868
1943
    :Ordering control:
1869
 
  
 
1944
 
1870
1945
      To display revisions from oldest to newest, use the --forward option.
1871
1946
      In most cases, using this option will have little impact on the total
1872
1947
      time taken to produce a log, though --forward does not incrementally
1873
1948
      display revisions like --reverse does when it can.
1874
 
  
 
1949
 
1875
1950
    :Revision filtering:
1876
 
  
 
1951
 
1877
1952
      The -r option can be used to specify what revision or range of revisions
1878
1953
      to filter against. The various forms are shown below::
1879
 
  
 
1954
 
1880
1955
        -rX      display revision X
1881
1956
        -rX..    display revision X and later
1882
1957
        -r..Y    display up to and including revision Y
1883
1958
        -rX..Y   display from X to Y inclusive
1884
 
  
 
1959
 
1885
1960
      See ``bzr help revisionspec`` for details on how to specify X and Y.
1886
1961
      Some common examples are given below::
1887
 
  
 
1962
 
1888
1963
        -r-1                show just the tip
1889
1964
        -r-10..             show the last 10 mainline revisions
1890
1965
        -rsubmit:..         show what's new on this branch
1891
1966
        -rancestor:path..   show changes since the common ancestor of this
1892
1967
                            branch and the one at location path
1893
1968
        -rdate:yesterday..  show changes since yesterday
1894
 
  
 
1969
 
1895
1970
      When logging a range of revisions using -rX..Y, log starts at
1896
1971
      revision Y and searches back in history through the primary
1897
1972
      ("left-hand") parents until it finds X. When logging just the
1900
1975
      a nested merge revision and the log will be truncated accordingly.
1901
1976
 
1902
1977
    :Path filtering:
1903
 
  
 
1978
 
1904
1979
      If a parameter is given and it's not a branch, the log will be filtered
1905
1980
      to show only those revisions that changed the nominated file or
1906
1981
      directory.
1907
 
  
 
1982
 
1908
1983
      Filenames are interpreted within their historical context. To log a
1909
1984
      deleted file, specify a revision range so that the file existed at
1910
1985
      the end or start of the range.
1911
 
  
 
1986
 
1912
1987
      Historical context is also important when interpreting pathnames of
1913
1988
      renamed files/directories. Consider the following example:
1914
 
  
 
1989
 
1915
1990
      * revision 1: add tutorial.txt
1916
1991
      * revision 2: modify tutorial.txt
1917
1992
      * revision 3: rename tutorial.txt to guide.txt; add tutorial.txt
1918
 
  
 
1993
 
1919
1994
      In this case:
1920
 
  
 
1995
 
1921
1996
      * ``bzr log guide.txt`` will log the file added in revision 1
1922
 
  
 
1997
 
1923
1998
      * ``bzr log tutorial.txt`` will log the new file added in revision 3
1924
 
  
 
1999
 
1925
2000
      * ``bzr log -r2 -p tutorial.txt`` will show the changes made to
1926
2001
        the original file in revision 2.
1927
 
  
 
2002
 
1928
2003
      * ``bzr log -r2 -p guide.txt`` will display an error message as there
1929
2004
        was no file called guide.txt in revision 2.
1930
 
  
 
2005
 
1931
2006
      Renames are always followed by log. By design, there is no need to
1932
2007
      explicitly ask for this (and no way to stop logging a file back
1933
2008
      until it was last renamed).
1934
 
  
 
2009
 
1935
2010
      Note: If the path is a directory, only revisions that directly changed
1936
2011
      that directory object are currently shown. This is considered a bug.
1937
2012
      (Support for filtering against multiple files and for files within a
1938
2013
      directory is under development.)
1939
 
  
 
2014
 
1940
2015
    :Other filtering:
1941
 
  
 
2016
 
1942
2017
      The --message option can be used for finding revisions that match a
1943
2018
      regular expression in a commit message.
1944
 
  
 
2019
 
1945
2020
    :Tips & tricks:
1946
 
  
 
2021
 
1947
2022
      GUI tools and IDEs are often better at exploring history than command
1948
2023
      line tools. You may prefer qlog or glog from the QBzr and Bzr-Gtk packages
1949
2024
      respectively for example. (TortoiseBzr uses qlog for displaying logs.) See
1950
2025
      http://bazaar-vcs.org/BzrPlugins and http://bazaar-vcs.org/IDEIntegration.
1951
 
  
 
2026
 
1952
2027
      Web interfaces are often better at exploring history than command line
1953
2028
      tools, particularly for branches on servers. You may prefer Loggerhead
1954
2029
      or one of its alternatives. See http://bazaar-vcs.org/WebInterface.
1955
 
  
 
2030
 
1956
2031
      You may find it useful to add the aliases below to ``bazaar.conf``::
1957
 
  
 
2032
 
1958
2033
        [ALIASES]
1959
2034
        tip = log -r-1 -n1
1960
2035
        top = log -r-10.. --short --forward
1961
2036
        show = log -v -p -n1 --long
1962
 
  
 
2037
 
1963
2038
      ``bzr tip`` will then show the latest revision while ``bzr top``
1964
2039
      will show the last 10 mainline revisions. To see the details of a
1965
2040
      particular revision X,  ``bzr show -rX``.
1966
 
  
 
2041
 
1967
2042
      As many GUI tools and Web interfaces do, you may prefer viewing
1968
2043
      history collapsed initially. If you are interested in looking deeper
1969
2044
      into a particular merge X, use ``bzr log -n0 -rX``. If you like
1970
2045
      working this way, you may wish to either:
1971
 
  
 
2046
 
1972
2047
      * change your default log format to short (or line)
1973
2048
      * add this alias: log = log -n1
1974
 
  
 
2049
 
1975
2050
      ``bzr log -v`` on a branch with lots of history is currently
1976
2051
      very slow. A fix for this issue is currently under development.
1977
2052
      With or without that fix, it is recommended that a revision range
1978
2053
      be given when using the -v option.
1979
 
  
 
2054
 
1980
2055
      bzr has a generic full-text matching plugin, bzr-search, that can be
1981
2056
      used to find revisions matching user names, commit messages, etc.
1982
2057
      Among other features, this plugin can find all revisions containing
1983
2058
      a list of words but not others.
1984
 
  
 
2059
 
1985
2060
      When exploring non-mainline history on large projects with deep
1986
2061
      history, the performance of log can be greatly improved by installing
1987
2062
      the revnocache plugin. This plugin buffers historical information
2063
2138
                        location)
2064
2139
        else:
2065
2140
            # local dir only
2066
 
            # FIXME ? log the current subdir only RBC 20060203 
 
2141
            # FIXME ? log the current subdir only RBC 20060203
2067
2142
            if revision is not None \
2068
2143
                    and len(revision) > 0 and revision[0].get_branch():
2069
2144
                location = revision[0].get_branch()
2290
2365
    using this command or directly by using an editor, be sure to commit
2291
2366
    it.
2292
2367
 
2293
 
    Note: ignore patterns containing shell wildcards must be quoted from 
 
2368
    Note: ignore patterns containing shell wildcards must be quoted from
2294
2369
    the shell on Unix.
2295
2370
 
2296
2371
    :Examples:
2321
2396
        Option('old-default-rules',
2322
2397
               help='Write out the ignore rules bzr < 0.9 always used.')
2323
2398
        ]
2324
 
    
 
2399
 
2325
2400
    def run(self, name_pattern_list=None, old_default_rules=None):
2326
2401
        from bzrlib import ignores
2327
2402
        if old_default_rules is not None:
2332
2407
        if not name_pattern_list:
2333
2408
            raise errors.BzrCommandError("ignore requires at least one "
2334
2409
                                  "NAME_PATTERN or --old-default-rules")
2335
 
        name_pattern_list = [globbing.normalize_pattern(p) 
 
2410
        name_pattern_list = [globbing.normalize_pattern(p)
2336
2411
                             for p in name_pattern_list]
2337
2412
        for name_pattern in name_pattern_list:
2338
 
            if (name_pattern[0] == '/' or 
 
2413
            if (name_pattern[0] == '/' or
2339
2414
                (len(name_pattern) > 1 and name_pattern[1] == ':')):
2340
2415
                raise errors.BzrCommandError(
2341
2416
                    "NAME_PATTERN should not be an absolute path")
2393
2468
    """
2394
2469
    hidden = True
2395
2470
    takes_args = ['revno']
2396
 
    
 
2471
 
2397
2472
    @display_command
2398
2473
    def run(self, revno):
2399
2474
        try:
2467
2542
    If no revision is nominated, the last revision is used.
2468
2543
 
2469
2544
    Note: Take care to redirect standard output when using this command on a
2470
 
    binary file. 
 
2545
    binary file.
2471
2546
    """
2472
2547
 
2473
2548
    _see_also = ['ls']
2520
2595
 
2521
2596
class cmd_local_time_offset(Command):
2522
2597
    """Show the offset in seconds from GMT to local time."""
2523
 
    hidden = True    
 
2598
    hidden = True
2524
2599
    @display_command
2525
2600
    def run(self):
2526
2601
        print osutils.local_time_offset()
2529
2604
 
2530
2605
class cmd_commit(Command):
2531
2606
    """Commit changes into a new revision.
2532
 
    
 
2607
 
2533
2608
    If no arguments are given, the entire tree is committed.
2534
2609
 
2535
2610
    If selected files are specified, only changes to those files are
2536
 
    committed.  If a directory is specified then the directory and everything 
 
2611
    committed.  If a directory is specified then the directory and everything
2537
2612
    within it is committed.
2538
2613
 
2539
2614
    When excludes are given, they take precedence over selected files.
2648
2723
        # TODO: Need a blackbox test for invoking the external editor; may be
2649
2724
        # slightly problematic to run this cross-platform.
2650
2725
 
2651
 
        # TODO: do more checks that the commit will succeed before 
 
2726
        # TODO: do more checks that the commit will succeed before
2652
2727
        # spending the user's valuable time typing a commit message.
2653
2728
 
2654
2729
        properties = {}
2677
2752
                        selected_list, diff=show_diff,
2678
2753
                        output_encoding=osutils.get_user_encoding())
2679
2754
                start_message = generate_commit_message_template(commit_obj)
2680
 
                my_message = edit_commit_message_encoded(t, 
 
2755
                my_message = edit_commit_message_encoded(t,
2681
2756
                    start_message=start_message)
2682
2757
                if my_message is None:
2683
2758
                    raise errors.BzrCommandError("please specify a commit"
2807
2882
 
2808
2883
class cmd_whoami(Command):
2809
2884
    """Show or set bzr user id.
2810
 
    
 
2885
 
2811
2886
    :Examples:
2812
2887
        Show the email of the current user::
2813
2888
 
2825
2900
                    ]
2826
2901
    takes_args = ['name?']
2827
2902
    encoding_type = 'replace'
2828
 
    
 
2903
 
2829
2904
    @display_command
2830
2905
    def run(self, email=False, branch=False, name=None):
2831
2906
        if name is None:
2846
2921
        except errors.NoEmailInUsername, e:
2847
2922
            warning('"%s" does not seem to contain an email address.  '
2848
2923
                    'This is allowed, but not recommended.', name)
2849
 
        
 
2924
 
2850
2925
        # use global config unless --branch given
2851
2926
        if branch:
2852
2927
            c = Branch.open_containing('.')[0].get_config()
2951
3026
 
2952
3027
class cmd_selftest(Command):
2953
3028
    """Run internal test suite.
2954
 
    
 
3029
 
2955
3030
    If arguments are given, they are regular expressions that say which tests
2956
3031
    should run.  Tests matching any expression are run, and other tests are
2957
3032
    not run.
2980
3055
    modified by plugins will not be tested, and tests provided by plugins will
2981
3056
    not be run.
2982
3057
 
2983
 
    Tests that need working space on disk use a common temporary directory, 
 
3058
    Tests that need working space on disk use a common temporary directory,
2984
3059
    typically inside $TMPDIR or /tmp.
2985
3060
 
2986
3061
    :Examples:
3156
3231
    #       merging only part of the history.
3157
3232
    takes_args = ['branch', 'other']
3158
3233
    hidden = True
3159
 
    
 
3234
 
3160
3235
    @display_command
3161
3236
    def run(self, branch, other):
3162
3237
        from bzrlib.revision import ensure_null
3163
 
        
 
3238
 
3164
3239
        branch1 = Branch.open_containing(branch)[0]
3165
3240
        branch2 = Branch.open_containing(other)[0]
3166
3241
        branch1.lock_read()
3182
3257
 
3183
3258
class cmd_merge(Command):
3184
3259
    """Perform a three-way merge.
3185
 
    
 
3260
 
3186
3261
    The source of the merge can be specified either in the form of a branch,
3187
3262
    or in the form of a path to a file containing a merge directive generated
3188
3263
    with bzr send. If neither is specified, the default is the upstream branch
3198
3273
    By default, bzr will try to merge in all new work from the other
3199
3274
    branch, automatically determining an appropriate base.  If this
3200
3275
    fails, you may need to give an explicit base.
3201
 
    
 
3276
 
3202
3277
    Merge will do its best to combine the changes in two branches, but there
3203
3278
    are some kinds of problems only a human can fix.  When it encounters those,
3204
3279
    it will mark a conflict.  A conflict means that you need to fix something,
3214
3289
    The results of the merge are placed into the destination working
3215
3290
    directory, where they can be reviewed (with bzr diff), tested, and then
3216
3291
    committed to record the result of the merge.
3217
 
    
 
3292
 
3218
3293
    merge refuses to run if there are any uncommitted changes, unless
3219
3294
    --force is given.
3220
3295
 
3279
3354
        allow_pending = True
3280
3355
        verified = 'inapplicable'
3281
3356
        tree = WorkingTree.open_containing(directory)[0]
 
3357
        view_info = _get_view_info_for_change_reporter(tree)
3282
3358
        change_reporter = delta._ChangeReporter(
3283
 
            unversioned_filter=tree.is_ignored)
 
3359
            unversioned_filter=tree.is_ignored, view_info=view_info)
3284
3360
        cleanups = []
3285
3361
        try:
3286
3362
            pb = ui.ui_factory.nested_progress_bar()
3485
3561
    """Redo a merge.
3486
3562
 
3487
3563
    Use this if you want to try a different merge technique while resolving
3488
 
    conflicts.  Some merge techniques are better than others, and remerge 
 
3564
    conflicts.  Some merge techniques are better than others, and remerge
3489
3565
    lets you try different ones on different files.
3490
3566
 
3491
3567
    The options for remerge have the same meaning and defaults as the ones for
3495
3571
    :Examples:
3496
3572
        Re-do the merge of all conflicted files, and show the base text in
3497
3573
        conflict regions, in addition to the usual THIS and OTHER texts::
3498
 
      
 
3574
 
3499
3575
            bzr remerge --show-base
3500
3576
 
3501
3577
        Re-do the merge of "foobar", using the weave merge algorithm, with
3502
3578
        additional processing to reduce the size of conflict regions::
3503
 
      
 
3579
 
3504
3580
            bzr remerge --merge-type weave --reprocess foobar
3505
3581
    """
3506
3582
    takes_args = ['file*']
3536
3612
                    interesting_ids.add(file_id)
3537
3613
                    if tree.kind(file_id) != "directory":
3538
3614
                        continue
3539
 
                    
 
3615
 
3540
3616
                    for name, ie in tree.inventory.iter_entries(file_id):
3541
3617
                        interesting_ids.add(ie.file_id)
3542
3618
                new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
3591
3667
    merge instead.  For example, "merge . --revision -2..-3" will remove the
3592
3668
    changes introduced by -2, without affecting the changes introduced by -1.
3593
3669
    Or to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
3594
 
    
 
3670
 
3595
3671
    By default, any files that have been manually changed will be backed up
3596
3672
    first.  (Files changed only by merge are not backed up.)  Backup files have
3597
3673
    '.~#~' appended to their name, where # is a number.
3666
3742
            ]
3667
3743
    takes_args = ['topic?']
3668
3744
    aliases = ['?', '--help', '-?', '-h']
3669
 
    
 
3745
 
3670
3746
    @display_command
3671
3747
    def run(self, topic=None, long=False):
3672
3748
        import bzrlib.help
3683
3759
    takes_args = ['context?']
3684
3760
    aliases = ['s-c']
3685
3761
    hidden = True
3686
 
    
 
3762
 
3687
3763
    @display_command
3688
3764
    def run(self, context=None):
3689
3765
        import shellcomplete
3879
3955
 
3880
3956
class cmd_plugins(Command):
3881
3957
    """List the installed plugins.
3882
 
    
 
3958
 
3883
3959
    This command displays the list of installed plugins including
3884
3960
    version of plugin and a short description of each.
3885
3961
 
3962
4038
    This prints out the given file with an annotation on the left side
3963
4039
    indicating which revision, author and date introduced the change.
3964
4040
 
3965
 
    If the origin is the same for a run of consecutive lines, it is 
 
4041
    If the origin is the same for a run of consecutive lines, it is
3966
4042
    shown only at the top, unless the --all option is given.
3967
4043
    """
3968
4044
    # TODO: annotate directories; showing when each file was last changed
3969
 
    # TODO: if the working copy is modified, show annotations on that 
 
4045
    # TODO: if the working copy is modified, show annotations on that
3970
4046
    #       with new uncommitted lines marked
3971
4047
    aliases = ['ann', 'blame', 'praise']
3972
4048
    takes_args = ['filename']
4018
4094
    hidden = True # is this right ?
4019
4095
    takes_args = ['revision_id*']
4020
4096
    takes_options = ['revision']
4021
 
    
 
4097
 
4022
4098
    def run(self, revision_id_list=None, revision=None):
4023
4099
        if revision_id_list is not None and revision is not None:
4024
4100
            raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4254
4330
    holding the lock has been stopped.
4255
4331
 
4256
4332
    You can get information on what locks are open via the 'bzr info' command.
4257
 
    
 
4333
 
4258
4334
    :Examples:
4259
4335
        bzr break-lock
4260
4336
    """
4268
4344
            control.break_lock()
4269
4345
        except NotImplementedError:
4270
4346
            pass
4271
 
        
 
4347
 
4272
4348
 
4273
4349
class cmd_wait_until_signalled(Command):
4274
4350
    """Test helper for test_start_and_stop_bzr_subprocess_send_signal.
4388
4464
 
4389
4465
class cmd_join(Command):
4390
4466
    """Combine a subtree into its containing tree.
4391
 
    
 
4467
 
4392
4468
    This command is for experimental use only.  It requires the target tree
4393
4469
    to be in dirstate-with-subtree format, which cannot be converted into
4394
4470
    earlier formats.
4436
4512
            try:
4437
4513
                containing_tree.subsume(sub_tree)
4438
4514
            except errors.BadSubsumeSource, e:
4439
 
                raise errors.BzrCommandError("Cannot join %s.  %s" % 
 
4515
                raise errors.BzrCommandError("Cannot join %s.  %s" %
4440
4516
                                             (tree, e.reason))
4441
4517
 
4442
4518
 
4595
4671
    Mail is sent using your preferred mail program.  This should be transparent
4596
4672
    on Windows (it uses MAPI).  On Linux, it requires the xdg-email utility.
4597
4673
    If the preferred client can't be found (or used), your editor will be used.
4598
 
    
 
4674
 
4599
4675
    To use a specific mail program, set the mail_client configuration option.
4600
4676
    (For Thunderbird 1.5, this works around some bugs.)  Supported values for
4601
4677
    specific clients are "claws", "evolution", "kmail", "mutt", and
4604
4680
 
4605
4681
    If mail is being sent, a to address is required.  This can be supplied
4606
4682
    either on the commandline, by setting the submit_to configuration
4607
 
    option in the branch itself or the child_submit_to configuration option 
 
4683
    option in the branch itself or the child_submit_to configuration option
4608
4684
    in the submit branch.
4609
4685
 
4610
4686
    Two formats are currently supported: "4" uses revision bundle format 4 and
4612
4688
    older formats.  It is compatible with Bazaar 0.19 and later.  It is the
4613
4689
    default.  "0.9" uses revision bundle format 0.9 and merge directive
4614
4690
    format 1.  It is compatible with Bazaar 0.12 - 0.18.
4615
 
    
 
4691
 
4616
4692
    Merge directives are applied using the merge command or the pull command.
4617
4693
    """
4618
4694
 
4835
4911
 
4836
4912
class cmd_tag(Command):
4837
4913
    """Create, remove or modify a tag naming a revision.
4838
 
    
 
4914
 
4839
4915
    Tags give human-meaningful names to revisions.  Commands that take a -r
4840
4916
    (--revision) option can be given -rtag:X, where X is any previously
4841
4917
    created tag.
4843
4919
    Tags are stored in the branch.  Tags are copied from one branch to another
4844
4920
    along when you branch, push, pull or merge.
4845
4921
 
4846
 
    It is an error to give a tag name that already exists unless you pass 
 
4922
    It is an error to give a tag name that already exists unless you pass
4847
4923
    --force, in which case the tag is moved to point to the new revision.
4848
4924
 
4849
4925
    To rename a tag (change the name but keep it on the same revsion), run ``bzr
4980
5056
 
4981
5057
    _see_also = ['branches', 'checkouts', 'standalone-trees', 'working-trees']
4982
5058
    takes_args = ['location?']
4983
 
    takes_options = [RegistryOption.from_kwargs('target_type',
4984
 
                     title='Target type',
4985
 
                     help='The type to reconfigure the directory to.',
4986
 
                     value_switches=True, enum_switch=False,
4987
 
                     branch='Reconfigure to be an unbound branch '
4988
 
                        'with no working tree.',
4989
 
                     tree='Reconfigure to be an unbound branch '
4990
 
                        'with a working tree.',
4991
 
                     checkout='Reconfigure to be a bound branch '
4992
 
                        'with a working tree.',
4993
 
                     lightweight_checkout='Reconfigure to be a lightweight'
4994
 
                     ' checkout (with no local history).',
4995
 
                     standalone='Reconfigure to be a standalone branch '
4996
 
                        '(i.e. stop using shared repository).',
4997
 
                     use_shared='Reconfigure to use a shared repository.'),
4998
 
                     Option('bind-to', help='Branch to bind checkout to.',
4999
 
                            type=str),
5000
 
                     Option('force',
5001
 
                        help='Perform reconfiguration even if local changes'
5002
 
                        ' will be lost.')
5003
 
                     ]
 
5059
    takes_options = [
 
5060
        RegistryOption.from_kwargs(
 
5061
            'target_type',
 
5062
            title='Target type',
 
5063
            help='The type to reconfigure the directory to.',
 
5064
            value_switches=True, enum_switch=False,
 
5065
            branch='Reconfigure to be an unbound branch with no working tree.',
 
5066
            tree='Reconfigure to be an unbound branch with a working tree.',
 
5067
            checkout='Reconfigure to be a bound branch with a working tree.',
 
5068
            lightweight_checkout='Reconfigure to be a lightweight'
 
5069
                ' checkout (with no local history).',
 
5070
            standalone='Reconfigure to be a standalone branch '
 
5071
                '(i.e. stop using shared repository).',
 
5072
            use_shared='Reconfigure to use a shared repository.',
 
5073
            with_trees='Reconfigure repository to create '
 
5074
                'working trees on branches by default.',
 
5075
            with_no_trees='Reconfigure repository to not create '
 
5076
                'working trees on branches by default.'
 
5077
            ),
 
5078
        Option('bind-to', help='Branch to bind checkout to.', type=str),
 
5079
        Option('force',
 
5080
               help='Perform reconfiguration even if local changes'
 
5081
               ' will be lost.')
 
5082
        ]
5004
5083
 
5005
5084
    def run(self, location=None, target_type=None, bind_to=None, force=False):
5006
5085
        directory = bzrdir.BzrDir.open(location)
5011
5090
        elif target_type == 'tree':
5012
5091
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5013
5092
        elif target_type == 'checkout':
5014
 
            reconfiguration = reconfigure.Reconfigure.to_checkout(directory,
5015
 
                                                                  bind_to)
 
5093
            reconfiguration = reconfigure.Reconfigure.to_checkout(
 
5094
                directory, bind_to)
5016
5095
        elif target_type == 'lightweight-checkout':
5017
5096
            reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5018
5097
                directory, bind_to)
5020
5099
            reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5021
5100
        elif target_type == 'standalone':
5022
5101
            reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
 
5102
        elif target_type == 'with-trees':
 
5103
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
 
5104
                directory, True)
 
5105
        elif target_type == 'with-no-trees':
 
5106
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
 
5107
                directory, False)
5023
5108
        reconfiguration.apply(force)
5024
5109
 
5025
5110
 
5026
5111
class cmd_switch(Command):
5027
5112
    """Set the branch of a checkout and update.
5028
 
    
 
5113
 
5029
5114
    For lightweight checkouts, this changes the branch being referenced.
5030
5115
    For heavyweight checkouts, this checks that there are no local commits
5031
5116
    versus the current bound branch, then it makes the local branch a mirror
5075
5160
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5076
5161
 
5077
5162
 
 
5163
class cmd_view(Command):
 
5164
    """Manage filtered views.
 
5165
 
 
5166
    Views provide a mask over the tree so that users can focus on
 
5167
    a subset of a tree when doing their work. After creating a view,
 
5168
    commands that support a list of files - status, diff, commit, etc -
 
5169
    effectively have that list of files implicitly given each time.
 
5170
    An explicit list of files can still be given but those files
 
5171
    must be within the current view.
 
5172
 
 
5173
    In most cases, a view has a short life-span: it is created to make
 
5174
    a selected change and is deleted once that change is committed.
 
5175
    At other times, you may wish to create one or more named views
 
5176
    and switch between them.
 
5177
 
 
5178
    To disable the current view without deleting it, you can switch to
 
5179
    the pseudo view called ``off``. This can be useful when you need
 
5180
    to see the whole tree for an operation or two (e.g. merge) but
 
5181
    want to switch back to your view after that.
 
5182
 
 
5183
    :Examples:
 
5184
      To define the current view::
 
5185
 
 
5186
        bzr view file1 dir1 ...
 
5187
 
 
5188
      To list the current view::
 
5189
 
 
5190
        bzr view
 
5191
 
 
5192
      To delete the current view::
 
5193
 
 
5194
        bzr view --delete
 
5195
 
 
5196
      To disable the current view without deleting it::
 
5197
 
 
5198
        bzr view --switch off
 
5199
 
 
5200
      To define a named view and switch to it::
 
5201
 
 
5202
        bzr view --name view-name file1 dir1 ...
 
5203
 
 
5204
      To list a named view::
 
5205
 
 
5206
        bzr view --name view-name
 
5207
 
 
5208
      To delete a named view::
 
5209
 
 
5210
        bzr view --name view-name --delete
 
5211
 
 
5212
      To switch to a named view::
 
5213
 
 
5214
        bzr view --switch view-name
 
5215
 
 
5216
      To list all views defined::
 
5217
 
 
5218
        bzr view --all
 
5219
 
 
5220
      To delete all views::
 
5221
 
 
5222
        bzr view --delete --all
 
5223
    """
 
5224
 
 
5225
    _see_also = []
 
5226
    takes_args = ['file*']
 
5227
    takes_options = [
 
5228
        Option('all',
 
5229
            help='Apply list or delete action to all views.',
 
5230
            ),
 
5231
        Option('delete',
 
5232
            help='Delete the view.',
 
5233
            ),
 
5234
        Option('name',
 
5235
            help='Name of the view to define, list or delete.',
 
5236
            type=unicode,
 
5237
            ),
 
5238
        Option('switch',
 
5239
            help='Name of the view to switch to.',
 
5240
            type=unicode,
 
5241
            ),
 
5242
        ]
 
5243
 
 
5244
    def run(self, file_list,
 
5245
            all=False,
 
5246
            delete=False,
 
5247
            name=None,
 
5248
            switch=None,
 
5249
            ):
 
5250
        tree, file_list = tree_files(file_list, apply_view=False)
 
5251
        current_view, view_dict = tree.views.get_view_info()
 
5252
        if name is None:
 
5253
            name = current_view
 
5254
        if delete:
 
5255
            if file_list:
 
5256
                raise errors.BzrCommandError(
 
5257
                    "Both --delete and a file list specified")
 
5258
            elif switch:
 
5259
                raise errors.BzrCommandError(
 
5260
                    "Both --delete and --switch specified")
 
5261
            elif all:
 
5262
                tree.views.set_view_info(None, {})
 
5263
                self.outf.write("Deleted all views.\n")
 
5264
            elif name is None:
 
5265
                raise errors.BzrCommandError("No current view to delete")
 
5266
            else:
 
5267
                tree.views.delete_view(name)
 
5268
                self.outf.write("Deleted '%s' view.\n" % name)
 
5269
        elif switch:
 
5270
            if file_list:
 
5271
                raise errors.BzrCommandError(
 
5272
                    "Both --switch and a file list specified")
 
5273
            elif all:
 
5274
                raise errors.BzrCommandError(
 
5275
                    "Both --switch and --all specified")
 
5276
            elif switch == 'off':
 
5277
                if current_view is None:
 
5278
                    raise errors.BzrCommandError("No current view to disable")
 
5279
                tree.views.set_view_info(None, view_dict)
 
5280
                self.outf.write("Disabled '%s' view.\n" % (current_view))
 
5281
            else:
 
5282
                tree.views.set_view_info(switch, view_dict)
 
5283
                view_str = views.view_display_str(tree.views.lookup_view())
 
5284
                self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
 
5285
        elif all:
 
5286
            if view_dict:
 
5287
                self.outf.write('Views defined:\n')
 
5288
                for view in sorted(view_dict):
 
5289
                    if view == current_view:
 
5290
                        active = "=>"
 
5291
                    else:
 
5292
                        active = "  "
 
5293
                    view_str = views.view_display_str(view_dict[view])
 
5294
                    self.outf.write('%s %-20s %s\n' % (active, view, view_str))
 
5295
            else:
 
5296
                self.outf.write('No views defined.\n')
 
5297
        elif file_list:
 
5298
            if name is None:
 
5299
                # No name given and no current view set
 
5300
                name = 'my'
 
5301
            elif name == 'off':
 
5302
                raise errors.BzrCommandError(
 
5303
                    "Cannot change the 'off' pseudo view")
 
5304
            tree.views.set_view(name, sorted(file_list))
 
5305
            view_str = views.view_display_str(tree.views.lookup_view())
 
5306
            self.outf.write("Using '%s' view: %s\n" % (name, view_str))
 
5307
        else:
 
5308
            # list the files
 
5309
            if name is None:
 
5310
                # No name given and no current view set
 
5311
                self.outf.write('No current view.\n')
 
5312
            else:
 
5313
                view_str = views.view_display_str(tree.views.lookup_view(name))
 
5314
                self.outf.write("'%s' view is: %s\n" % (name, view_str))
 
5315
 
 
5316
 
5078
5317
class cmd_hooks(Command):
5079
5318
    """Show a branch's currently registered hooks.
5080
5319
    """
5217
5456
 
5218
5457
# these get imported and then picked up by the scan for cmd_*
5219
5458
# TODO: Some more consistent way to split command definitions across files;
5220
 
# we do need to load at least some information about them to know of 
 
5459
# we do need to load at least some information about them to know of
5221
5460
# aliases.  ideally we would avoid loading the implementation until the
5222
5461
# details were needed.
5223
5462
from bzrlib.cmd_version_info import cmd_version_info