changeset 5501:1896d6bc574b stable

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.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 22 Aug 2020 07:18:55 +0800
parents 9242d0b5f74d
children 77c0ddd6f172
files hgext3rd/evolve/cmdrewrite.py tests/test-split.t
diffstat 2 files changed, 100 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- 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 ..