histedit-test: ensure that non commute test will never commute
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 21 Sep 2012 19:13:25 +0200
changeset 17646 d44731a3adb8
parent 17645 4721fc933943
child 17647 d34ba4991188
histedit-test: ensure that non commute test will never commute The previous version would commute if using merge algorithm (to be accurate, merge will cleanly prompt the user during the merge). The new version create and initial commit with some content for all involved files en ensure all changes are a content changes of the first lines. This lead to guaranteed conflict when commuted.
tests/test-histedit-fold-non-commute.t
tests/test-histedit-non-commute.t
--- a/tests/test-histedit-fold-non-commute.t	Fri Sep 21 19:25:19 2012 +0200
+++ b/tests/test-histedit-fold-non-commute.t	Fri Sep 21 19:13:25 2012 +0200
@@ -6,79 +6,95 @@
   > histedit=
   > EOF
 
-  $ EDITED="$TESTTMP/editedhistory"
-  $ cat > $EDITED <<EOF
-  > pick 177f92b77385 c
-  > pick 055a42cdd887 d
-  > fold bfa474341cc9 does not commute with e
-  > pick e860deea161a e
-  > pick 652413bf663e f
-  > EOF
   $ initrepo ()
   > {
   >     hg init $1
   >     cd $1
   >     for x in a b c d e f ; do
+  >         echo $x$x$x$x$x > $x
+  >         hg add $x
+  >     done
+  >     hg ci -m 'Initial commit'
+  >     for x in a b c d e f ; do
   >         echo $x > $x
-  >         hg add $x
   >         hg ci -m $x
   >     done
-  >     echo a >> e
+  >     echo 'I can haz no commute' > e
   >     hg ci -m 'does not commute with e'
   >     cd ..
   > }
 
   $ initrepo r
   $ cd r
+Initial generation of the command files
+
+  $ EDITED="$TESTTMP/editedhistory"
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
+  $ hg log --template 'fold {node|short} {rev} {desc}\n' -r 7 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
+  $ cat $EDITED
+  pick 65a9a84f33fd 3 c
+  pick 00f1c5383965 4 d
+  fold 39522b764e3d 7 does not commute with e
+  pick 7b4e2f4b7bcd 5 e
+  pick 500cac37a696 6 f
 
 log before edit
   $ hg log --graph
-  @  changeset:   6:bfa474341cc9
+  @  changeset:   7:39522b764e3d
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     does not commute with e
   |
-  o  changeset:   5:652413bf663e
+  o  changeset:   6:500cac37a696
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:e860deea161a
+  o  changeset:   5:7b4e2f4b7bcd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     e
   |
-  o  changeset:   3:055a42cdd887
+  o  changeset:   4:00f1c5383965
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
   |
-  o  changeset:   2:177f92b77385
+  o  changeset:   3:65a9a84f33fd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     c
   |
-  o  changeset:   1:d2ae7f538514
+  o  changeset:   2:da6535b52e45
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:cb9a9f314b8b
+  o  changeset:   1:c1f09da44841
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     a
+  |
+  o  changeset:   0:1715188a53c7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
+     summary:     Initial commit
   
 
 edit the history
-  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 
 fix up
   $ echo a > e
-  $ hg add e
   $ cat > cat.py <<EOF
   > import sys
   > print open(sys.argv[1]).read()
@@ -86,6 +102,7 @@
   > print
   > EOF
   $ HGEDITOR="python cat.py" hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   d
   ***
   does not commute with e
@@ -104,7 +121,8 @@
   
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  file e already exists
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 
@@ -115,31 +133,36 @@
 
 log after edit
   $ hg log --graph
-  @  changeset:   4:f768fd60ca34
+  @  changeset:   5:45bd04206744
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   3:671efe372e33
+  o  changeset:   4:abff6367c13a
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
   |
-  o  changeset:   2:177f92b77385
+  o  changeset:   3:65a9a84f33fd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     c
   |
-  o  changeset:   1:d2ae7f538514
+  o  changeset:   2:da6535b52e45
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:cb9a9f314b8b
+  o  changeset:   1:c1f09da44841
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     a
+  |
+  o  changeset:   0:1715188a53c7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
+     summary:     Initial commit
   
 
 contents of e
--- a/tests/test-histedit-non-commute.t	Fri Sep 21 19:25:19 2012 +0200
+++ b/tests/test-histedit-non-commute.t	Fri Sep 21 19:13:25 2012 +0200
@@ -6,24 +6,20 @@
   > histedit=
   > EOF
 
-  $ EDITED="$TESTTMP/editedhistory"
-  $ cat > $EDITED <<EOF
-  > pick 177f92b77385 c
-  > pick 055a42cdd887 d
-  > pick bfa474341cc9 does not commute with e
-  > pick e860deea161a e
-  > pick 652413bf663e f
-  > EOF
   $ initrepo ()
   > {
   >     hg init $1
   >     cd $1
   >     for x in a b c d e f ; do
+  >         echo $x$x$x$x$x > $x
+  >         hg add $x
+  >     done
+  >     hg ci -m 'Initial commit'
+  >     for x in a b c d e f ; do
   >         echo $x > $x
-  >         hg add $x
   >         hg ci -m $x
   >     done
-  >     echo a >> e
+  >     echo 'I can haz no commute' > e
   >     hg ci -m 'does not commute with e'
   >     cd ..
   > }
