Patchwork [01,of,11] test-revert: add case where file is added between "base" and "parent"

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 12, 2014, 7:43 p.m.
Message ID <f1bdca5b44a2ff5597cf.1407872621@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5357/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 12, 2014, 7:43 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1403714233 -3600
#      Wed Jun 25 17:37:13 2014 +0100
# Node ID f1bdca5b44a2ff5597cf28686e7e524fbd1900f5
# Parent  eb9dae836e2d2b495d6c8350f70e6ac781fa6bc6
test-revert: add case where file is added between "base" and "parent"

Patch

diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -428,15 +428,19 @@  Write the python script to disk
 -------------------------------
 
   $ cat << EOF > gen-revert-cases.py
   > # generate proper file state to test revert behavior
   > import sys
+  > import os
   > 
   > # content of the file in "base" and "parent"
+  > # None means no file at all
   > ctxcontent = {
   >     # modified: file content change from base to parent
   >     'modified': ['base', 'parent'],
+  >     # added: file is missing from base and added in parent
+  >     'added': [None, 'parent'],
   > }
   > 
   > # content of file in working copy
   > wccontent = {
   >     # clean: wc content is the same as parent
@@ -472,18 +476,22 @@  Write the python script to disk
   >         print >> sys.stderr, "unknown target:", target
   >         sys.exit(1)
   > 
   > # write actual content
   > for filename, data in content:
-  >     f = open(filename, 'w')
-  >     f.write(data + '\n')
-  >     f.close()
+  >     if data is not None:
+  >         f = open(filename, 'w')
+  >         f.write(data + '\n')
+  >         f.close()
+  >     elif os.path.exists(filename):
+  >        os.remove(filename)
   > EOF
 
 check list of planned files
 
   $ python gen-revert-cases.py filelist
+  added_clean
   modified_clean
 
 Script to make a simple text version of the content
 ---------------------------------------------------
 
@@ -522,33 +530,38 @@  Generate base changeset
 
 Create parent changeset
 
   $ python ../gen-revert-cases.py parent
   $ hg addremove --similarity 0
+  adding added_clean
   $ hg status
   M modified_clean
+  A added_clean
   $ hg commit -m 'parent'
 
 (create a simple text version of the content)
 
   $ python ../dircontent.py > ../content-parent.txt
   $ cat ../content-parent.txt
+  parent added_clean
   parent modified_clean
 
 Setup working directory
 
   $ python ../gen-revert-cases.py wc | cat
   $ hg addremove --similarity 0
   $ hg status
 
   $ hg status --rev 'desc("base")'
   M modified_clean
+  A added_clean
 
 (create a simple text version of the content)
 
   $ python ../dircontent.py > ../content-wc.txt
   $ cat ../content-wc.txt
+  parent added_clean
   parent modified_clean
 
   $ cd ..
 
 Test revert --all to parent content
@@ -582,10 +595,11 @@  Test revert --all to "base" content
   $ cd revert-base-all
 
 check revert output
 
   $ hg revert --all --rev 'desc(base)'
+  removing added_clean
   reverting modified_clean
 
 Compare resulting directory with revert target.
 
 The diff is filtered to include change only. The only difference should be
@@ -610,10 +624,13 @@  revert all files individually and check 
   $ for file in `python ../gen-revert-cases.py filelist`; do
   >   echo '### revert for:' $file;
   >   hg revert $file;
   >   echo
   > done
+  ### revert for: added_clean
+  no changes needed to added_clean
+  
   ### revert for: modified_clean
   no changes needed to modified_clean
   
 
 check resulting directory againt the --all run
@@ -638,10 +655,12 @@  revert all files individually and check 
   $ for file in `python ../gen-revert-cases.py filelist`; do
   >   echo '### revert for:' $file;
   >   hg revert $file --rev 'desc(base)';
   >   echo
   > done
+  ### revert for: added_clean
+  
   ### revert for: modified_clean
   
 
 check resulting directory againt the --all run
 (There should be no difference)