[PATCH 02 of 11] filectx: make renamed a property cache

Jun Wu quark at fb.com
Wed May 10 04:34:21 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1494384537 25200
#      Tue May 09 19:48:57 2017 -0700
# Node ID 8fe9241cb76e0e1b91d6deaa9af81de3e97f696e
# Parent  e4403b22312ef8d7a0d4cded7f23f5fc0753d50c
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 8fe9241cb76e
filectx: make renamed a property cache

See previous patch for context - mainly to avoid code duplication.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -798,4 +798,6 @@ class basefilectx(object):
     def changectx(self):
         return self._changectx
+    def renamed(self):
+        return self._copied
     def repo(self):
         return self._repo
@@ -1150,5 +1152,6 @@ class filectx(basefilectx):
         return self._filelog.size(self._filerev)
 
-    def renamed(self):
+    @propertycache
+    def _copied(self):
         """check if file was actually renamed in this changeset revision
 
@@ -2065,6 +2068,4 @@ class memfilectx(committablefilectx):
     def size(self):
         return len(self.data())
-    def renamed(self):
-        return self._copied
 
     def remove(self, ignoremissing=False):


More information about the Mercurial-devel mailing list