sapling/tests/test-fbamend-rebase.t
Arun Kulshreshtha 3c80b1176b fbamend: make inhibit hook fire after rebase
Summary:
Recently @rmcelroy discovered that attempting to rebase a single commit in the middle of a stack results in the rest of the stack being marked as unstable. See https://fb.facebook.com/groups/sourcecontrol/permalink/1207767375939547/ for full example.

It turns out that the inhibit extension's post-transaction hook that would ordinarily inhibit the rebased (and thus obsolete) commit, and thereby hide the instability, was not firing in this case. This was similar to a previous problem with `hg next --rebase` wherein `--continue`'ing a rebase with conflicts would result in visible instability for the same reason. In both cases, the problem appears to be that `rebase` doesn't actually create a transaction, so of course the post-transaction hook doesn't fire.

The solution for `hg next --rebase` was to add a (nearly) empty transaction after the rebase call to trigger the hook. This diff just makes this the default behavior for `hg rebase` so that the hook is always called.

Test Plan:
See new test file. Basically, create a situation like:

```
o  e5d56d  debugbuilddag
|  r3
|
| o  c175ba  debugbuilddag
| |  r2
| |
| o  220949  debugbuilddag
|/   r1
|
o  1ad88b  debugbuilddag
   r0
```

Perform `hg rebase -r 1 -d 3`, which rebases commit "r1" onto "r3", which would ordinarily make "r2" unstable. Instead, the result should be as below, with no visible instability because "r1" is inhibited.

```
o  738e8e  debugbuilddag
|  r1
|
o  e5d56d  debugbuilddag
|  r3
|
| o  c175ba  debugbuilddag
| |  r2
| |
| x  220949 (Rebased as 738e8e)  debugbuilddag
|/   r1
|
o  1ad88b  debugbuilddag
   r0
```

Reviewers: rmcelroy, #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D4491870

Tasks: 15697758

Signature: t1:4491870:1486033128:45b8e9a72af1e88ab78484ddef47a788d1aca7b5
2017-02-02 11:49:44 -08:00

54 lines
1.2 KiB
Perl

Set up test environment.
$ . $TESTDIR/require-ext.sh directaccess evolve inhibit
$ extpath=`dirname $TESTDIR`
$ cp $extpath/hgext3rd/allowunstable.py $TESTTMP
$ cp $extpath/hgext3rd/debuginhibit.py $TESTTMP
$ cp $extpath/hgext3rd/fbamend.py $TESTTMP
$ cat >> $HGRCPATH << EOF
> [extensions]
> allowunstable=$TESTTMP/allowunstable.py
> debuginhibit=$TESTTMP/debuginhibit.py
> directaccess=
> evolve=
> fbamend=$TESTTMP/fbamend.py
> inhibit=
> rebase=
> [experimental]
> evolution = createmarkers
> evolutioncommands = prev next fold split
> EOF
$ showgraph() {
> hg log --graph -T "{rev} {desc|firstline}" | sed \$d
> }
Test that rebased commits that would cause instability are inhibited.
$ hg init repo && cd repo
$ hg debugbuilddag -m '+3 *3'
$ showgraph
o 3 r3
|
| o 2 r2
| |
| o 1 r1
|/
o 0 r0
$ hg rebase -r 1 -d 3 --config "debuginhibit.printnodes=true"
rebasing 1:* "r1" (glob)
merging mf
Inhibiting: ['*'] (glob)
Deinhibiting: ['*'] (glob)
Deinhibiting: []
Inhibiting: ['*'] (glob)
$ showgraph
o 4 r1
|
o 3 r3
|
| o 2 r2
| |
| o 1 r1
|/
o 0 r0
Make sure there are no unstable commits.
$ hg log -r 'unstable()'