[PATCH 1 of 8 V3] context: refactor introrev to make the next patch easier to read

Martin von Zweigbergk martinvonz at google.com
Wed Oct 3 15:24:05 EDT 2018


Oh, and thanks for splitting this patch up! I find it much easier to see
what's going on now.

On Wed, Oct 3, 2018 at 12:23 PM Martin von Zweigbergk <martinvonz at google.com>
wrote:

>
>
> On Wed, Oct 3, 2018 at 12:15 PM Boris Feld <boris.feld at octobus.net> wrote:
>
>> # HG changeset patch
>> # User Boris Feld <boris.feld at octobus.net>
>> # Date 1538554251 -7200
>> #      Wed Oct 03 10:10:51 2018 +0200
>> # Node ID 68ec0cf339c7e65ee4349f543e3024068fbbe591
>> # Parent  1a4c1a3cc3f5b54de7f56753c0ea8b02b4443958
>> # EXP-Topic copy-perf
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
>> 68ec0cf339c7
>> context: refactor introrev to make the next patch easier to read
>>
>> We are about to update the logic for checking if the rev is available in
>> an
>> efficient manner. Refactoring introrev will make the next patch easier to
>> read.
>>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -776,10 +776,15 @@ class basefilectx(object):
>>          """
>>          lkr = self.linkrev()
>>          attrs = vars(self)
>> -        noctx = not (r'_changeid' in attrs or r'_changectx' in attrs)
>> -        if noctx or self.rev() == lkr:
>> -            return self.linkrev()
>> -        return self._adjustlinkrev(self.rev(), inclusive=True)
>> +        lazyavailable = r'_changeid' in attrs or r'_changectx' in attrs
>> +        if lazyavailable:
>> +            rev = self.rev()
>> +            if rev == lkr:
>> +                return rev
>> +            else:
>> +                return self._adjustlinkrev(rev, inclusive=True)
>> +        else:
>> +            return self.rev()
>>
>
> For this to be a pure refactoring, shouldn't this be "return
> self.linkrev()"? That's what we used to return when noctx was true.
>
>
>>      def introfilectx(self):
>>          """Return filectx having identical contents, but pointing to the
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20181003/7702f1e5/attachment.html>


More information about the Mercurial-devel mailing list