changeset 6178:81afdd016867

debugancestor: make the index argument optional, defaulting to 00changelog.i
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 27 Feb 2008 14:58:44 -0800
parents 673d8a6bc709
children 36ab165abbe2
files mercurial/commands.py
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Feb 26 22:42:37 2008 +0100
+++ b/mercurial/commands.py	Wed Feb 27 14:58:44 2008 -0800
@@ -568,9 +568,17 @@
     finally:
         del wlock
 
-def debugancestor(ui, index, rev1, rev2):
+def debugancestor(ui, *opts):
     """find the ancestor revision of two revisions in a given index"""
-    r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
+    if len(opts) == 3:
+        index, rev1, rev2 = opts
+        r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
+    elif len(opts) == 2:
+        rev1, rev2 = opts
+        repo = hg.repository(ui)
+        r = repo.changelog
+    else:
+        raise util.Abort(_('either two or three arguments required'))
     a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
     ui.write("%d:%s\n" % (r.rev(a), hex(a)))
 
@@ -2850,7 +2858,8 @@
            _('forcibly copy over an existing managed file')),
          ] + walkopts + dryrunopts,
          _('hg copy [OPTION]... [SOURCE]... DEST')),
-    "debugancestor": (debugancestor, [], _('hg debugancestor INDEX REV1 REV2')),
+    "debugancestor": (debugancestor, [],
+                      _('hg debugancestor [INDEX] REV1 REV2')),
     "debugcheckstate": (debugcheckstate, [], _('hg debugcheckstate')),
     "debugcomplete":
         (debugcomplete,