[PATCH STABLE] absorb: pass a matcher to cmdutil.recordfilter() (issue6155)

Augie Fackler raf at durin42.com
Mon Jul 8 13:23:51 EDT 2019


This is already fixed on default by 86f17fc31aa8 - is it worth getting the fix in 5.0.2 in a day or two, or is it okay for the fix to wait for 5.1?

> On Jul 8, 2019, at 10:52, Denis Laxalde <denis at laxalde.org> wrote:
> 
> # HG changeset patch
> # User Denis Laxalde <denis at laxalde.org>
> # Date 1562597461 -7200
> #      lun. juil. 08 16:51:01 2019 +0200
> # Branch stable
> # Node ID d27b4c53714314b6e3151ce84b62eb95a58be4db
> # Parent  2c27b7fadcd3afabdcd9f72a6984166a8f6e39f4
> absorb: pass a matcher to cmdutil.recordfilter() (issue6155)
> 
> This follows up on changeset db72f9f6580e where that function got
> modified to use an extra non-optional "matcher" argument. Usage in
> hgext/absorb.py was missed, thus making "hg absorb --interactive" crash
> as described in https://bz.mercurial-scm.org/show_bug.cgi?id=6155.
> We fix this by passing a matcher object in absorb code as well.
> 
> We add tests for --interactive option of "hg absorb" as there was none
> before.
> 
> diff --git a/hgext/absorb.py b/hgext/absorb.py
> --- a/hgext/absorb.py
> +++ b/hgext/absorb.py
> @@ -932,7 +932,7 @@ def absorb(ui, repo, stack=None, targetc
>     if opts.get('interactive'):
>         diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)
>         origchunks = patch.parsepatch(diff)
> -        chunks = cmdutil.recordfilter(ui, origchunks)[0]
> +        chunks = cmdutil.recordfilter(ui, origchunks, matcher)[0]
>         targetctx = overlaydiffcontext(stack[-1], chunks)
>     fm = None
>     if opts.get('print_changes') or not opts.get('apply_changes'):
> diff --git a/tests/test-absorb-interactive.t b/tests/test-absorb-interactive.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-absorb-interactive.t
> @@ -0,0 +1,129 @@
> +  $ cat >> $HGRCPATH << EOF
> +  > [extensions]
> +  > absorb=
> +  > EOF
> +
> +  $ hg init repo1
> +  $ cd repo1
> +
> +Make some commits:
> +
> +  $ for i in 1 2 3 4 5; do
> +  >   echo $i >> a
> +  >   hg commit -A a -m "commit $i" -q
> +  > done
> +
> +  $ hg annotate a
> +  0: 1
> +  1: 2
> +  2: 3
> +  3: 4
> +  4: 5
> +
> +Change a few lines:
> +
> +  $ cat > a <<EOF
> +  > 1a
> +  > 2b
> +  > 3
> +  > 4d
> +  > 5e
> +  > EOF
> +
> +Preview absorb changes:
> +
> +  $ hg absorb --print-changes --dry-run
> +  showing changes for a
> +          @@ -0,2 +0,2 @@
> +  4ec16f8 -1
> +  5c5f952 -2
> +  4ec16f8 +1a
> +  5c5f952 +2b
> +          @@ -3,2 +3,2 @@
> +  ad8b8b7 -4
> +  4f55fa6 -5
> +  ad8b8b7 +4d
> +  4f55fa6 +5e
> +  
> +  4 changesets affected
> +  4f55fa6 commit 5
> +  ad8b8b7 commit 4
> +  5c5f952 commit 2
> +  4ec16f8 commit 1
> +
> +Interactive absorb:
> +
> +  $ hg absorb --interactive --apply-changes << EOF
> +  > y
> +  > y
> +  > y
> +  > EOF
> +  diff -r 4f55fa657dae a
> +  2 hunks, 4 lines changed
> +  examine changes to 'a'? [Ynesfdaq?] y
> +  
> +  @@ -1,3 +1,3 @@
> +  -1
> +  -2
> +  +1a
> +  +2b
> +   3
> +  record change 1/2 to 'a'? [Ynesfdaq?] y
> +  
> +  @@ -3,3 +3,3 @@
> +   3
> +  -4
> +  -5
> +  +4d
> +  +5e
> +  record change 2/2 to 'a'? [Ynesfdaq?] y
> +  
> +  saved backup bundle to * (glob)
> +  2 of 2 chunk(s) applied
> +  $ hg annotate a
> +  0: 1a
> +  1: 2b
> +  2: 3
> +  3: 4d
> +  4: 5e
> +
> +Interactive with a file
> +
> +  $ cat > a <<EOF
> +  > 1aa
> +  > 2bb
> +  > 3
> +  > 4dd
> +  > 5ee
> +  > EOF
> +
> +  $ hg absorb --interactive --apply-changes a << EOF
> +  > y
> +  > y
> +  > EOF
> +  diff -r 84e5416c937c a
> +  2 hunks, 4 lines changed
> +  @@ -1,3 +1,3 @@
> +  -1a
> +  -2b
> +  +1aa
> +  +2bb
> +   3
> +  record change 1/2 to 'a'? [Ynesfdaq?] y
> +  
> +  @@ -3,3 +3,3 @@
> +   3
> +  -4d
> +  -5e
> +  +4dd
> +  +5ee
> +  record change 2/2 to 'a'? [Ynesfdaq?] y
> +  
> +  saved backup bundle to * (glob)
> +  2 of 2 chunk(s) applied
> +  $ hg annotate a
> +  0: 1aa
> +  1: 2bb
> +  2: 3
> +  3: 4dd
> +  4: 5ee
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list