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

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

Comments

Jun Wu - May 10, 2017, 8:34 a.m.
# HG changeset patch
# User Jun Wu <quark@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.
Sean Farley - May 10, 2017, 5:09 p.m.
Jun Wu <quark@fb.com> writes:

> # HG changeset patch
> # User Jun Wu <quark@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):

Am I reading this right that this is _copied and not 'renamed'? Or is
the diff hunk misaligned?
Jun Wu - May 10, 2017, 5:13 p.m.
Excerpts from Sean Farley's message of 2017-05-10 10:09:39 -0700:
> Am I reading this right that this is _copied and not 'renamed'? Or is
> the diff hunk misaligned?

They are the same.

memfilectx uses the word "copied" so this minimizes churn. If we use
"_renamed", then memfilectx and its callers need update.
Sean Farley - May 10, 2017, 6:20 p.m.
Jun Wu <quark@fb.com> writes:

> Excerpts from Sean Farley's message of 2017-05-10 10:09:39 -0700:
>> Am I reading this right that this is _copied and not 'renamed'? Or is
>> the diff hunk misaligned?
>
> They are the same.
>
> memfilectx uses the word "copied" so this minimizes churn. If we use
> "_renamed", then memfilectx and its callers need update.

Aha, fair enough.

Patch

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):