@@ -31,48 +27,70 @@
   $ initrepo r1
   $ cd r1
 
+Initial generation of the command files
+
+  $ EDITED="$TESTTMP/editedhistory"
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 7 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
+  $ cat $EDITED
+  pick 65a9a84f33fd 3 c
+  pick 00f1c5383965 4 d
+  pick 39522b764e3d 7 does not commute with e
+  pick 7b4e2f4b7bcd 5 e
+  pick 500cac37a696 6 f
+
 log before edit
   $ hg log --graph
-  @  changeset:   6:bfa474341cc9
+  @  changeset:   7:39522b764e3d
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     does not commute with e
   |
-  o  changeset:   5:652413bf663e
+  o  changeset:   6:500cac37a696
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:e860deea161a
+  o  changeset:   5:7b4e2f4b7bcd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     e
   |
-  o  changeset:   3:055a42cdd887
+  o  changeset:   4:00f1c5383965
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
   |
-  o  changeset:   2:177f92b77385
+  o  changeset:   3:65a9a84f33fd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     c
   |
-  o  changeset:   1:d2ae7f538514
+  o  changeset:   2:da6535b52e45
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:cb9a9f314b8b
+  o  changeset:   1:c1f09da44841
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     a
+  |
+  o  changeset:   0:1715188a53c7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
+     summary:     Initial commit
   
 
 edit the history
-  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 
@@ -84,55 +102,62 @@
 second edit set
 
   $ hg log --graph
-  @  changeset:   6:bfa474341cc9
+  @  changeset:   7:39522b764e3d
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     does not commute with e
   |
-  o  changeset:   5:652413bf663e
+  o  changeset:   6:500cac37a696
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:e860deea161a
+  o  changeset:   5:7b4e2f4b7bcd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     e
   |
-  o  changeset:   3:055a42cdd887
+  o  changeset:   4:00f1c5383965
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
   |
-  o  changeset:   2:177f92b77385
+  o  changeset:   3:65a9a84f33fd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     c
   |
-  o  changeset:   1:d2ae7f538514
+  o  changeset:   2:da6535b52e45
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:cb9a9f314b8b
+  o  changeset:   1:c1f09da44841
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     a
+  |
+  o  changeset:   0:1715188a53c7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
+     summary:     Initial commit
   
 
 edit the history
-  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 
 fix up
-  $ echo a > e
-  $ hg add e
+  $ echo 'I can haz no commute' > e
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  file e already exists
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 
@@ -143,36 +168,41 @@
 
 log after edit
   $ hg log --graph
-  @  changeset:   5:9ab84894b459
+  @  changeset:   6:8e082d1a72ea
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:1fff3ae8199d
+  o  changeset:   5:13b04d775b81
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     does not commute with e
   |
-  o  changeset:   3:055a42cdd887
+  o  changeset:   4:00f1c5383965
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
   |
-  o  changeset:   2:177f92b77385
+  o  changeset:   3:65a9a84f33fd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     c
   |
-  o  changeset:   1:d2ae7f538514
+  o  changeset:   2:da6535b52e45
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:cb9a9f314b8b
+  o  changeset:   1:c1f09da44841
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     a
+  |
+  o  changeset:   0:1715188a53c7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
+     summary:     Initial commit
   
 
 start over
@@ -181,25 +211,32 @@
 
   $ initrepo r2
   $ cd r2
-  $ cat > $EDITED <<EOF
-  > pick 177f92b77385 c
-  > pick 055a42cdd887 d
-  > mess bfa474341cc9 does not commute with e
-  > pick e860deea161a e
-  > pick 652413bf663e f
-  > EOF
+  $ rm $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
+  $ hg log --template 'mess {node|short} {rev} {desc}\n' -r 7 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
+  $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
+  $ cat $EDITED
+  pick 65a9a84f33fd 3 c
+  pick 00f1c5383965 4 d
+  mess 39522b764e3d 7 does not commute with e
+  pick 7b4e2f4b7bcd 5 e
+  pick 500cac37a696 6 f
 
 edit the history, this time with a fold action
-  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 
-  $ echo a > e
-  $ hg add e
+  $ echo 'I can haz no commute' > e
   $ HGEDITOR="cat \"$EDITED\" > " hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  file e already exists
+  patching file e
+  Hunk #1 FAILED at 0
   1 out of 1 hunks FAILED -- saving rejects to file e.rej
   abort: Fix up the change and run hg histedit --continue
 second edit also fails, but just continue
@@ -209,36 +246,41 @@
 
 post message fix
   $ hg log --graph
-  @  changeset:   5:6459970fb49b
+  @  changeset:   6:f14da722aa4b
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     f
   |
-  o  changeset:   4:556f27c874b0
+  o  changeset:   5:382ff1adf0ed
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     pick 177f92b77385 c
+  |  summary:     pick 65a9a84f33fd 3 c
   |
-  o  changeset:   3:055a42cdd887
+  o  changeset:   4:00f1c5383965
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     d
   |
-  o  changeset:   2:177f92b77385
+  o  changeset:   3:65a9a84f33fd
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     c
   |
-  o  changeset:   1:d2ae7f538514
+  o  changeset:   2:da6535b52e45
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:cb9a9f314b8b
+  o  changeset:   1:c1f09da44841
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     a
+  |
+  o  changeset:   0:1715188a53c7
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
+     summary:     Initial commit
   
 
   $ cd ..