~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2006-05-05 00:44:25 UTC
  • mfrom: (1697 +trunk)
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060505004425-55597abf11998087
Merge HEAD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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()
 
93
        return format
90
94
    if typestring == "knit":
91
95
        format = bzrdir.BzrDirMetaFormat1()
92
96
        format.repository_format = bzrlib.repository.RepositoryFormatKnit1()
93
97
        return format
94
 
    msg = "No known bzr-dir format %s. Supported types are: weave, metadir\n" %\
95
 
        (typestring)
 
98
    msg = "Unknown bzr format %s. Current formats are: default, knit,\n" \
 
99
          "metaweave and weave" % typestring
96
100
    raise BzrCommandError(msg)
97
101
 
98
102
 
765
769
 
766
770
 
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.
 
773
 
 
774
    This command will show all known locations and formats associated to the
 
775
    tree, branch or repository.  Statistical information is included with
 
776
    each report.
 
777
 
 
778
    Branches and working trees will also report any missing revisions.
 
779
    """
 
780
    takes_args = ['location?']
770
781
    takes_options = ['verbose']
771
 
    
 
782
 
772
783
    @display_command
773
 
    def run(self, branch=None, verbose=False):
774
 
        import bzrlib.info
775
 
        bzrlib.info.show_bzrdir_info(bzrdir.BzrDir.open_containing(branch)[0],
776
 
                                     verbose=verbose)
 
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],
 
787
                         verbose=verbose)
777
788
 
778
789
 
779
790
class cmd_remove(Command):
900
911
    takes_args = ['location?']
901
912
    takes_options = [
902
913
                     Option('format', 
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),
907
919
                     ]
908
920
    def run(self, location=None, format=None):
909
921
        from bzrlib.branch import Branch
 
922
        if format is None:
 
923
            format = get_format_type('default')
910
924
        if location is None:
911
925
            location = u'.'
912
926
        else:
949
963
    """
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),
956
971
                     Option('trees',
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'
1657
 
                                 ' "knit".',
 
1668
                            help='Upgrade to a specific format. Current formats'
 
1669
                                 ' are: default, knit, metaweave and weave.'
 
1670
                                 ' Default is knit; metaweave and weave are'
 
1671
                                 ' deprecated',
1658
1672
                            type=get_format_type),
1659
1673
                    ]
1660
1674
 
1661
1675
 
1662
1676
    def run(self, url='.', format=None):
1663
1677
        from bzrlib.upgrade import upgrade
 
1678
        if format is None:
 
1679
            format = get_format_type('default')
1664
1680
        upgrade(url, format)
1665
1681
 
1666
1682
 
2261
2277
    shown only at the top, unless the --all option is given.
2262
2278
    """
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'),
 
2286
                     'revision'
2271
2287
                     ]
2272
2288
 
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()
2279
2295
        try:
 
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')
 
2300
            else:
 
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)
2284
2306
        finally: