Patchwork [6,of,8,ancestor-ish] revlog: use context ancestor instead of changelog ancestor

login
register
mail settings
Submitter Mads Kiilerich
Date April 7, 2014, 9:18 p.m.
Message ID <d1c551696f45860a80a2.1396905502@mk-desktop>
Download mbox | patch
Permalink /patch/4261/
State Accepted
Commit a05d694599f94c14c989740272db0996633f01be
Headers show

Comments

Mads Kiilerich - April 7, 2014, 9:18 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1396905471 -7200
#      Mon Apr 07 23:17:51 2014 +0200
# Node ID d1c551696f45860a80a27b06fa71076c72077f82
# Parent  9dc50181e9a9ee73abaa0d630ab639b8042d6585
revlog: use context ancestor instead of changelog ancestor

We want to move in this direction.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -320,7 +320,7 @@  def adds(repo, subset, x):
 
 def ancestor(repo, subset, x):
     """``ancestor(*changeset)``
-    Greatest common ancestor of the changesets.
+    A greatest common ancestor of the changesets.
 
     Accepts 0 or more changesets.
     Will return empty list when passed no args.
@@ -332,18 +332,15 @@  def ancestor(repo, subset, x):
     anc = None
 
     # (getset(repo, rl, i) for i in l) generates a list of lists
-    rev = repo.changelog.rev
-    ancestor = repo.changelog.ancestor
-    node = repo.changelog.node
     for revs in (getset(repo, rl, i) for i in l):
         for r in revs:
             if anc is None:
-                anc = r
+                anc = repo[r]
             else:
-                anc = rev(ancestor(node(anc), node(r)))
-
-    if anc is not None and anc in subset:
-        return baseset([anc])
+                anc = anc.ancestor(repo[r])
+
+    if anc is not None and anc.rev() in subset:
+        return baseset([anc.rev()])
     return baseset([])
 
 def _ancestors(repo, subset, x, followfirst=False):