235
def _open_directory_or_containing_tree_or_branch(filename, directory):
236
"""Open the tree or branch containing the specified file, unless
237
the --directory option is used to specify a different branch."""
238
if directory is not None:
239
return (None, Branch.open(directory), filename)
240
return bzrdir.BzrDir.open_containing_tree_or_branch(filename)
243
235
# TODO: Make sure no commands unconditionally use the working directory as a
244
236
# branch. If a filename argument is used, the first of them should be used to
245
237
# specify the branch. (Perhaps this can be factored out into some kind of
350
342
takes_args = ['revision_id?']
351
takes_options = ['directory', 'revision']
343
takes_options = ['revision']
352
344
# cat-revision is more for frontends so should be exact
353
345
encoding = 'strict'
361
353
self.outf.write(revtext.decode('utf-8'))
364
def run(self, revision_id=None, revision=None, directory=u'.'):
356
def run(self, revision_id=None, revision=None):
365
357
if revision_id is not None and revision is not None:
366
358
raise errors.BzrCommandError('You can only supply one of'
367
359
' revision_id or --revision')
368
360
if revision_id is None and revision is None:
369
361
raise errors.BzrCommandError('You must supply either'
370
362
' --revision or a revision_id')
371
b = WorkingTree.open_containing(directory)[0].branch
363
b = WorkingTree.open_containing(u'.')[0].branch
373
365
revisions = b.repository.revisions
374
366
if revisions is None:
560
552
takes_args = ['revision_info*']
561
553
takes_options = [
563
custom_help('directory',
564
556
help='Branch to examine, '
565
'rather than the one containing the working directory.'),
557
'rather than the one containing the working directory.',
566
561
Option('tree', help='Show revno of working tree'),
956
951
takes_options = ['remember', 'overwrite', 'revision',
957
952
custom_help('verbose',
958
953
help='Show logs of pulled revisions.'),
959
custom_help('directory',
960
955
help='Branch to pull into, '
961
'rather than the one containing the working directory.'),
956
'rather than the one containing the working directory.',
963
961
help="Perform a local pull in a bound "
964
962
"branch. Local pulls are not applied to "
1078
1076
Option('create-prefix',
1079
1077
help='Create the path leading up to the branch '
1080
1078
'if it does not already exist.'),
1081
custom_help('directory',
1082
1080
help='Branch to push from, '
1083
'rather than the one containing the working directory.'),
1081
'rather than the one containing the working directory.',
1084
1085
Option('use-existing-dir',
1085
1086
help='By default push will fail if the target'
1086
1087
' directory exists, but does not already'
1336
1337
except errors.NoWorkingTree:
1337
1338
source.bzrdir.create_workingtree(revision_id)
1341
message = ('Copying history to "%s". '
1342
'To checkout without local history use --lightweight.' % to_location)
1343
ui.ui_factory.show_message(message)
1344
1340
source.create_checkout(to_location, revision_id, lightweight,
1345
1341
accelerator_tree, hardlink)
1991
1987
# level of effort but possibly much less IO. (Or possibly not,
1992
1988
# if the directories are very large...)
1993
1989
_see_also = ['status', 'ls']
1994
takes_options = ['directory', 'show-ids']
1990
takes_options = ['show-ids']
1996
1992
@display_command
1997
def run(self, show_ids=False, directory=u'.'):
1998
tree = WorkingTree.open_containing(directory)[0]
1993
def run(self, show_ids=False):
1994
tree = WorkingTree.open_containing(u'.')[0]
1999
1995
self.add_cleanup(tree.lock_read().unlock)
2000
1996
old = tree.basis_tree()
2001
1997
self.add_cleanup(old.lock_read().unlock)
2016
2012
_see_also = ['status', 'ls']
2017
takes_options = ['directory', 'null']
2015
help='Write an ascii NUL (\\0) separator '
2016
'between files rather than a newline.')
2019
2019
@display_command
2020
def run(self, null=False, directory=u'.'):
2021
tree = WorkingTree.open_containing(directory)[0]
2020
def run(self, null=False):
2021
tree = WorkingTree.open_containing(u'.')[0]
2022
2022
td = tree.changes_from(tree.basis_tree())
2023
2023
for path, id, kind, text_modified, meta_modified in td.modified:
2035
2035
_see_also = ['status', 'ls']
2036
takes_options = ['directory', 'null']
2038
help='Write an ascii NUL (\\0) separator '
2039
'between files rather than a newline.')
2038
2042
@display_command
2039
def run(self, null=False, directory=u'.'):
2040
wt = WorkingTree.open_containing(directory)[0]
2043
def run(self, null=False):
2044
wt = WorkingTree.open_containing(u'.')[0]
2041
2045
self.add_cleanup(wt.lock_read().unlock)
2042
2046
basis = wt.basis_tree()
2043
2047
self.add_cleanup(basis.lock_read().unlock)
2049
2053
if inv.is_root(file_id) and len(basis_inv) == 0:
2051
2055
path = inv.id2path(file_id)
2052
if not os.access(osutils.pathjoin(wt.basedir, path), os.F_OK):
2056
if not os.access(osutils.abspath(path), os.F_OK):
2055
2059
self.outf.write(path + '\0')
2255
2259
help='Show just the specified revision.'
2256
2260
' See also "help revisionspec".'),
2258
RegistryOption('authors',
2259
'What names to list as authors - first, all or committer.',
2261
lazy_registry=('bzrlib.log', 'author_list_registry'),
2263
2262
Option('levels',
2264
2263
short_name='n',
2265
2264
help='Number of levels to display - 0 for all, 1 for flat.',
2384
2382
show_timezone=timezone,
2385
2383
delta_format=get_verbosity_level(),
2387
show_advice=levels is None,
2388
author_list_handler=authors)
2385
show_advice=levels is None)
2390
2387
# Choose the algorithm for doing the logging. It's annoying
2391
2388
# having multiple code paths like this but necessary until
2508
2505
help='Recurse into subdirectories.'),
2509
2506
Option('from-root',
2510
2507
help='Print paths relative to the root of the branch.'),
2511
Option('unknown', short_name='u',
2512
help='Print unknown files.'),
2508
Option('unknown', help='Print unknown files.'),
2513
2509
Option('versioned', help='Print versioned files.',
2514
2510
short_name='V'),
2515
Option('ignored', short_name='i',
2516
help='Print ignored files.'),
2517
Option('kind', short_name='k',
2511
Option('ignored', help='Print ignored files.'),
2513
help='Write an ascii NUL (\\0) separator '
2514
'between files rather than a newline.'),
2518
2516
help='List entries of a particular kind: file, directory, symlink.',
2524
2520
@display_command
2525
2521
def run(self, revision=None, verbose=False,
2526
2522
recursive=False, from_root=False,
2527
2523
unknown=False, versioned=False, ignored=False,
2528
null=False, kind=None, show_ids=False, path=None, directory=None):
2524
null=False, kind=None, show_ids=False, path=None):
2530
2526
if kind and kind not in ('file', 'directory', 'symlink'):
2531
2527
raise errors.BzrCommandError('invalid kind specified')
2543
2539
raise errors.BzrCommandError('cannot specify both --from-root'
2546
tree, branch, relpath = \
2547
_open_directory_or_containing_tree_or_branch(fs_path, directory)
2542
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
2549
2545
# Calculate the prefix to use
2620
2616
_see_also = ['ls']
2621
takes_options = ['directory']
2623
2618
@display_command
2624
def run(self, directory=u'.'):
2625
for f in WorkingTree.open_containing(directory)[0].unknowns():
2620
for f in WorkingTree.open_containing(u'.')[0].unknowns():
2626
2621
self.outf.write(osutils.quotefn(f) + '\n')
2694
2689
_see_also = ['status', 'ignored', 'patterns']
2695
2690
takes_args = ['name_pattern*']
2696
takes_options = ['directory',
2697
2692
Option('default-rules',
2698
2693
help='Display the default ignore rules that bzr uses.')
2701
def run(self, name_pattern_list=None, default_rules=None,
2696
def run(self, name_pattern_list=None, default_rules=None):
2703
2697
from bzrlib import ignores
2704
2698
if default_rules is not None:
2705
2699
# dump the default rules and exit
2716
2710
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2717
2711
raise errors.BzrCommandError(
2718
2712
"NAME_PATTERN should not be an absolute path")
2719
tree, relpath = WorkingTree.open_containing(directory)
2713
tree, relpath = WorkingTree.open_containing(u'.')
2720
2714
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2721
2715
ignored = globbing.Globster(name_pattern_list)
2749
2743
encoding_type = 'replace'
2750
2744
_see_also = ['ignore', 'ls']
2751
takes_options = ['directory']
2753
2746
@display_command
2754
def run(self, directory=u'.'):
2755
tree = WorkingTree.open_containing(directory)[0]
2748
tree = WorkingTree.open_containing(u'.')[0]
2756
2749
self.add_cleanup(tree.lock_read().unlock)
2757
2750
for path, file_class, kind, file_id, entry in tree.list_files():
2758
2751
if file_class != 'I':
2772
2765
takes_args = ['revno']
2773
takes_options = ['directory']
2775
2767
@display_command
2776
def run(self, revno, directory=u'.'):
2768
def run(self, revno):
2778
2770
revno = int(revno)
2779
2771
except ValueError:
2780
2772
raise errors.BzrCommandError("not a valid revision-number: %r"
2782
revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
2774
revid = WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
2783
2775
self.outf.write("%s\n" % revid)
2812
2804
================= =========================
2814
2806
takes_args = ['dest', 'branch_or_subdir?']
2815
takes_options = ['directory',
2816
2808
Option('format',
2817
2809
help="Type of file to export to.",
2827
2819
'revision in which it was changed.'),
2829
2821
def run(self, dest, branch_or_subdir=None, revision=None, format=None,
2830
root=None, filters=False, per_file_timestamps=False, directory=u'.'):
2822
root=None, filters=False, per_file_timestamps=False):
2831
2823
from bzrlib.export import export
2833
2825
if branch_or_subdir is None:
2834
tree = WorkingTree.open_containing(directory)[0]
2826
tree = WorkingTree.open_containing(u'.')[0]
2835
2827
b = tree.branch
2858
2850
_see_also = ['ls']
2859
takes_options = ['directory',
2860
2852
Option('name-from-revision', help='The path name in the old tree.'),
2861
2853
Option('filters', help='Apply content filters to display the '
2862
2854
'convenience form.'),
2868
2860
@display_command
2869
2861
def run(self, filename, revision=None, name_from_revision=False,
2870
filters=False, directory=None):
2871
2863
if revision is not None and len(revision) != 1:
2872
2864
raise errors.BzrCommandError("bzr cat --revision takes exactly"
2873
2865
" one revision specifier")
2874
2866
tree, branch, relpath = \
2875
_open_directory_or_containing_tree_or_branch(filename, directory)
2867
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
2876
2868
self.add_cleanup(branch.lock_read().unlock)
2877
2869
return self._run(tree, branch, relpath, filename, revision,
2878
2870
name_from_revision, filters)
3362
3354
_see_also = ['info']
3363
3355
takes_args = ['nickname?']
3364
takes_options = ['directory']
3365
def run(self, nickname=None, directory=u'.'):
3366
branch = Branch.open_containing(directory)[0]
3356
def run(self, nickname=None):
3357
branch = Branch.open_containing(u'.')[0]
3367
3358
if nickname is None:
3368
3359
self.printme(branch)
3773
3764
' completely merged into the source, pull from the'
3774
3765
' source rather than merging. When this happens,'
3775
3766
' you do not need to commit the result.'),
3776
custom_help('directory',
3777
3768
help='Branch to merge into, '
3778
'rather than the one containing the working directory.'),
3769
'rather than the one containing the working directory.',
3779
3773
Option('preview', help='Instead of merging, show a diff of the'
3781
3775
Option('interactive', help='Select changes interactively.',
4548
4542
Option('long', help='Show commit date in annotations.'),
4553
4546
encoding_type = 'exact'
4555
4548
@display_command
4556
4549
def run(self, filename, all=False, long=False, revision=None,
4557
show_ids=False, directory=None):
4558
4551
from bzrlib.annotate import annotate_file, annotate_file_tree
4559
4552
wt, branch, relpath = \
4560
_open_directory_or_containing_tree_or_branch(filename, directory)
4553
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
4561
4554
if wt is not None:
4562
4555
self.add_cleanup(wt.lock_read().unlock)
4588
4581
hidden = True # is this right ?
4589
4582
takes_args = ['revision_id*']
4590
takes_options = ['directory', 'revision']
4583
takes_options = ['revision']
4592
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4585
def run(self, revision_id_list=None, revision=None):
4593
4586
if revision_id_list is not None and revision is not None:
4594
4587
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4595
4588
if revision_id_list is None and revision is None:
4596
4589
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4597
b = WorkingTree.open_containing(directory)[0].branch
4590
b = WorkingTree.open_containing(u'.')[0].branch
4598
4591
self.add_cleanup(b.lock_write().unlock)
4599
4592
return self._run(b, revision_id_list, revision)
4661
4654
_see_also = ['checkouts', 'unbind']
4662
4655
takes_args = ['location?']
4663
takes_options = ['directory']
4665
def run(self, location=None, directory=u'.'):
4666
b, relpath = Branch.open_containing(directory)
4658
def run(self, location=None):
4659
b, relpath = Branch.open_containing(u'.')
4667
4660
if location is None:
4669
4662
location = b.get_old_bound_location()
4697
4690
_see_also = ['checkouts', 'bind']
4698
4691
takes_args = []
4699
takes_options = ['directory']
4701
def run(self, directory=u'.'):
4702
b, relpath = Branch.open_containing(directory)
4695
b, relpath = Branch.open_containing(u'.')
4703
4696
if not b.unbind():
4704
4697
raise errors.BzrCommandError('Local branch is not bound')
4867
4860
'result in a dynamically allocated port. The default port '
4868
4861
'depends on the protocol.',
4870
custom_help('directory',
4871
help='Serve contents of this directory.'),
4864
help='Serve contents of this directory.',
4872
4866
Option('allow-writes',
4873
4867
help='By default the server is a readonly server. Supplying '
4874
4868
'--allow-writes enables write access to the contents of '
5303
5297
Option('delete',
5304
5298
help='Delete this tag rather than placing it.',
5306
custom_help('directory',
5307
help='Branch in which to place the tag.'),
5301
help='Branch in which to place the tag.',
5308
5305
Option('force',
5309
5306
help='Replace existing tags.',
5353
5350
_see_also = ['tag']
5354
5351
takes_options = [
5355
custom_help('directory',
5356
help='Branch whose tags should be displayed.'),
5353
help='Branch whose tags should be displayed.',
5357
5357
RegistryOption.from_kwargs('sort',
5358
5358
'Sort tags by different criteria.', title='Sorting',
5359
5359
alpha='Sort tags lexicographically (default).',
5922
5922
To check what clean-tree will do, use --dry-run.
5924
takes_options = ['directory',
5925
Option('ignored', help='Delete all ignored files.'),
5924
takes_options = [Option('ignored', help='Delete all ignored files.'),
5926
5925
Option('detritus', help='Delete conflict files, merge'
5927
5926
' backups, and failed selftest dirs.'),
5928
5927
Option('unknown',
5931
5930
' deleting them.'),
5932
5931
Option('force', help='Do not prompt before deleting.')]
5933
5932
def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
5934
force=False, directory=u'.'):
5935
5934
from bzrlib.clean_tree import clean_tree
5936
5935
if not (unknown or ignored or detritus):
5940
clean_tree(directory, unknown=unknown, ignored=ignored,
5941
detritus=detritus, dry_run=dry_run, no_prompt=force)
5939
clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus,
5940
dry_run=dry_run, no_prompt=force)
5944
5943
class cmd_reference(Command):