[PATCH 39 of 41] basefilectx: move ancestors from filectx
Sean Farley
sean.michael.farley at gmail.com
Mon Aug 12 11:27:35 CDT 2013
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1376280350 18000
# Sun Aug 11 23:05:50 2013 -0500
# Node ID 7a90f67b36bc157dfecd81512b62e7eccbfbce0c
# Parent 6a5e7efe1ce482a3d41dea16496abdd03558217d
basefilectx: move ancestors from filectx
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:
More information about the Mercurial-devel
mailing list