[PATCH 1 of 2] histedit: add execute method

Durham Goode durham at fb.com
Tue Sep 16 18:32:28 CDT 2014


On 9/16/14, 2:23 PM, David Soria Parra wrote:
> # HG changeset patch
> # User David Soria Parra <davidsp at fb.com>
> # Date 1410901051 25200
> #      Tue Sep 16 13:57:31 2014 -0700
> # Node ID d4e975e2707a0ea606c22ed472d56fab4fda7ae2
> # Parent  ca854cd4a26a8770fbc22b4d7ee1ac6823b682a5
> histedit: add execute method
>
> Add a method to execute command after a changeset is picked, folded, etc.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -152,6 +152,7 @@
>   import errno
>   import os
>   import sys
> +import subprocess
>   
>   from mercurial import cmdutil
>   from mercurial import discovery
> @@ -406,6 +407,30 @@
>       return ctx, [(repo[ha].node(), ())]
>   
>   
> +def execute(ui, repo, ctx, cmd, opts):
> +    hg.update(repo, ctx.node())
> +
> +    # release locks so the programm can call hg and then relock.
> +    release(repo._histeditlock, repo._histeditwlock)
> +
> +    process = subprocess.Popen(cmd, close_fds=True, shell=True,
> +            cwd=repo.root)
> +    process.communicate()
> +
> +    # relock the repository
> +    repo._histeditlock = repo.lock()
> +    repo._histeditwlock = repo.wlock()
> +
> +    if process.returncode != 0:
> +        raise error.InterventionRequired(
> +            _("Command '%s' failed with exit status %d.") % (cmd,
> +                process.returncode))
> +    if util.any(repo.status()[:4]):
> +        raise error.InterventionRequired(
> +            _('Working copy dirty, please check the files listed above.\n'
> +              'When you are finished, run hg histedit --continue to resume.'))
> +    return ctx, []
Don't we need to return repo['.'] as the new context?  And potentially 
provide a mapping from ctx.node() to newctx.node() (assuming ctx isn't a 
descendant of newctx)?  That way we can handle them 
adding/modifying/deleting commits during the exec.


More information about the Mercurial-devel mailing list