[PATCH] import: move tryone closure in cmdutil

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Feb 12 13:31:23 CST 2014



On 02/11/2014 07:57 PM, Matt Mackall wrote:
> On Tue, 2014-02-11 at 16:59 -0800, pierre-yves.david at ens-lyon.org wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
>> # Date 1392166356 28800
>> #      Tue Feb 11 16:52:36 2014 -0800
>> # Node ID 9b59241d45fcdc69a13459c0a90942b808faf69e
>> # Parent  1478a9ce679097c03234201d179e48c58d0b5c1d
>> import: move tryone closure in cmdutil
>>
>> We extract the `tryone` function into the `cmdutil` module. A lot fo the command
>> context have to be passed to the utility function, but having and explicit
>> declaration will allow extension to wrap it. This will allows use to make
>> changeset evolution related experiment in dedicated extension.
>>
>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>> --- a/mercurial/cmdutil.py
>> +++ b/mercurial/cmdutil.py
>> @@ -540,10 +540,124 @@ def service(opts, parentfn=None, initfn=
>>               os.close(logfilefd)
>>
>>       if runfn:
>>           return runfn()
>>
>> +def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc):
>> +    """Utility function used by commands.import to import a single patch
>
> This is perhaps a bit too ugly as an API.

Yes, but this patch focus on moving the code around with minimal change 
to it.

> Can we try to extract the core
> "import a patch" function from this?

We can probably build something nicer. Such change is bit out of my 
original scope "patchbombing one year old draft changeset out my working 
copy"

> At the very least, we should document the horrendous args this accepts.

I'll update the patch with such information and a note to future reader 
about how we would like it to be nicer.

-- 
Pierre-Yves


More information about the Mercurial-devel mailing list