[PATCH 3 of 3 stable] extdiff: fix wrong comment about regexp ordering - regexps are just greedy

Yuya Nishihara yuya at tcha.org
Tue Jan 27 08:41:47 CST 2015


On Tue, 27 Jan 2015 03:15:52 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1422324901 -3600
> #      Tue Jan 27 03:15:01 2015 +0100
> # Branch stable
> # Node ID 02b0b226f33ba22df7e820d27fe93a79b69ad24a
> # Parent  bf99a88b77b67ac4c88674ba5d1d19dd97092426
> extdiff: fix wrong comment about regexp ordering - regexps are just greedy
> 
> diff --git a/hgext/extdiff.py b/hgext/extdiff.py
> --- a/hgext/extdiff.py
> +++ b/hgext/extdiff.py
> @@ -218,9 +218,8 @@ def dodiff(ui, repo, cmdline, pats, opts
>                  return pre
>              return pre + util.shellquote(replace[key])
>  
> -        # Match parent2 first, so 'parent1?' will match both parent1 and parent
>          regex = (r'''(['"]?)([^ '"]*)?'''
> -                 r'\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1')
> +                 r'\$(parent1?|parent2|child|plabel1|plabel2|clabel|root)\1')

IIRC, regexp is greedy, but the first matching pattern is used. So "$parent2"
is eaten by "\$(parent1?|".

I think "parent[12]?" can kill the confusing comment.

(original)

  % ./hg kdiff --config merge-tools.kdiff3.diffargs='$parent2' --debug
  running '/usr/bin/kdiff3 ' in /tmp/extdiff.NSwCFZ

(with this patch)

  % ./hg kdiff --config merge-tools.kdiff3.diffargs='$parent2' --debug
  running '/usr/bin/kdiff3 /tmp/extdiff.x_goam/mercurial-work.02b0b226f33b
  /hgext/extdiff.py2' in /tmp/extdiff.x_goam

Regards,


More information about the Mercurial-devel mailing list