~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-07-11 07:25:42 UTC
  • Revision ID: mbp@sourcefrog.net-20050711072542-6b1917e90ffc20cf
- merge john's plugins-have-test_suite.patch:
 - plugins can provide tests
 - plugins command shows more useful information

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    assert cmd.startswith("cmd_")
52
52
    return cmd[4:].replace('_','-')
53
53
 
54
 
 
55
54
def _parse_revision_str(revstr):
56
 
    """This handles a revision string -> revno.
57
 
 
58
 
    This always returns a list.  The list will have one element for 
 
55
    """This handles a revision string -> revno. 
59
56
 
60
57
    It supports integers directly, but everything else it
61
58
    defers for passing to Branch.get_revision_info()
332
329
    directory is shown.  Otherwise, only the status of the specified
333
330
    files or directories is reported.  If a directory is given, status
334
331
    is reported for everything inside that directory.
335
 
 
336
 
    If a revision is specified, the changes since that revision are shown.
337
332
    """
338
333
    takes_args = ['file*']
339
 
    takes_options = ['all', 'show-ids', 'revision']
 
334
    takes_options = ['all', 'show-ids']
340
335
    aliases = ['st', 'stat']
341
336
    
342
337
    def run(self, all=False, show_ids=False, file_list=None):
349
344
                file_list = None
350
345
        else:
351
346
            b = find_branch('.')
352
 
            
353
 
        from bzrlib.status import show_status
354
 
        show_status(b, show_unchanged=all, show_ids=show_ids,
355
 
                    specific_files=file_list)
 
347
        import status
 
348
        status.show_status(b, show_unchanged=all, show_ids=show_ids,
 
349
                           specific_files=file_list)
356
350
 
357
351
 
358
352
class cmd_cat_revision(Command):
594
588
        import tempfile
595
589
        cache_root = tempfile.mkdtemp()
596
590
 
597
 
        if revision is None:
598
 
            revision = [None]
599
 
        elif len(revision) > 1:
600
 
            raise BzrCommandError('bzr branch --revision takes exactly 1 revision value')
601
 
 
 
591
        if revision is not None:
 
592
            if len(revision) > 1:
 
593
                raise BzrCommandError('bzr branch --revision takes exactly 1 revision value')
602
594
        try:
603
595
            try:
604
596
                br_from = find_cached_branch(from_location, cache_root)
625
617
                    raise
626
618
            br_to = Branch(to_location, init=True)
627
619
 
628
 
            br_to.set_root_id(br_from.get_root_id())
629
 
 
630
 
            if revision:
631
 
                if revision[0] is None:
632
 
                    revno = br_from.revno()
633
 
                else:
634
 
                    revno, rev_id = br_from.get_revision_info(revision[0])
635
 
                try:
636
 
                    br_to.update_revisions(br_from, stop_revision=revno)
637
 
                except NoSuchRevision:
638
 
                    rmtree(to_location)
639
 
                    msg = "The branch %s has no revision %d." % (from_location,
640
 
                                                                 revno)
641
 
                    raise BzrCommandError(msg)
642
 
            
 
620
            revno = br_to.lookup_revision(revision[0])
 
621
            try:
 
622
                br_to.update_revisions(br_from, stop_revision=revno)
 
623
            except NoSuchRevision:
 
624
                rmtree(to_location)
 
625
                msg = "The branch %s has no revision %d." % (from_location,
 
626
                                                             revno)
 
627
                raise BzrCommandError(msg)
643
628
            merge((to_location, -1), (to_location, 0), this_dir=to_location,
644
629
                  check_clean=False, ignore_zero=True)
645
630
            from_location = pull_loc(br_from)
1254
1239
 
1255
1240
 
1256
1241
 
1257
 
class cmd_scan_cache(Command):
1258
 
    hidden = True
1259
 
    def run(self):
1260
 
        from bzrlib.hashcache import HashCache
1261
 
        import os
1262
 
 
1263
 
        c = HashCache('.')
1264
 
        c.read()
1265
 
        c.scan()
1266
 
            
1267
 
        print '%6d stats' % c.stat_count
1268
 
        print '%6d in hashcache' % len(c._cache)
1269
 
        print '%6d files removed from cache' % c.removed_count
1270
 
        print '%6d hashes updated' % c.update_count
1271
 
        print '%6d files changed too recently to cache' % c.danger_count
1272
 
 
1273
 
        if c.needs_write:
1274
 
            c.write()
1275
 
            
1276
 
 
1277
 
 
1278
1242
class cmd_upgrade(Command):
1279
1243
    """Upgrade branch storage to current format.
1280
1244
 
1303
1267
class cmd_selftest(Command):
1304
1268
    """Run internal test suite"""
1305
1269
    hidden = True
1306
 
    takes_options = ['verbose']
1307
 
    def run(self, verbose=False):
 
1270
    def run(self):
1308
1271
        from bzrlib.selftest import selftest
1309
 
        return int(not selftest(verbose=verbose))
 
1272
        return int(not selftest())
1310
1273
 
1311
1274
 
1312
1275
class cmd_version(Command):
1427
1390
    def run(self, revision=None):
1428
1391
        from bzrlib.merge import merge
1429
1392
        if revision is None:
1430
 
            revision = [-1]
 
1393
            revision = -1
1431
1394
        elif len(revision) != 1:
1432
1395
            raise BzrCommandError('bzr merge-revert --revision takes exactly 1 argument')
1433
1396
        merge(('.', revision[0]), parse_spec('.'),