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

login
register
mail settings
Submitter Jun Wu
Date May 10, 2017, 8:34 a.m.
Message ID <e4403b22312ef8d7a0d4.1494405260@x1c>
Download mbox | patch
Permalink /patch/20547/
State Accepted
Headers show

Comments

Jun Wu - May 10, 2017, 8:34 a.m.
# HG changeset patch
# User Jun Wu <quark@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.

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