[PATCH 7 of 8] histedit-test: ensure that non commute test will never commute

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Sep 21 12:28:30 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1348247605 -7200
# Node ID bdf1a024374d676d8626f441f49ec84a81fe56d7
# Parent  43084bae9ecedc01741895bc1eae27de065b5263
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.

diff --git a/tests/test-histedit-fold-non-commute.t b/tests/test-histedit-fold-non-commute.t
--- a/tests/test-histedit-fold-non-commute.t
+++ b/tests/test-histedit-fold-non-commute.t
@@ -4,90 +4,107 @@
   > [extensions]
   > graphlog=
   > 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()
   > print
   > 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
   
   
@@ -102,46 +119,52 @@ fix up
   
   
   
   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
 
 just continue this time
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 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
   $ hg cat e
   a
diff --git a/tests/test-histedit-non-commute.t b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -4,77 +4,95 @@
   > [extensions]
   > graphlog=
   > 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 ..
   > }
 
   $ 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
 
 abort the edit
   $ hg histedit --abort 2>&1 | fixbundle
@@ -82,163 +100,187 @@ abort the edit
 
 
 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
 
 just continue this time
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 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
 
   $ cd ..
 
   $ 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
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 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 ..


More information about the Mercurial-devel mailing list