88
88
"""Parse and return a format specifier."""
89
89
if typestring == "weave":
90
90
return bzrdir.BzrDirFormat6()
91
if typestring == "metadir":
91
if typestring == "default":
92
92
return bzrdir.BzrDirMetaFormat1()
93
if typestring == "metaweave":
94
format = bzrdir.BzrDirMetaFormat1()
95
format.repository_format = bzrlib.repository.RepositoryFormat7()
93
97
if typestring == "knit":
94
98
format = bzrdir.BzrDirMetaFormat1()
95
99
format.repository_format = bzrlib.repository.RepositoryFormatKnit1()
97
msg = "No known bzr-dir format %s. Supported types are: weave, metadir\n" %\
101
msg = "Unknown bzr format %s. Current formats are: default, knit,\n" \
102
"metaweave and weave" % typestring
99
103
raise BzrCommandError(msg)
497
501
from bzrlib.transport import get_transport
499
tree_from = WorkingTree.open_containing(u'.')[0]
500
br_from = tree_from.branch
501
stored_loc = tree_from.branch.get_push_location()
503
br_from = Branch.open_containing('.')[0]
504
stored_loc = br_from.get_push_location()
503
505
if location is None:
504
506
if stored_loc is None:
505
507
raise BzrCommandError("No push location known or specified.")
592
594
def run(self, from_location, to_location=None, revision=None, basis=None):
593
595
from bzrlib.transport import get_transport
596
from bzrlib.osutils import rmtree
594
597
if revision is None:
595
598
revision = [None]
596
599
elif len(revision) > 1:
674
677
--basis is to speed up checking out from remote branches. When specified, it
675
678
uses the inventory and file contents from the basis branch in preference to the
676
branch being checked out. [Not implemented yet.]
679
branch being checked out.
678
681
takes_args = ['branch_location?', 'to_location?']
679
682
takes_options = ['revision', # , 'basis']
799
802
class cmd_info(Command):
800
"""Show statistical information about a branch."""
801
takes_args = ['branch?']
803
"""Show information about a working tree, branch or repository.
805
This command will show all known locations and formats associated to the
806
tree, branch or repository. Statistical information is included with
809
Branches and working trees will also report any missing revisions.
811
takes_args = ['location?']
802
812
takes_options = ['verbose']
805
def run(self, branch=None, verbose=False):
807
bzrlib.info.show_bzrdir_info(bzrdir.BzrDir.open_containing(branch)[0],
815
def run(self, location=None, verbose=False):
816
from bzrlib.info import show_bzrdir_info
817
show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
811
821
class cmd_remove(Command):
943
953
takes_args = ['location?']
944
954
takes_options = [
946
help='Create a specific format rather than the'
947
' current default format. Currently this '
948
' option only accepts "metadir"',
956
help='Specify a format for this branch. Current'
957
' formats are: default, knit, metaweave and'
958
' weave. Default is knit; metaweave and'
959
' weave are deprecated',
949
960
type=get_format_type),
951
962
def run(self, location=None, format=None):
952
963
from bzrlib.branch import Branch
965
format = get_format_type('default')
953
966
if location is None:
993
1006
takes_args = ["location"]
994
1007
takes_options = [Option('format',
995
help='Use a specific format rather than the'
996
' current default format. Currently this'
997
' option accepts "weave", "metadir" and "knit"',
1008
help='Specify a format for this repository.'
1009
' Current formats are: default, knit,'
1010
' metaweave and weave. Default is knit;'
1011
' metaweave and weave are deprecated',
998
1012
type=get_format_type),
1000
1014
help='Allows branches in repository to have'
1001
1015
' a working tree')]
1002
1016
aliases = ["init-repo"]
1003
1017
def run(self, location, format=None, trees=False):
1004
from bzrlib.bzrdir import BzrDirMetaFormat1
1005
1018
from bzrlib.transport import get_transport
1006
1019
if format is None:
1007
format = BzrDirMetaFormat1()
1020
format = get_format_type('default')
1008
1021
transport = get_transport(location)
1009
1022
if not transport.has('.'):
1010
1023
transport.mkdir('')
1019
1032
If files are listed, only the changes in those files are listed.
1020
1033
Otherwise, all changes for the tree are listed.
1035
"bzr diff -p1" is equivalent to "bzr diff --prefix old/:new/", and
1036
produces patches suitable for "patch -p1".
1025
1041
bzr diff -r1..2
1042
bzr diff --diff-prefix old/:new/
1043
bzr diff bzr.mine bzr.dev
1027
# TODO: Allow diff across branches.
1028
1046
# TODO: Option to use external diff command; could be GNU diff, wdiff,
1029
1047
# or a graphical diff.
1031
1049
# TODO: Python difflib is not exactly the same as unidiff; should
1032
1050
# either fix it up or prefer to use an external diff.
1034
# TODO: If a directory is given, diff everything under that.
1036
1052
# TODO: Selected-file diff is inefficient and doesn't show you
1037
1053
# deleted files.
1039
1055
# TODO: This probably handles non-Unix newlines poorly.
1041
1057
takes_args = ['file*']
1042
takes_options = ['revision', 'diff-options']
1058
takes_options = ['revision', 'diff-options', 'prefix']
1043
1059
aliases = ['di', 'dif']
1044
1060
encoding_type = 'exact'
1046
1062
@display_command
1047
def run(self, revision=None, file_list=None, diff_options=None):
1063
def run(self, revision=None, file_list=None, diff_options=None,
1048
1065
from bzrlib.diff import diff_cmd_helper, show_diff_trees
1067
if (prefix is None) or (prefix == '0'):
1075
if not ':' in prefix:
1076
raise BzrError("--diff-prefix expects two values separated by a colon")
1077
old_label, new_label = prefix.split(":")
1050
1080
tree1, file_list = internal_tree_files(file_list)
1066
1096
raise BzrCommandError("Can't specify -r with two branches")
1067
1097
if (len(revision) == 1) or (revision[1].spec is None):
1068
1098
return diff_cmd_helper(tree1, file_list, diff_options,
1100
old_label=old_label, new_label=new_label)
1070
1101
elif len(revision) == 2:
1071
1102
return diff_cmd_helper(tree1, file_list, diff_options,
1072
revision[0], revision[1])
1103
revision[0], revision[1],
1104
old_label=old_label, new_label=new_label)
1074
1106
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
1076
1108
if tree2 is not None:
1077
1109
return show_diff_trees(tree1, tree2, sys.stdout,
1078
1110
specific_files=file_list,
1079
external_diff_options=diff_options)
1111
external_diff_options=diff_options,
1112
old_label=old_label, new_label=new_label)
1081
return diff_cmd_helper(tree1, file_list, diff_options)
1114
return diff_cmd_helper(tree1, file_list, diff_options,
1115
old_label=old_label, new_label=new_label)
1084
1118
class cmd_deleted(Command):
1682
1716
takes_args = ['url?']
1683
1717
takes_options = [
1684
1718
Option('format',
1685
help='Upgrade to a specific format rather than the'
1686
' current default format. Currently this'
1687
' option accepts "weave", "metadir" and'
1719
help='Upgrade to a specific format. Current formats'
1720
' are: default, knit, metaweave and weave.'
1721
' Default is knit; metaweave and weave are'
1689
1723
type=get_format_type),
1693
1727
def run(self, url='.', format=None):
1694
1728
from bzrlib.upgrade import upgrade
1730
format = get_format_type('default')
1695
1731
upgrade(url, format)
2294
2330
shown only at the top, unless the --all option is given.
2296
2332
# TODO: annotate directories; showing when each file was last changed
2297
# TODO: annotate a previous version of a file
2298
2333
# TODO: if the working copy is modified, show annotations on that
2299
2334
# with new uncommitted lines marked
2300
2335
aliases = ['blame', 'praise']
2301
2336
takes_args = ['filename']
2302
2337
takes_options = [Option('all', help='show annotations on all lines'),
2303
2338
Option('long', help='show date in annotations'),
2306
2342
@display_command
2307
def run(self, filename, all=False, long=False):
2343
def run(self, filename, all=False, long=False, revision=None):
2308
2344
from bzrlib.annotate import annotate_file
2309
2345
tree, relpath = WorkingTree.open_containing(filename)
2310
2346
branch = tree.branch
2311
2347
branch.lock_read()
2349
if revision is None:
2350
revision_id = branch.last_revision()
2351
elif len(revision) != 1:
2352
raise BzrCommandError('bzr annotate --revision takes exactly 1 argument')
2354
revision_id = revision[0].in_history(branch).rev_id
2313
2355
file_id = tree.inventory.path2id(relpath)
2314
tree = branch.repository.revision_tree(branch.last_revision())
2356
tree = branch.repository.revision_tree(revision_id)
2315
2357
file_version = tree.inventory[file_id].revision
2316
2358
annotate_file(branch, file_version, file_id, long, all, sys.stdout)
2382
2424
class cmd_unbind(Command):
2383
"""Bind the current branch to its parent.
2425
"""Unbind the current branch from its master branch.
2385
2427
After unbinding, the local branch is considered independent.
2428
All subsequent commits will be local.
2388
2431
takes_args = []
2472
2515
CAUTION: Locks should only be broken when you are sure that the process
2473
2516
holding the lock has been stopped.
2518
You can get information on what locks are open via the 'bzr info' command.
2478
takes_args = ['location']
2479
takes_options = [Option('show',
2480
help="just show information on the lock, " \
2483
def run(self, location, show=False):
2484
raise NotImplementedError("sorry, break-lock is not complete yet; "
2485
"you can remove the 'held' directory manually to break the lock")
2523
takes_args = ['location?']
2525
def run(self, location=None, show=False):
2526
if location is None:
2528
control, relpath = bzrdir.BzrDir.open_containing(location)
2530
control.break_lock()
2531
except NotImplementedError:
2488
2536
# command-line interpretation helper for merge-related commands