[PATCH 1 of 3 remove-makememctx V2] memctx: refactor inline getfilectx into convenience method

Sean Farley sean at farley.io
Mon Jun 12 02:01:03 EDT 2017


Martin von Zweigbergk <martinvonz at google.com> writes:

> On Fri, Jun 9, 2017 at 2:20 PM, Sean Farley <sean at farley.io> wrote:
>> # HG changeset patch
>> # User Sean Farley <sean at farley.io>
>> # Date 1497039902 25200
>> #      Fri Jun 09 13:25:02 2017 -0700
>> # Branch remove-makememctx
>> # Node ID dfe7dc826d3b1c6b0c933cc74c9ad14042f39877
>> # Parent  776d077eb4ef815e08631fb1e7b33375adca3ef1
>> memctx: refactor inline getfilectx into convenience method
>>
>> No actual logic is changing, just moving code so __init__ is easier to
>> read.
>>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> index 91b5bf1..5960d02 100644
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -2039,10 +2039,29 @@ def makecachingfilectxfn(func):
>>              cache[path] = func(repo, memctx, path)
>>          return cache[path]
>>
>>      return getfilectx
>>
>> +def memfilefromctx(ctx):
>
> Should this have a '_' prefix or do you plan on adding users outside
> of the module?

I was on the fence about it but you're correct; there are no users
outside of context.py so feel free to prefix it with a '_'.

>> +    """Given a context return a memfilectx for ctx[path]
>> +
>> +    This is a convenience method for building a memctx based on another
>> +    context.
>
> But it doesn't build a memctx. Was it simply meant to say
> "memfilectx"? It becomes pretty similar to the first line then.

I did mean memfilectx; good catch (also feel free to change in flight).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170611/d6b50e2d/attachment.sig>


More information about the Mercurial-devel mailing list