comparison mercurial/commands.py @ 6189:81cbb5dfdec0

Make hg debugancestor accept -R by making it an optionalrepo command.
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 29 Feb 2008 01:25:31 +0100
parents 3b0c2b71e0d7
children a79d9408806f
comparison
equal deleted inserted replaced
6188:3b0c2b71e0d7 6189:81cbb5dfdec0
566 try: 566 try:
567 return cmdutil.copy(ui, repo, pats, opts) 567 return cmdutil.copy(ui, repo, pats, opts)
568 finally: 568 finally:
569 del wlock 569 del wlock
570 570
571 def debugancestor(ui, *args): 571 def debugancestor(ui, repo, *args):
572 """find the ancestor revision of two revisions in a given index""" 572 """find the ancestor revision of two revisions in a given index"""
573 if len(args) == 3: 573 if len(args) == 3:
574 index, rev1, rev2 = args 574 index, rev1, rev2 = args
575 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index) 575 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
576 elif len(args) == 2: 576 elif len(args) == 2:
577 if not repo:
578 raise util.Abort(_("There is no Mercurial repository here "
579 "(.hg not found)"))
577 rev1, rev2 = args 580 rev1, rev2 = args
578 repo = hg.repository(ui)
579 r = repo.changelog 581 r = repo.changelog
580 else: 582 else:
581 raise util.Abort(_('either two or three arguments required')) 583 raise util.Abort(_('either two or three arguments required'))
582 a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) 584 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
583 ui.write("%d:%s\n" % (r.rev(a), hex(a))) 585 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
3160 _('hg update [-C] [-d DATE] [[-r] REV]')), 3162 _('hg update [-C] [-d DATE] [[-r] REV]')),
3161 "verify": (verify, [], _('hg verify')), 3163 "verify": (verify, [], _('hg verify')),
3162 "version": (version_, [], _('hg version')), 3164 "version": (version_, [], _('hg version')),
3163 } 3165 }
3164 3166
3165 norepo = ("clone init version help debugancestor debugcomplete debugdata" 3167 norepo = ("clone init version help debugcomplete debugdata"
3166 " debugindex debugindexdot debugdate debuginstall debugfsinfo") 3168 " debugindex debugindexdot debugdate debuginstall debugfsinfo")
3167 optionalrepo = ("identify paths serve showconfig") 3169 optionalrepo = ("identify paths serve showconfig debugancestor")