85
84
"""Parse and return a format specifier."""
86
85
if typestring == "weave":
87
86
return bzrdir.BzrDirFormat6()
88
if typestring == "metadir":
87
if typestring == "default":
89
88
return bzrdir.BzrDirMetaFormat1()
89
if typestring == "metaweave":
90
format = bzrdir.BzrDirMetaFormat1()
91
format.repository_format = bzrlib.repository.RepositoryFormat7()
90
93
if typestring == "knit":
91
94
format = bzrdir.BzrDirMetaFormat1()
92
95
format.repository_format = bzrlib.repository.RepositoryFormatKnit1()
94
msg = "No known bzr-dir format %s. Supported types are: weave, metadir\n" %\
97
msg = "Unknown bzr format %s. Current formats are: default, knit,\n" \
98
"metaweave and weave" % typestring
96
99
raise BzrCommandError(msg)
477
480
from bzrlib.transport import get_transport
479
tree_from = WorkingTree.open_containing(u'.')[0]
480
br_from = tree_from.branch
481
stored_loc = tree_from.branch.get_push_location()
482
br_from = Branch.open_containing('.')[0]
483
stored_loc = br_from.get_push_location()
482
484
if location is None:
483
485
if stored_loc is None:
484
486
raise BzrCommandError("No push location known or specified.")
562
564
aliases = ['get', 'clone']
564
566
def run(self, from_location, to_location=None, revision=None, basis=None):
567
from bzrlib.osutils import rmtree
565
568
if revision is None:
566
569
revision = [None]
567
570
elif len(revision) > 1:
643
646
--basis is to speed up checking out from remote branches. When specified, it
644
647
uses the inventory and file contents from the basis branch in preference to the
645
branch being checked out. [Not implemented yet.]
648
branch being checked out.
647
650
takes_args = ['branch_location?', 'to_location?']
648
651
takes_options = ['revision', # , 'basis']
768
771
class cmd_info(Command):
769
"""Show statistical information about a branch."""
770
takes_args = ['branch?']
772
"""Show information about a working tree, branch or repository.
774
This command will show all known locations and formats associated to the
775
tree, branch or repository. Statistical information is included with
778
Branches and working trees will also report any missing revisions.
780
takes_args = ['location?']
771
781
takes_options = ['verbose']
774
def run(self, branch=None, verbose=False):
776
bzrlib.info.show_bzrdir_info(bzrdir.BzrDir.open_containing(branch)[0],
784
def run(self, location=None, verbose=False):
785
from bzrlib.info import show_bzrdir_info
786
show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
780
790
class cmd_remove(Command):
901
911
takes_args = ['location?']
902
912
takes_options = [
904
help='Create a specific format rather than the'
905
' current default format. Currently this '
906
' option only accepts "metadir"',
914
help='Specify a format for this branch. Current'
915
' formats are: default, knit, metaweave and'
916
' weave. Default is knit; metaweave and'
917
' weave are deprecated',
907
918
type=get_format_type),
909
920
def run(self, location=None, format=None):
910
921
from bzrlib.branch import Branch
923
format = get_format_type('default')
911
924
if location is None:
951
964
takes_args = ["location"]
952
965
takes_options = [Option('format',
953
help='Use a specific format rather than the'
954
' current default format. Currently this'
955
' option accepts "weave", "metadir" and "knit"',
966
help='Specify a format for this repository.'
967
' Current formats are: default, knit,'
968
' metaweave and weave. Default is knit;'
969
' metaweave and weave are deprecated',
956
970
type=get_format_type),
958
972
help='Allows branches in repository to have'
959
973
' a working tree')]
960
974
aliases = ["init-repo"]
961
975
def run(self, location, format=None, trees=False):
962
from bzrlib.bzrdir import BzrDirMetaFormat1
963
976
from bzrlib.transport import get_transport
964
977
if format is None:
965
format = BzrDirMetaFormat1()
978
format = get_format_type('default')
966
979
transport = get_transport(location)
967
980
if not transport.has('.'):
968
981
transport.mkdir('')
977
990
If files are listed, only the changes in those files are listed.
978
991
Otherwise, all changes for the tree are listed.
993
"bzr diff -p1" is equivalent to "bzr diff --prefix old/:new/", and
994
produces patches suitable for "patch -p1".
1000
bzr diff --diff-prefix old/:new/
1001
bzr diff bzr.mine bzr.dev
985
# TODO: Allow diff across branches.
986
1004
# TODO: Option to use external diff command; could be GNU diff, wdiff,
987
1005
# or a graphical diff.
989
1007
# TODO: Python difflib is not exactly the same as unidiff; should
990
1008
# either fix it up or prefer to use an external diff.
992
# TODO: If a directory is given, diff everything under that.
994
1010
# TODO: Selected-file diff is inefficient and doesn't show you
995
1011
# deleted files.
997
1013
# TODO: This probably handles non-Unix newlines poorly.
999
1015
takes_args = ['file*']
1000
takes_options = ['revision', 'diff-options']
1016
takes_options = ['revision', 'diff-options', 'prefix']
1001
1017
aliases = ['di', 'dif']
1003
1019
@display_command
1004
def run(self, revision=None, file_list=None, diff_options=None):
1020
def run(self, revision=None, file_list=None, diff_options=None,
1005
1022
from bzrlib.diff import diff_cmd_helper, show_diff_trees
1024
if (prefix is None) or (prefix == '0'):
1032
if not ':' in prefix:
1033
raise BzrError("--diff-prefix expects two values separated by a colon")
1034
old_label, new_label = prefix.split(":")
1007
1037
tree1, file_list = internal_tree_files(file_list)
1023
1053
raise BzrCommandError("Can't specify -r with two branches")
1024
1054
if (len(revision) == 1) or (revision[1].spec is None):
1025
1055
return diff_cmd_helper(tree1, file_list, diff_options,
1057
old_label=old_label, new_label=new_label)
1027
1058
elif len(revision) == 2:
1028
1059
return diff_cmd_helper(tree1, file_list, diff_options,
1029
revision[0], revision[1])
1060
revision[0], revision[1],
1061
old_label=old_label, new_label=new_label)
1031
1063
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
1033
1065
if tree2 is not None:
1034
1066
return show_diff_trees(tree1, tree2, sys.stdout,
1035
1067
specific_files=file_list,
1036
external_diff_options=diff_options)
1068
external_diff_options=diff_options,
1069
old_label=old_label, new_label=new_label)
1038
return diff_cmd_helper(tree1, file_list, diff_options)
1071
return diff_cmd_helper(tree1, file_list, diff_options,
1072
old_label=old_label, new_label=new_label)
1041
1075
class cmd_deleted(Command):
1638
1672
takes_args = ['url?']
1639
1673
takes_options = [
1640
1674
Option('format',
1641
help='Upgrade to a specific format rather than the'
1642
' current default format. Currently this'
1643
' option accepts "weave", "metadir" and'
1675
help='Upgrade to a specific format. Current formats'
1676
' are: default, knit, metaweave and weave.'
1677
' Default is knit; metaweave and weave are'
1645
1679
type=get_format_type),
1649
1683
def run(self, url='.', format=None):
1650
1684
from bzrlib.upgrade import upgrade
1686
format = get_format_type('default')
1651
1687
upgrade(url, format)
2248
2284
shown only at the top, unless the --all option is given.
2250
2286
# TODO: annotate directories; showing when each file was last changed
2251
# TODO: annotate a previous version of a file
2252
2287
# TODO: if the working copy is modified, show annotations on that
2253
2288
# with new uncommitted lines marked
2254
2289
aliases = ['blame', 'praise']
2255
2290
takes_args = ['filename']
2256
2291
takes_options = [Option('all', help='show annotations on all lines'),
2257
2292
Option('long', help='show date in annotations'),
2260
2296
@display_command
2261
def run(self, filename, all=False, long=False):
2297
def run(self, filename, all=False, long=False, revision=None):
2262
2298
from bzrlib.annotate import annotate_file
2263
2299
tree, relpath = WorkingTree.open_containing(filename)
2264
2300
branch = tree.branch
2265
2301
branch.lock_read()
2303
if revision is None:
2304
revision_id = branch.last_revision()
2305
elif len(revision) != 1:
2306
raise BzrCommandError('bzr annotate --revision takes exactly 1 argument')
2308
revision_id = revision[0].in_history(branch).rev_id
2267
2309
file_id = tree.inventory.path2id(relpath)
2268
tree = branch.repository.revision_tree(branch.last_revision())
2310
tree = branch.repository.revision_tree(revision_id)
2269
2311
file_version = tree.inventory[file_id].revision
2270
2312
annotate_file(branch, file_version, file_id, long, all, sys.stdout)
2426
2468
CAUTION: Locks should only be broken when you are sure that the process
2427
2469
holding the lock has been stopped.
2471
You can get information on what locks are open via the 'bzr info' command.
2432
takes_args = ['location']
2433
takes_options = [Option('show',
2434
help="just show information on the lock, " \
2437
def run(self, location, show=False):
2438
raise NotImplementedError("sorry, break-lock is not complete yet; "
2439
"you can remove the 'held' directory manually to break the lock")
2476
takes_args = ['location?']
2478
def run(self, location=None, show=False):
2479
if location is None:
2481
control, relpath = bzrdir.BzrDir.open_containing(location)
2483
control.break_lock()
2484
except NotImplementedError:
2442
2489
# command-line interpretation helper for merge-related commands