[PATCH V2] extensions: add onsub extension

Yuya Nishihara yuya at tcha.org
Sun Oct 12 10:40:23 CDT 2014


On Sun, 12 Oct 2014 16:09:15 +0200, Angel Ezquerra wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra at gmail.com>
> # Date 1409641307 -7200
> #      Tue Sep 02 09:01:47 2014 +0200
> # Node ID 76a648d782cfadf1dac3dbc194a8ffc74c385cb5
> # Parent  1533e642262de32c5a2445789710f49237019fd6
> extensions: add onsub extension

> +    def execCmd(sub, cmd, kind):
> +        """if sub == None, cmd is executed inside repo; else, inside sub.
> +        If cmd == None, do nothing. If cmd == '', do only the print0 (if needed). 
> +        Else, do either print0 or the debugging message, then execute the command.
> +        kind is the type of the (sub)repo.
> +        """
> +        if sub == None:
> +            envargdict = dict(HG_SUBPATH='.',
> +                              HG_SUBURL='.',
> +                              HG_SUBSTATE=repo['.'].hex(),
> +                              HG_REPO=repo.root,
> +                              HG_SUBTYPE=kind)
> +            relpath = '.'
> +            cmdwd = repo.root
> +        else:
> +            # subrepo.relpath was renamed to subrepo.subrelpath in
> +            # 18b5b6392fcf.
> +            if hasattr(subrepo, 'relpath'):
> +                relpath = subrepo.relpath(sub)
> +            else:
> +                relpath = subrepo.subrelpath(sub)
> +            envargdict = dict(HG_SUBPATH=relpath,
> +                              HG_SUBURL=sub._path,
> +                              HG_SUBSTATE=sub._state[1],
> +                              HG_REPO=repo.root,
> +                              HG_SUBTYPE=kind)
> +            cmdwd = os.path.join(repo.root, relpath)
> +        if cmd != None and (repotypefilter == '' or repotypefilter == kind):
> +            if print0:
> +                ui.write(relpath, "\0")
> +            if cmd != '':
> +                if not print0: ui.note(_("executing '%s' in %s\n") % (cmd, relpath))
> +                util.system(cmd, environ=envargdict, cwd=cmdwd, onerr=onerr,
> +                            errprefix=_('terminated onsub in %s') % relpath)

I didn't look through the onsub extension, but this util.system() call will
break the command-server channel.

https://bitbucket.org/tortoisehg/thg/issue/3924/
(no response yet, as usual)

Regards,


More information about the Mercurial-devel mailing list