~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-30 16:59:21 UTC
  • mto: (4493.2.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4496.
  • Revision ID: v.ladeuil+lp@free.fr-20090630165921-jdg42f5unm33nz8a
Fix failing test.

* bzrlib/tests/blackbox/test_revision_info.py:
Minor cleanups.

* bzrlib/tests/blackbox/test_revno.py:
Some cleanups.

* bzrlib/builtins.py: 
(cmd_revno.run): Don't open WT if we don't need to.

Show diffs side-by-side

added added

removed removed

Lines of Context:
480
480
 
481
481
    @display_command
482
482
    def run(self, tree=False, location=u'.'):
483
 
        try:
484
 
            wt = WorkingTree.open_containing(location)[0]
485
 
            b = wt.branch
486
 
            wt.lock_read()
487
 
        except (errors.NoWorkingTree, errors.NotLocalUrl):
488
 
            wt = None
489
 
            b = Branch.open_containing(location)[0]
490
 
            b.lock_read()
491
 
        try:
492
 
            if tree:
493
 
                if wt is None:
494
 
                    raise errors.NoWorkingTree(location)
 
483
        if tree:
 
484
            try:
 
485
                wt = WorkingTree.open_containing(location)[0]
 
486
                wt.lock_read()
 
487
            except (errors.NoWorkingTree, errors.NotLocalUrl):
 
488
                raise errors.NoWorkingTree(location)
 
489
            try:
495
490
                revid = wt.last_revision()
496
491
                try:
497
492
                    revno_t = wt.branch.revision_id_to_dotted_revno(revid)
498
493
                except errors.NoSuchRevision:
499
494
                    revno_t = ('???',)
500
495
                revno = ".".join(str(n) for n in revno_t)
501
 
            else:
 
496
            finally:
 
497
                wt.unlock()
 
498
        else:
 
499
            b = Branch.open_containing(location)[0]
 
500
            b.lock_read()
 
501
            try:
502
502
                revno = b.revno()
503
 
        finally:
504
 
            if wt is None:
 
503
            finally:
505
504
                b.unlock()
506
 
            else:
507
 
                wt.unlock()
 
505
 
508
506
        self.outf.write(str(revno) + '\n')
509
507
 
510
508