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']
908
911
takes_args = ['location?']
909
912
takes_options = [
911
help='Create a specific format rather than the'
912
' current default format. Currently this '
913
' 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',
914
918
type=get_format_type),
916
920
def run(self, location=None, format=None):
917
921
from bzrlib.branch import Branch
923
format = get_format_type('default')
918
924
if location is None:
958
964
takes_args = ["location"]
959
965
takes_options = [Option('format',
960
help='Use a specific format rather than the'
961
' current default format. Currently this'
962
' 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',
963
970
type=get_format_type),
965
972
help='Allows branches in repository to have'
966
973
' a working tree')]
967
974
aliases = ["init-repo"]
968
975
def run(self, location, format=None, trees=False):
969
from bzrlib.bzrdir import BzrDirMetaFormat1
970
976
from bzrlib.transport import get_transport
971
977
if format is None:
972
format = BzrDirMetaFormat1()
978
format = get_format_type('default')
973
979
transport = get_transport(location)
974
980
if not transport.has('.'):
975
981
transport.mkdir('')
984
990
If files are listed, only the changes in those files are listed.
985
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
992
# TODO: Allow diff across branches.
993
1004
# TODO: Option to use external diff command; could be GNU diff, wdiff,
994
1005
# or a graphical diff.
996
1007
# TODO: Python difflib is not exactly the same as unidiff; should
997
1008
# either fix it up or prefer to use an external diff.
999
# TODO: If a directory is given, diff everything under that.
1001
1010
# TODO: Selected-file diff is inefficient and doesn't show you
1002
1011
# deleted files.
1004
1013
# TODO: This probably handles non-Unix newlines poorly.
1006
1015
takes_args = ['file*']
1007
takes_options = ['revision', 'diff-options']
1016
takes_options = ['revision', 'diff-options', 'prefix']
1008
1017
aliases = ['di', 'dif']
1010
1019
@display_command
1011
def run(self, revision=None, file_list=None, diff_options=None):
1020
def run(self, revision=None, file_list=None, diff_options=None,
1012
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(":")
1014
1037
tree1, file_list = internal_tree_files(file_list)
1030
1053
raise BzrCommandError("Can't specify -r with two branches")
1031
1054
if (len(revision) == 1) or (revision[1].spec is None):
1032
1055
return diff_cmd_helper(tree1, file_list, diff_options,
1057
old_label=old_label, new_label=new_label)
1034
1058
elif len(revision) == 2:
1035
1059
return diff_cmd_helper(tree1, file_list, diff_options,
1036
revision[0], revision[1])
1060
revision[0], revision[1],
1061
old_label=old_label, new_label=new_label)
1038
1063
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
1040
1065
if tree2 is not None:
1041
1066
return show_diff_trees(tree1, tree2, sys.stdout,
1042
1067
specific_files=file_list,
1043
external_diff_options=diff_options)
1068
external_diff_options=diff_options,
1069
old_label=old_label, new_label=new_label)
1045
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)
1048
1075
class cmd_deleted(Command):
1645
1672
takes_args = ['url?']
1646
1673
takes_options = [
1647
1674
Option('format',
1648
help='Upgrade to a specific format rather than the'
1649
' current default format. Currently this'
1650
' 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'
1652
1679
type=get_format_type),
1656
1683
def run(self, url='.', format=None):
1657
1684
from bzrlib.upgrade import upgrade
1686
format = get_format_type('default')
1658
1687
upgrade(url, format)
2255
2284
shown only at the top, unless the --all option is given.
2257
2286
# TODO: annotate directories; showing when each file was last changed
2258
# TODO: annotate a previous version of a file
2259
2287
# TODO: if the working copy is modified, show annotations on that
2260
2288
# with new uncommitted lines marked
2261
2289
aliases = ['blame', 'praise']
2262
2290
takes_args = ['filename']
2263
2291
takes_options = [Option('all', help='show annotations on all lines'),
2264
2292
Option('long', help='show date in annotations'),
2267
2296
@display_command
2268
def run(self, filename, all=False, long=False):
2297
def run(self, filename, all=False, long=False, revision=None):
2269
2298
from bzrlib.annotate import annotate_file
2270
2299
tree, relpath = WorkingTree.open_containing(filename)
2271
2300
branch = tree.branch
2272
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
2274
2309
file_id = tree.inventory.path2id(relpath)
2275
tree = branch.repository.revision_tree(branch.last_revision())
2310
tree = branch.repository.revision_tree(revision_id)
2276
2311
file_version = tree.inventory[file_id].revision
2277
2312
annotate_file(branch, file_version, file_id, long, all, sys.stdout)
2343
2378
class cmd_unbind(Command):
2344
"""Bind the current branch to its parent.
2379
"""Unbind the current branch from its master branch.
2346
2381
After unbinding, the local branch is considered independent.
2382
All subsequent commits will be local.
2349
2385
takes_args = []
2433
2469
CAUTION: Locks should only be broken when you are sure that the process
2434
2470
holding the lock has been stopped.
2472
You can get information on what locks are open via the 'bzr info' command.
2439
takes_args = ['location']
2440
takes_options = [Option('show',
2441
help="just show information on the lock, " \
2444
def run(self, location, show=False):
2445
raise NotImplementedError("sorry, break-lock is not complete yet; "
2446
"you can remove the 'held' directory manually to break the lock")
2477
takes_args = ['location?']
2479
def run(self, location=None, show=False):
2480
if location is None:
2482
control, relpath = bzrdir.BzrDir.open_containing(location)
2484
control.break_lock()
2485
except NotImplementedError:
2449
2490
# command-line interpretation helper for merge-related commands