# HG changeset patch # User Matt Mackall # Date 1242325240 18000 # Node ID 6ad1f72bdf343accceaae4e8f8238289efb2bc73 # Parent 7cbf8fcd2453487cb9305288bed9f8e0141469a3 context: add p1 and p2 methods diff -r 7cbf8fcd2453 -r 6ad1f72bdf34 mercurial/context.py --- a/mercurial/context.py Thu May 14 13:20:40 2009 -0500 +++ b/mercurial/context.py Thu May 14 13:20:40 2009 -0500 @@ -101,6 +101,14 @@ """return contexts for each parent changeset""" return self._parents + def p1(self): + return self._parents[0] + + def p2(self): + if len(self._parents) == 2: + return self._parents[1] + return changectx(self._repo, -1) + def children(self): """return contexts for each child changeset""" c = self._repo.changelog.children(self._node) @@ -750,6 +758,9 @@ def __getitem__(self, key): return self.filectx(key) + def p1(self): return self._parents[0] + def p2(self): return self._parents[1] + def user(self): return self._user or self._repo.ui.username() def date(self): return self._date def description(self): return self._text @@ -800,4 +811,3 @@ def isexec(self): return 'x' in self._flags def islink(self): return 'l' in self._flags def renamed(self): return self._copied -