Patchwork [36,of,41] basefilectx: move p2 from filectx

login
register
mail settings
Submitter Sean Farley
Date Aug. 12, 2013, 4:27 p.m.
Message ID <adb0ddbdca0f5b7c8f02.1376324852@laptop.local>
Download mbox | patch
Permalink /patch/2162/
State Accepted
Commit 056a949799ac174908ba826c5c65a67c47364fae
Headers show

Comments

Sean Farley - Aug. 12, 2013, 4:27 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1376280011 18000
#      Sun Aug 11 23:00:11 2013 -0500
# Node ID adb0ddbdca0f5b7c8f029c0a40d70f3602c9bc06
# Parent  3f092041ba827e9e278d4e1d3d6fdad2d3cd8c7c
basefilectx: move p2 from filectx

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -551,10 +551,16 @@ 
                 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)
+
 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):
@@ -636,16 +642,10 @@ 
                     return None
             except error.LookupError:
                 pass
         return renamed
 
-    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)
         return [filectx(self._repo, self._path, fileid=x,
                         filelog=self._filelog) for x in c]