557
557
takes_args = ['location?']
558
558
takes_options = [
559
559
Option('tree', help='Show revno of working tree'),
563
def run(self, tree=False, location=u'.'):
564
def run(self, tree=False, location=u'.', revision=None):
565
if revision is not None and tree:
566
raise errors.BzrCommandError(gettext("--tree and --revision can "
567
"not be used together"))
566
571
wt = WorkingTree.open_containing(location)[0]
567
572
self.add_cleanup(wt.lock_read().unlock)
568
573
except (errors.NoWorkingTree, errors.NotLocalUrl):
569
574
raise errors.NoWorkingTree(location)
570
576
revid = wt.last_revision()
572
revno_t = wt.branch.revision_id_to_dotted_revno(revid)
573
except errors.NoSuchRevision:
575
revno = ".".join(str(n) for n in revno_t)
577
578
b = Branch.open_containing(location)[0]
578
579
self.add_cleanup(b.lock_read().unlock)
581
if len(revision) != 1:
582
raise errors.BzrCommandError(gettext(
583
"Tags can only be placed on a single revision, "
585
revid = revision[0].as_revision_id(b)
587
revid = b.last_revision()
589
revno_t = b.revision_id_to_dotted_revno(revid)
590
except errors.NoSuchRevision:
592
revno = ".".join(str(n) for n in revno_t)
580
593
self.cleanup_now()
581
self.outf.write(str(revno) + '\n')
594
self.outf.write(revno + '\n')
584
597
class cmd_revision_info(Command):