[PATCH] filemerge: add $revbase and $revother substitutions in merge tool arguments

Mads Kiilerich mads at kiilerich.com
Tue Jul 31 19:55:55 CDT 2012


Vitaliy Filippov wrote, On 08/01/2012 12:58 AM:
> # HG changeset patch
> # User Vitaliy Filippov <vitalif at yourcmc.ru>
> # Date 1342116873 -14400
> # Node ID b861c6e313334007cc55462e473c4c2c8ad549c9
> # Parent  3ac9592b7ab432e1470ec97d19c9b7c58c3fda86
> filemerge: add $revbase and $revother substitutions in merge tool arguments
>
> Usage example:
>
> [merge-tools]
> filemerge.executable = /usr/bin/merge
> filemerge.args = -L local -L "base (rev $revbase)" -L "other (rev $revother)" -A $local $base $other

I think I would prefer $baserev and $otherrev. And $localrev could be 
equally relevant.

I suggest utilizing these new 'variables' in some relevant places in 
contrib/mergetools.hgrc . That will demonstrate how useful they are.

Finally: You should add some tests for it. That will demonstrate that it 
works and make sure it doesn't regress in the future.

> diff -r 3ac9592b7ab4 -r b861c6e31333 mercurial/filemerge.py
> --- a/mercurial/filemerge.py	Thu Jul 12 14:20:34 2012 -0500
> +++ b/mercurial/filemerge.py	Thu Jul 12 22:14:33 2012 +0400
> @@ -254,8 +254,11 @@
>           if "$output" in args:
>               out, a = a, back # read input from backup, write to original
>           replace = dict(local=a, base=b, other=c, output=out)
> -        args = util.interpolate(r'\$', replace, args,
> -                                lambda s: '"%s"' % util.localpath(s))
> +        for i in replace:
> +            replace[i] = '"%s"' % util.localpath(replace[i])
> +        replace['revbase'] = str(fca.rev())
> +        replace['revother'] = str(fco.rev())
> +        args = util.interpolate(r'\$', replace, args)

FWIW, I guess I would use

         f = lambda s: '"%s"' % util.localpath(s)
         replace = dict(local=f(a), base=f(b), other=f(c), output=f(out),
                        revbase=str(fca.rev()), revother=str(fco.rev()))

>           r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env,
>                           out=ui.fout)
>           return True, r
>

/Mads


More information about the Mercurial-devel mailing list