Patchwork filectx: fix annotate to not directly instantiate filectx

login
register
mail settings
Submitter Durham Goode
Date Jan. 9, 2015, 7:28 p.m.
Message ID <83700e5605006fbddab0.1420831686@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7407/
State Accepted
Commit 50f0096a73462b43206e6aef38efb1142147ebad
Headers show

Comments

Durham Goode - Jan. 9, 2015, 7:28 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1420831289 28800
#      Fri Jan 09 11:21:29 2015 -0800
# Node ID 83700e5605006fbddab0b02b695da6b9a0e106fd
# Parent  bb3ee61cfaa1d3f085c7577f48f566a0f31a6985
filectx: fix annotate to not directly instantiate filectx

28a302e9225d changed basefilectx.annotate() to directly instantiate new
filectx's instead of going through self.filectx(), this breaks extensions that
replace the filectx class, and would also break future uses that would need
memfilectx's.
Pierre-Yves David - Jan. 9, 2015, 7:34 p.m.
On 01/09/2015 11:28 AM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1420831289 28800
> #      Fri Jan 09 11:21:29 2015 -0800
> # Node ID 83700e5605006fbddab0b02b695da6b9a0e106fd
> # Parent  bb3ee61cfaa1d3f085c7577f48f566a0f31a6985
> filectx: fix annotate to not directly instantiate filectx
>
> 28a302e9225d changed basefilectx.annotate() to directly instantiate new
> filectx's instead of going through self.filectx(), this breaks extensions that
> replace the filectx class, and would also break future uses that would need
> memfilectx's.

Sure, pushed to the clowncopter. Thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -893,8 +893,7 @@  class basefilectx(object):
         base = self
         introrev = self.introrev()
         if self.rev() != introrev:
-            base = filectx(self._repo, self._path, filelog=self.filelog(),
-                           fileid=self.filenode(), changeid=introrev)
+            base = self.filectx(self.filenode(), changeid=introrev)
 
         # This algorithm would prefer to be recursive, but Python is a
         # bit recursion-hostile. Instead we do an iterative
@@ -1000,11 +999,11 @@  class filectx(basefilectx):
             # considered when solving linkrev issue are on the table.
             return changectx(self._repo.unfiltered(), self._changeid)
 
-    def filectx(self, fileid):
+    def filectx(self, fileid, changeid=None):
         '''opens an arbitrary revision of the file without
         opening a new filelog'''
         return filectx(self._repo, self._path, fileid=fileid,
-                       filelog=self._filelog)
+                       filelog=self._filelog, changeid=changeid)
 
     def data(self):
         try: