[PATCH 01 of 11] filectx: make flags a property cache

Jun Wu quark at fb.com
Wed May 10 08:34:20 UTC 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1494383008 25200
#      Tue May 09 19:23:28 2017 -0700
# Node ID e4403b22312ef8d7a0d4cded7f23f5fc0753d50c
# Parent  1ada3d18e7fbc9069910f2c036992d2f2b28e058
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r e4403b22312e
filectx: make flags a property cache

Make basefilectx._flags a property cache, so basefilectx.flags() could be
reasonably reused. This avoids code duplication between memfilectx and a
class added in a later patch.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -763,6 +763,9 @@ class basefilectx(object):
     def filenode(self):
         return self._filenode
+    @propertycache
+    def _flags(self):
+        return self._changectx.flags(self._path)
     def flags(self):
-        return self._changectx.flags(self._path)
+        return self._flags
     def filelog(self):
         return self._filelog
@@ -2062,6 +2065,4 @@ class memfilectx(committablefilectx):
     def size(self):
         return len(self.data())
-    def flags(self):
-        return self._flags
     def renamed(self):
         return self._copied


More information about the Mercurial-devel mailing list