# HG changeset patch # User Matt Mackall # Date 2011-04-04 21:21:57 # Node ID 653121e6941f9fafcd2a7c9063b18f98ec66aa48 # Parent 10c7d92ac482789f5392314ecba1552c81309490 filectx: introduce p1/p2 convenience methods diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -402,6 +402,15 @@ class filectx(object): return [filectx(self._repo, p, fileid=n, filelog=l) for p, n, l in pl if n != nullid] + def p1(self): + return self.parents()[0] + + def p2(self): + p = self.parents() + if len(p) == 2: + return p[1] + return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) + def children(self): # hard for renames c = self._filelog.children(self._filenode)