Patchwork [39,of,41] basefilectx: move ancestors from filectx

login
register
mail settings
Submitter Sean Farley
Date Aug. 12, 2013, 4:27 p.m.
Message ID <7a90f67b36bc157dfecd.1376324855@laptop.local>
Download mbox | patch
Permalink /patch/2166/
State Accepted
Commit 0670422d58c6b08a755fdf3f080d9d089b4e91a6
Headers show

Comments

Sean Farley - Aug. 12, 2013, 4:27 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1376280350 18000
#      Sun Aug 11 23:05:50 2013 -0500
# Node ID 7a90f67b36bc157dfecd81512b62e7eccbfbce0c
# Parent  6a5e7efe1ce482a3d41dea16496abdd03558217d
basefilectx: move ancestors from filectx

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -708,10 +708,22 @@ 
             f, n = v
             return filectx(self._repo, f, fileid=n, filelog=flcache[f])
 
         return None
 
+    def ancestors(self, followfirst=False):
+        visit = {}
+        c = self
+        cut = followfirst and 1 or None
+        while True:
+            for parent in c.parents()[:cut]:
+                visit[(parent.rev(), parent.node())] = parent
+            if not visit:
+                break
+            c = visit.pop(max(visit))
+            yield c
+
 class filectx(basefilectx):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
     def __init__(self, repo, path, changeid=None, fileid=None,
                  filelog=None, changectx=None):
@@ -799,22 +811,10 @@ 
         # hard for renames
         c = self._filelog.children(self._filenode)
         return [filectx(self._repo, self._path, fileid=x,
                         filelog=self._filelog) for x in c]
 
-    def ancestors(self, followfirst=False):
-        visit = {}
-        c = self
-        cut = followfirst and 1 or None
-        while True:
-            for parent in c.parents()[:cut]:
-                visit[(parent.rev(), parent.node())] = parent
-            if not visit:
-                break
-            c = visit.pop(max(visit))
-            yield c
-
     def copies(self, c2):
         if not util.safehasattr(self, "_copycache"):
             self._copycache = {}
         sc2 = str(c2)
         if sc2 not in self._copycache: