85
85
"""Parse and return a format specifier."""
86
86
if typestring == "weave":
87
87
return bzrdir.BzrDirFormat6()
88
if typestring == "metadir":
88
if typestring == "default":
89
89
return bzrdir.BzrDirMetaFormat1()
90
if typestring == "metaweave":
91
format = bzrdir.BzrDirMetaFormat1()
92
format.repository_format = bzrlib.repository.RepositoryFormat7()
90
94
if typestring == "knit":
91
95
format = bzrdir.BzrDirMetaFormat1()
92
96
format.repository_format = bzrlib.repository.RepositoryFormatKnit1()
94
msg = "No known bzr-dir format %s. Supported types are: weave, metadir\n" %\
98
msg = "Unknown bzr format %s. Current formats are: default, knit,\n" \
99
"metaweave and weave" % typestring
96
100
raise BzrCommandError(msg)
767
771
class cmd_info(Command):
768
"""Show statistical information about a branch."""
769
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?']
770
781
takes_options = ['verbose']
773
def run(self, branch=None, verbose=False):
775
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],
779
790
class cmd_remove(Command):
900
911
takes_args = ['location?']
901
912
takes_options = [
903
help='Create a specific format rather than the'
904
' current default format. Currently supports:'
905
' metadir, knit, and weave',
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',
906
918
type=get_format_type),
908
920
def run(self, location=None, format=None):
909
921
from bzrlib.branch import Branch
923
format = get_format_type('default')
910
924
if location is None:
950
964
takes_args = ["location"]
951
965
takes_options = [Option('format',
952
help='Use a specific format rather than the'
953
' current default format. Currently this'
954
' 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',
955
970
type=get_format_type),
957
972
help='Allows branches in repository to have'
958
973
' a working tree')]
959
974
aliases = ["init-repo"]
960
975
def run(self, location, format=None, trees=False):
961
from bzrlib.bzrdir import BzrDirMetaFormat1
962
976
from bzrlib.transport import get_transport
963
977
if format is None:
964
format = BzrDirMetaFormat1()
978
format = get_format_type('default')
965
979
transport = get_transport(location)
966
980
if not transport.has('.'):
967
981
transport.mkdir('')
1651
1665
takes_args = ['url?']
1652
1666
takes_options = [
1653
1667
Option('format',
1654
help='Upgrade to a specific format rather than the'
1655
' current default format. Currently this'
1656
' option accepts "weave", "metadir" and'
1668
help='Upgrade to a specific format. Current formats'
1669
' are: default, knit, metaweave and weave.'
1670
' Default is knit; metaweave and weave are'
1658
1672
type=get_format_type),
1662
1676
def run(self, url='.', format=None):
1663
1677
from bzrlib.upgrade import upgrade
1679
format = get_format_type('default')
1664
1680
upgrade(url, format)
2261
2277
shown only at the top, unless the --all option is given.
2263
2279
# TODO: annotate directories; showing when each file was last changed
2264
# TODO: annotate a previous version of a file
2265
2280
# TODO: if the working copy is modified, show annotations on that
2266
2281
# with new uncommitted lines marked
2267
2282
aliases = ['blame', 'praise']
2268
2283
takes_args = ['filename']
2269
2284
takes_options = [Option('all', help='show annotations on all lines'),
2270
2285
Option('long', help='show date in annotations'),
2273
2289
@display_command
2274
def run(self, filename, all=False, long=False):
2290
def run(self, filename, all=False, long=False, revision=None):
2275
2291
from bzrlib.annotate import annotate_file
2276
2292
tree, relpath = WorkingTree.open_containing(filename)
2277
2293
branch = tree.branch
2278
2294
branch.lock_read()
2296
if revision is None:
2297
revision_id = branch.last_revision()
2298
elif len(revision) != 1:
2299
raise BzrCommandError('bzr annotate --revision takes exactly 1 argument')
2301
revision_id = revision[0].in_history(branch).rev_id
2280
2302
file_id = tree.inventory.path2id(relpath)
2281
tree = branch.repository.revision_tree(branch.last_revision())
2303
tree = branch.repository.revision_tree(revision_id)
2282
2304
file_version = tree.inventory[file_id].revision
2283
2305
annotate_file(branch, file_version, file_id, long, all, sys.stdout)