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)
235
243
# TODO: Make sure no commands unconditionally use the working directory as a
236
244
# branch. If a filename argument is used, the first of them should be used to
237
245
# specify the branch. (Perhaps this can be factored out into some kind of
342
350
takes_args = ['revision_id?']
343
takes_options = ['revision']
351
takes_options = ['directory', 'revision']
344
352
# cat-revision is more for frontends so should be exact
345
353
encoding = 'strict'
353
361
self.outf.write(revtext.decode('utf-8'))
356
def run(self, revision_id=None, revision=None):
364
def run(self, revision_id=None, revision=None, directory=u'.'):
357
365
if revision_id is not None and revision is not None:
358
366
raise errors.BzrCommandError('You can only supply one of'
359
367
' revision_id or --revision')
360
368
if revision_id is None and revision is None:
361
369
raise errors.BzrCommandError('You must supply either'
362
370
' --revision or a revision_id')
363
b = WorkingTree.open_containing(u'.')[0].branch
371
b = WorkingTree.open_containing(directory)[0].branch
365
373
revisions = b.repository.revisions
366
374
if revisions is None:
530
538
wt = WorkingTree.open_containing(location)[0]
531
self.add_cleanup(wt.lock_read().unlock)
532
540
except (errors.NoWorkingTree, errors.NotLocalUrl):
533
541
raise errors.NoWorkingTree(location)
542
self.add_cleanup(wt.unlock)
534
543
revid = wt.last_revision()
536
545
revno_t = wt.branch.revision_id_to_dotted_revno(revid)
539
548
revno = ".".join(str(n) for n in revno_t)
541
550
b = Branch.open_containing(location)[0]
542
self.add_cleanup(b.lock_read().unlock)
552
self.add_cleanup(b.unlock)
543
553
revno = b.revno()
544
554
self.cleanup_now()
545
555
self.outf.write(str(revno) + '\n')
552
562
takes_args = ['revision_info*']
553
563
takes_options = [
565
custom_help('directory',
556
566
help='Branch to examine, '
557
'rather than the one containing the working directory.',
567
'rather than the one containing the working directory.'),
561
568
Option('tree', help='Show revno of working tree'),
569
576
wt = WorkingTree.open_containing(directory)[0]
571
self.add_cleanup(wt.lock_read().unlock)
579
self.add_cleanup(wt.unlock)
572
580
except (errors.NoWorkingTree, errors.NotLocalUrl):
574
582
b = Branch.open_containing(directory)[0]
575
self.add_cleanup(b.lock_read().unlock)
584
self.add_cleanup(b.unlock)
576
585
revision_ids = []
577
586
if revision is not None:
578
587
revision_ids.extend(rev.as_revision_id(b) for rev in revision)
677
686
should_print=(not is_quiet()))
680
self.add_cleanup(base_tree.lock_read().unlock)
689
base_tree.lock_read()
690
self.add_cleanup(base_tree.unlock)
681
691
tree, file_list = tree_files_for_add(file_list)
682
692
added, ignored = tree.smart_add(file_list, not
683
693
no_recurse, action=action, save=not dry_run)
756
766
revision = _get_one_revision('inventory', revision)
757
767
work_tree, file_list = tree_files(file_list)
758
self.add_cleanup(work_tree.lock_read().unlock)
768
work_tree.lock_read()
769
self.add_cleanup(work_tree.unlock)
759
770
if revision is not None:
760
771
tree = revision.as_tree(work_tree.branch)
762
773
extra_trees = [work_tree]
763
self.add_cleanup(tree.lock_read().unlock)
775
self.add_cleanup(tree.unlock)
826
838
if len(names_list) < 2:
827
839
raise errors.BzrCommandError("missing file argument")
828
840
tree, rel_names = tree_files(names_list, canonicalize=False)
829
self.add_cleanup(tree.lock_tree_write().unlock)
841
tree.lock_tree_write()
842
self.add_cleanup(tree.unlock)
830
843
self._run(tree, names_list, rel_names, after)
832
845
def run_auto(self, names_list, after, dry_run):
837
850
raise errors.BzrCommandError('--after cannot be specified with'
839
852
work_tree, file_list = tree_files(names_list, default_branch='.')
840
self.add_cleanup(work_tree.lock_tree_write().unlock)
853
work_tree.lock_tree_write()
854
self.add_cleanup(work_tree.unlock)
841
855
rename_map.RenameMap.guess_renames(work_tree, dry_run)
843
857
def _run(self, tree, names_list, rel_names, after):
951
965
takes_options = ['remember', 'overwrite', 'revision',
952
966
custom_help('verbose',
953
967
help='Show logs of pulled revisions.'),
968
custom_help('directory',
955
969
help='Branch to pull into, '
956
'rather than the one containing the working directory.',
970
'rather than the one containing the working directory.'),
961
972
help="Perform a local pull in a bound "
962
973
"branch. Local pulls are not applied to "
978
989
tree_to = WorkingTree.open_containing(directory)[0]
979
990
branch_to = tree_to.branch
980
self.add_cleanup(tree_to.lock_write().unlock)
992
self.add_cleanup(tree_to.unlock)
981
993
except errors.NoWorkingTree:
983
995
branch_to = Branch.open_containing(directory)[0]
984
self.add_cleanup(branch_to.lock_write().unlock)
996
branch_to.lock_write()
997
self.add_cleanup(branch_to.unlock)
986
999
if local and not branch_to.get_bound_location():
987
1000
raise errors.LocalRequiresBoundBranch()
1019
1032
branch_from = Branch.open(location,
1020
1033
possible_transports=possible_transports)
1021
self.add_cleanup(branch_from.lock_read().unlock)
1034
branch_from.lock_read()
1035
self.add_cleanup(branch_from.unlock)
1023
1037
if branch_to.get_parent() is None or remember:
1024
1038
branch_to.set_parent(branch_from.base)
1076
1090
Option('create-prefix',
1077
1091
help='Create the path leading up to the branch '
1078
1092
'if it does not already exist.'),
1093
custom_help('directory',
1080
1094
help='Branch to push from, '
1081
'rather than the one containing the working directory.',
1095
'rather than the one containing the working directory.'),
1085
1096
Option('use-existing-dir',
1086
1097
help='By default push will fail if the target'
1087
1098
' directory exists, but does not already'
1207
1218
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1209
1220
revision = _get_one_revision('branch', revision)
1210
self.add_cleanup(br_from.lock_read().unlock)
1222
self.add_cleanup(br_from.unlock)
1211
1223
if revision is not None:
1212
1224
revision_id = revision.as_revision_id(br_from)
1353
1365
@display_command
1354
1366
def run(self, dir=u'.'):
1355
1367
tree = WorkingTree.open_containing(dir)[0]
1356
self.add_cleanup(tree.lock_read().unlock)
1369
self.add_cleanup(tree.unlock)
1357
1370
new_inv = tree.inventory
1358
1371
old_tree = tree.basis_tree()
1359
self.add_cleanup(old_tree.lock_read().unlock)
1372
old_tree.lock_read()
1373
self.add_cleanup(old_tree.unlock)
1360
1374
old_inv = old_tree.inventory
1362
1376
iterator = tree.iter_changes(old_tree, include_unchanged=True)
1400
1414
master = branch.get_master_branch(
1401
1415
possible_transports=possible_transports)
1402
1416
if master is not None:
1403
1418
branch_location = master.base
1420
tree.lock_tree_write()
1406
1421
branch_location = tree.branch.base
1407
tree.lock_tree_write()
1408
1422
self.add_cleanup(tree.unlock)
1409
1423
# get rid of the final '/' and be ready for display
1410
1424
branch_location = urlutils.unescape_for_display(
1530
1544
if file_list is not None:
1531
1545
file_list = [f for f in file_list]
1533
self.add_cleanup(tree.lock_write().unlock)
1548
self.add_cleanup(tree.unlock)
1534
1549
# Heuristics should probably all move into tree.remove_smart or
1987
2002
# level of effort but possibly much less IO. (Or possibly not,
1988
2003
# if the directories are very large...)
1989
2004
_see_also = ['status', 'ls']
1990
takes_options = ['show-ids']
2005
takes_options = ['directory', 'show-ids']
1992
2007
@display_command
1993
def run(self, show_ids=False):
1994
tree = WorkingTree.open_containing(u'.')[0]
1995
self.add_cleanup(tree.lock_read().unlock)
2008
def run(self, show_ids=False, directory=u'.'):
2009
tree = WorkingTree.open_containing(directory)[0]
2011
self.add_cleanup(tree.unlock)
1996
2012
old = tree.basis_tree()
1997
self.add_cleanup(old.lock_read().unlock)
2014
self.add_cleanup(old.unlock)
1998
2015
for path, ie in old.inventory.iter_entries():
1999
2016
if not tree.has_id(ie.file_id):
2000
2017
self.outf.write(path)
2012
2029
_see_also = ['status', 'ls']
2015
help='Write an ascii NUL (\\0) separator '
2016
'between files rather than a newline.')
2030
takes_options = ['directory', 'null']
2019
2032
@display_command
2020
def run(self, null=False):
2021
tree = WorkingTree.open_containing(u'.')[0]
2033
def run(self, null=False, directory=u'.'):
2034
tree = WorkingTree.open_containing(directory)[0]
2022
2035
td = tree.changes_from(tree.basis_tree())
2023
2036
for path, id, kind, text_modified, meta_modified in td.modified:
2035
2048
_see_also = ['status', 'ls']
2038
help='Write an ascii NUL (\\0) separator '
2039
'between files rather than a newline.')
2049
takes_options = ['directory', 'null']
2042
2051
@display_command
2043
def run(self, null=False):
2044
wt = WorkingTree.open_containing(u'.')[0]
2045
self.add_cleanup(wt.lock_read().unlock)
2052
def run(self, null=False, directory=u'.'):
2053
wt = WorkingTree.open_containing(directory)[0]
2055
self.add_cleanup(wt.unlock)
2046
2056
basis = wt.basis_tree()
2047
self.add_cleanup(basis.lock_read().unlock)
2058
self.add_cleanup(basis.unlock)
2048
2059
basis_inv = basis.inventory
2049
2060
inv = wt.inventory
2050
2061
for file_id in inv:
2053
2064
if inv.is_root(file_id) and len(basis_inv) == 0:
2055
2066
path = inv.id2path(file_id)
2056
if not os.access(osutils.abspath(path), os.F_OK):
2067
if not os.access(osutils.pathjoin(wt.basedir, path), os.F_OK):
2059
2070
self.outf.write(path + '\0')
2333
2344
# find the file ids to log and check for directory filtering
2334
2345
b, file_info_list, rev1, rev2 = _get_info_for_log_files(
2335
revision, file_list, self.add_cleanup)
2346
revision, file_list)
2347
self.add_cleanup(b.unlock)
2336
2348
for relpath, file_id, kind in file_info_list:
2337
2349
if file_id is None:
2338
2350
raise errors.BzrCommandError(
2357
2369
dir, relpath = bzrdir.BzrDir.open_containing(location)
2358
2370
b = dir.open_branch()
2359
self.add_cleanup(b.lock_read().unlock)
2372
self.add_cleanup(b.unlock)
2360
2373
rev1, rev2 = _get_revision_range(revision, b, self.name())
2362
2375
# Decide on the type of delta & diff filtering to use
2486
2499
tree, relpath = WorkingTree.open_containing(filename)
2487
2500
file_id = tree.path2id(relpath)
2488
2501
b = tree.branch
2489
self.add_cleanup(b.lock_read().unlock)
2503
self.add_cleanup(b.unlock)
2490
2504
touching_revs = log.find_touching_revisions(b, file_id)
2491
2505
for revno, revision_id, what in touching_revs:
2492
2506
self.outf.write("%6d %s\n" % (revno, what))
2505
2519
help='Recurse into subdirectories.'),
2506
2520
Option('from-root',
2507
2521
help='Print paths relative to the root of the branch.'),
2508
Option('unknown', help='Print unknown files.'),
2522
Option('unknown', short_name='u',
2523
help='Print unknown files.'),
2509
2524
Option('versioned', help='Print versioned files.',
2510
2525
short_name='V'),
2511
Option('ignored', help='Print ignored files.'),
2513
help='Write an ascii NUL (\\0) separator '
2514
'between files rather than a newline.'),
2526
Option('ignored', short_name='i',
2527
help='Print ignored files.'),
2528
Option('kind', short_name='k',
2516
2529
help='List entries of a particular kind: file, directory, symlink.',
2520
2535
@display_command
2521
2536
def run(self, revision=None, verbose=False,
2522
2537
recursive=False, from_root=False,
2523
2538
unknown=False, versioned=False, ignored=False,
2524
null=False, kind=None, show_ids=False, path=None):
2539
null=False, kind=None, show_ids=False, path=None, directory=None):
2526
2541
if kind and kind not in ('file', 'directory', 'symlink'):
2527
2542
raise errors.BzrCommandError('invalid kind specified')
2539
2554
raise errors.BzrCommandError('cannot specify both --from-root'
2542
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
2557
tree, branch, relpath = \
2558
_open_directory_or_containing_tree_or_branch(fs_path, directory)
2545
2560
# Calculate the prefix to use
2561
2576
view_str = views.view_display_str(view_files)
2562
2577
note("Ignoring files outside view. View is %s" % view_str)
2564
self.add_cleanup(tree.lock_read().unlock)
2580
self.add_cleanup(tree.unlock)
2565
2581
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2566
2582
from_dir=relpath, recursive=recursive):
2567
2583
# Apply additional masking
2616
2632
_see_also = ['ls']
2633
takes_options = ['directory']
2618
2635
@display_command
2620
for f in WorkingTree.open_containing(u'.')[0].unknowns():
2636
def run(self, directory=u'.'):
2637
for f in WorkingTree.open_containing(directory)[0].unknowns():
2621
2638
self.outf.write(osutils.quotefn(f) + '\n')
2689
2706
_see_also = ['status', 'ignored', 'patterns']
2690
2707
takes_args = ['name_pattern*']
2708
takes_options = ['directory',
2692
2709
Option('default-rules',
2693
2710
help='Display the default ignore rules that bzr uses.')
2696
def run(self, name_pattern_list=None, default_rules=None):
2713
def run(self, name_pattern_list=None, default_rules=None,
2697
2715
from bzrlib import ignores
2698
2716
if default_rules is not None:
2699
2717
# dump the default rules and exit
2710
2728
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2711
2729
raise errors.BzrCommandError(
2712
2730
"NAME_PATTERN should not be an absolute path")
2713
tree, relpath = WorkingTree.open_containing(u'.')
2731
tree, relpath = WorkingTree.open_containing(directory)
2714
2732
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2715
2733
ignored = globbing.Globster(name_pattern_list)
2743
2761
encoding_type = 'replace'
2744
2762
_see_also = ['ignore', 'ls']
2763
takes_options = ['directory']
2746
2765
@display_command
2748
tree = WorkingTree.open_containing(u'.')[0]
2749
self.add_cleanup(tree.lock_read().unlock)
2766
def run(self, directory=u'.'):
2767
tree = WorkingTree.open_containing(directory)[0]
2769
self.add_cleanup(tree.unlock)
2750
2770
for path, file_class, kind, file_id, entry in tree.list_files():
2751
2771
if file_class != 'I':
2765
2785
takes_args = ['revno']
2786
takes_options = ['directory']
2767
2788
@display_command
2768
def run(self, revno):
2789
def run(self, revno, directory=u'.'):
2770
2791
revno = int(revno)
2771
2792
except ValueError:
2772
2793
raise errors.BzrCommandError("not a valid revision-number: %r"
2774
revid = WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
2795
revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
2775
2796
self.outf.write("%s\n" % revid)
2804
2825
================= =========================
2806
2827
takes_args = ['dest', 'branch_or_subdir?']
2828
takes_options = ['directory',
2808
2829
Option('format',
2809
2830
help="Type of file to export to.",
2819
2840
'revision in which it was changed.'),
2821
2842
def run(self, dest, branch_or_subdir=None, revision=None, format=None,
2822
root=None, filters=False, per_file_timestamps=False):
2843
root=None, filters=False, per_file_timestamps=False, directory=u'.'):
2823
2844
from bzrlib.export import export
2825
2846
if branch_or_subdir is None:
2826
tree = WorkingTree.open_containing(u'.')[0]
2847
tree = WorkingTree.open_containing(directory)[0]
2827
2848
b = tree.branch
2850
2871
_see_also = ['ls']
2872
takes_options = ['directory',
2852
2873
Option('name-from-revision', help='The path name in the old tree.'),
2853
2874
Option('filters', help='Apply content filters to display the '
2854
2875
'convenience form.'),
2860
2881
@display_command
2861
2882
def run(self, filename, revision=None, name_from_revision=False,
2883
filters=False, directory=None):
2863
2884
if revision is not None and len(revision) != 1:
2864
2885
raise errors.BzrCommandError("bzr cat --revision takes exactly"
2865
2886
" one revision specifier")
2866
2887
tree, branch, relpath = \
2867
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
2868
self.add_cleanup(branch.lock_read().unlock)
2888
_open_directory_or_containing_tree_or_branch(filename, directory)
2890
self.add_cleanup(branch.unlock)
2869
2891
return self._run(tree, branch, relpath, filename, revision,
2870
2892
name_from_revision, filters)
2874
2896
if tree is None:
2875
2897
tree = b.basis_tree()
2876
2898
rev_tree = _get_one_revision_tree('cat', revision, branch=b)
2877
self.add_cleanup(rev_tree.lock_read().unlock)
2899
rev_tree.lock_read()
2900
self.add_cleanup(rev_tree.unlock)
2879
2902
old_file_id = rev_tree.path2id(relpath)
3354
3377
_see_also = ['info']
3355
3378
takes_args = ['nickname?']
3356
def run(self, nickname=None):
3357
branch = Branch.open_containing(u'.')[0]
3379
takes_options = ['directory']
3380
def run(self, nickname=None, directory=u'.'):
3381
branch = Branch.open_containing(directory)[0]
3358
3382
if nickname is None:
3359
3383
self.printme(branch)
3664
3688
branch1 = Branch.open_containing(branch)[0]
3665
3689
branch2 = Branch.open_containing(other)[0]
3666
self.add_cleanup(branch1.lock_read().unlock)
3667
self.add_cleanup(branch2.lock_read().unlock)
3691
self.add_cleanup(branch1.unlock)
3693
self.add_cleanup(branch2.unlock)
3668
3694
last1 = ensure_null(branch1.last_revision())
3669
3695
last2 = ensure_null(branch2.last_revision())
3764
3790
' completely merged into the source, pull from the'
3765
3791
' source rather than merging. When this happens,'
3766
3792
' you do not need to commit the result.'),
3793
custom_help('directory',
3768
3794
help='Branch to merge into, '
3769
'rather than the one containing the working directory.',
3795
'rather than the one containing the working directory.'),
3773
3796
Option('preview', help='Instead of merging, show a diff of the'
3775
3798
Option('interactive', help='Select changes interactively.',
3808
3831
unversioned_filter=tree.is_ignored, view_info=view_info)
3809
3832
pb = ui.ui_factory.nested_progress_bar()
3810
3833
self.add_cleanup(pb.finished)
3811
self.add_cleanup(tree.lock_write().unlock)
3835
self.add_cleanup(tree.unlock)
3812
3836
if location is not None:
3814
3838
mergeable = bundle.read_mergeable_from_url(location,
4070
4094
if merge_type is None:
4071
4095
merge_type = _mod_merge.Merge3Merger
4072
4096
tree, file_list = tree_files(file_list)
4073
self.add_cleanup(tree.lock_write().unlock)
4098
self.add_cleanup(tree.unlock)
4074
4099
parents = tree.get_parent_ids()
4075
4100
if len(parents) != 2:
4076
4101
raise errors.BzrCommandError("Sorry, remerge only works after normal"
4186
4211
def run(self, revision=None, no_backup=False, file_list=None,
4187
4212
forget_merges=None):
4188
4213
tree, file_list = tree_files(file_list)
4189
self.add_cleanup(tree.lock_tree_write().unlock)
4214
tree.lock_tree_write()
4215
self.add_cleanup(tree.unlock)
4190
4216
if forget_merges:
4191
4217
tree.set_parent_ids(tree.get_parent_ids()[:1])
4345
4372
if remote_branch.base == local_branch.base:
4346
4373
remote_branch = local_branch
4348
self.add_cleanup(remote_branch.lock_read().unlock)
4375
remote_branch.lock_read()
4376
self.add_cleanup(remote_branch.unlock)
4350
4378
local_revid_range = _revision_range_to_revid_range(
4351
4379
_get_revision_range(my_revision, local_branch,
4406
4434
message("Branches are up to date.\n")
4407
4435
self.cleanup_now()
4408
4436
if not status_code and parent is None and other_branch is not None:
4409
self.add_cleanup(local_branch.lock_write().unlock)
4437
local_branch.lock_write()
4438
self.add_cleanup(local_branch.unlock)
4410
4439
# handle race conditions - a parent might be set while we run.
4411
4440
if local_branch.get_parent() is None:
4412
4441
local_branch.set_parent(remote_branch.base)
4542
4572
Option('long', help='Show commit date in annotations.'),
4546
4577
encoding_type = 'exact'
4548
4579
@display_command
4549
4580
def run(self, filename, all=False, long=False, revision=None,
4581
show_ids=False, directory=None):
4551
4582
from bzrlib.annotate import annotate_file, annotate_file_tree
4552
4583
wt, branch, relpath = \
4553
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
4584
_open_directory_or_containing_tree_or_branch(filename, directory)
4554
4585
if wt is not None:
4555
self.add_cleanup(wt.lock_read().unlock)
4587
self.add_cleanup(wt.unlock)
4557
self.add_cleanup(branch.lock_read().unlock)
4590
self.add_cleanup(branch.unlock)
4558
4591
tree = _get_one_revision_tree('annotate', revision, branch=branch)
4559
self.add_cleanup(tree.lock_read().unlock)
4593
self.add_cleanup(tree.unlock)
4560
4594
if wt is not None:
4561
4595
file_id = wt.path2id(relpath)
4581
4615
hidden = True # is this right ?
4582
4616
takes_args = ['revision_id*']
4583
takes_options = ['revision']
4617
takes_options = ['directory', 'revision']
4585
def run(self, revision_id_list=None, revision=None):
4619
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4586
4620
if revision_id_list is not None and revision is not None:
4587
4621
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4588
4622
if revision_id_list is None and revision is None:
4589
4623
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4590
b = WorkingTree.open_containing(u'.')[0].branch
4591
self.add_cleanup(b.lock_write().unlock)
4624
b = WorkingTree.open_containing(directory)[0].branch
4626
self.add_cleanup(b.unlock)
4592
4627
return self._run(b, revision_id_list, revision)
4594
4629
def _run(self, b, revision_id_list, revision):
4654
4689
_see_also = ['checkouts', 'unbind']
4655
4690
takes_args = ['location?']
4691
takes_options = ['directory']
4658
def run(self, location=None):
4659
b, relpath = Branch.open_containing(u'.')
4693
def run(self, location=None, directory=u'.'):
4694
b, relpath = Branch.open_containing(directory)
4660
4695
if location is None:
4662
4697
location = b.get_old_bound_location()
4690
4725
_see_also = ['checkouts', 'bind']
4691
4726
takes_args = []
4727
takes_options = ['directory']
4695
b, relpath = Branch.open_containing(u'.')
4729
def run(self, directory=u'.'):
4730
b, relpath = Branch.open_containing(directory)
4696
4731
if not b.unbind():
4697
4732
raise errors.BzrCommandError('Local branch is not bound')
4744
4779
b = control.open_branch()
4746
4781
if tree is not None:
4747
self.add_cleanup(tree.lock_write().unlock)
4783
self.add_cleanup(tree.unlock)
4749
self.add_cleanup(b.lock_write().unlock)
4786
self.add_cleanup(b.unlock)
4750
4787
return self._run(b, tree, dry_run, verbose, revision, force, local=local)
4752
4789
def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
4860
4897
'result in a dynamically allocated port. The default port '
4861
4898
'depends on the protocol.',
4864
help='Serve contents of this directory.',
4900
custom_help('directory',
4901
help='Serve contents of this directory.'),
4866
4902
Option('allow-writes',
4867
4903
help='By default the server is a readonly server. Supplying '
4868
4904
'--allow-writes enables write access to the contents of '
5297
5333
Option('delete',
5298
5334
help='Delete this tag rather than placing it.',
5301
help='Branch in which to place the tag.',
5336
custom_help('directory',
5337
help='Branch in which to place the tag.'),
5305
5338
Option('force',
5306
5339
help='Replace existing tags.',
5317
5350
branch, relpath = Branch.open_containing(directory)
5318
self.add_cleanup(branch.lock_write().unlock)
5352
self.add_cleanup(branch.unlock)
5320
5354
if tag_name is None:
5321
5355
raise errors.BzrCommandError("No tag specified to delete.")
5350
5384
_see_also = ['tag']
5351
5385
takes_options = [
5353
help='Branch whose tags should be displayed.',
5386
custom_help('directory',
5387
help='Branch whose tags should be displayed.'),
5357
5388
RegistryOption.from_kwargs('sort',
5358
5389
'Sort tags by different criteria.', title='Sorting',
5359
5390
alpha='Sort tags lexicographically (default).',
5379
self.add_cleanup(branch.lock_read().unlock)
5411
self.add_cleanup(branch.unlock)
5381
5413
graph = branch.repository.get_graph()
5382
5414
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5861
5893
def run_for_list(self):
5862
5894
tree = WorkingTree.open_containing('.')[0]
5863
self.add_cleanup(tree.lock_read().unlock)
5896
self.add_cleanup(tree.unlock)
5864
5897
manager = tree.get_shelf_manager()
5865
5898
shelves = manager.active_shelves()
5866
5899
if len(shelves) == 0:
5922
5955
To check what clean-tree will do, use --dry-run.
5924
takes_options = [Option('ignored', help='Delete all ignored files.'),
5957
takes_options = ['directory',
5958
Option('ignored', help='Delete all ignored files.'),
5925
5959
Option('detritus', help='Delete conflict files, merge'
5926
5960
' backups, and failed selftest dirs.'),
5927
5961
Option('unknown',
5930
5964
' deleting them.'),
5931
5965
Option('force', help='Do not prompt before deleting.')]
5932
5966
def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
5967
force=False, directory=u'.'):
5934
5968
from bzrlib.clean_tree import clean_tree
5935
5969
if not (unknown or ignored or detritus):
5939
clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus,
5940
dry_run=dry_run, no_prompt=force)
5973
clean_tree(directory, unknown=unknown, ignored=ignored,
5974
detritus=detritus, dry_run=dry_run, no_prompt=force)
5943
5977
class cmd_reference(Command):