# HG changeset patch # User Anton Shestakov # Date 1598051935 -28800 # Node ID 1896d6bc574bdeca418955a603fc96bdd128ae51 # Parent 9242d0b5f74d34cff28b3e5f39b10efa302682dd split: demonstrate that discard after more than one commit is misbehaving The `assert` that this patch removes was introduced in 9242d0b5f74d, when we didn't have the test that this patch adds. Without the `assert` we can actually see the incorrect behavior. With it, the test would throw an AssertionError just before "forgetting c", when hg split is handling the second discard action. diff -r 9242d0b5f74d -r 1896d6bc574b hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Fri Aug 21 23:04:03 2020 +0800 +++ b/hgext3rd/evolve/cmdrewrite.py Sat Aug 22 07:18:55 2020 +0800 @@ -1314,7 +1314,6 @@ # hg <= 5.5 (8c466bcb0879) if r'parents' in code.co_varnames[:code.co_argcount]: args.append((target, node.nullid)) - assert target.node() == repo.dirstate.p1() if pats: status = repo.status(match=matcher) dirty = set() diff -r 9242d0b5f74d -r 1896d6bc574b tests/test-split.t --- a/tests/test-split.t Fri Aug 21 23:04:03 2020 +0800 +++ b/tests/test-split.t Sat Aug 22 07:18:55 2020 +0800 @@ -1285,3 +1285,103 @@ @@ -0,0 +1,1 @@ +a + $ cd .. + +Discard after splitting into more than one changeset + + $ hg init discard-after-many + $ cd discard-after-many + + $ echo 0 > num + $ cat > editor.sh << '__EOF__' + > NUM=$(cat num) + > NUM=`expr "$NUM" + 1` + > echo "$NUM" > num + > echo "split$NUM" > "$1" + > __EOF__ + $ export HGEDITOR="\"sh\" \"editor.sh\"" + + $ echo a > a + $ echo b > b + $ echo c > c + $ hg add a b c + $ hg ci -m 'a b c' + +XXX: this shouldn't ask to re-examine changes in b and definitely shouldn't revert b + + $ hg split << EOF + > f + > d + > y + > f + > d + > d + > s + > c + > EOF + 0 files updated, 0 files merged, 3 files removed, 0 files unresolved + adding a + adding b + adding c + diff --git a/a b/a + new file mode 100644 + examine changes to 'a'? + (enter ? for help) [Ynesfdaq?] f + + diff --git a/b b/b + new file mode 100644 + examine changes to 'b'? + (enter ? for help) [Ynesfdaq?] d + + created new head + (consider using topic for lightweight branches. See 'hg help topic') + continue splitting? [Ycdq?] y + diff --git a/b b/b + new file mode 100644 + examine changes to 'b'? + (enter ? for help) [Ynesfdaq?] f + + diff --git a/c b/c + new file mode 100644 + examine changes to 'c'? + (enter ? for help) [Ynesfdaq?] d + + continue splitting? [Ycdq?] d + discarding remaining changes + forgetting c + removing b + diff --git a/b b/b + deleted file mode 100644 + examine changes to 'b'? + (enter ? for help) [Ynesfdaq?] s + + no changes to record + continue splitting? [Ycdq?] c + + $ hg glog -p + @ 3:bdee57117c76 split3 (draft) + | diff --git a/b b/b + | deleted file mode 100644 + | --- a/b + | +++ /dev/null + | @@ -1,1 +0,0 @@ + | -b + | + o 2:c2c6f4d8c766 split2 (draft) + | diff --git a/b b/b + | new file mode 100644 + | --- /dev/null + | +++ b/b + | @@ -0,0 +1,1 @@ + | +b + | + o 1:fb91c6249a20 split1 (draft) + diff --git a/a b/a + new file mode 100644 + --- /dev/null + +++ b/a + @@ -0,0 +1,1 @@ + +a + + + $ cd ..