Patchwork [06,of,11] test-revert: add case where wc content is different from "base" and "parent"

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 12, 2014, 7:43 p.m.
Message ID <fda3d9fac3077936915f.1407872626@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5361/
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 1403885296 -7200
#      Fri Jun 27 18:08:16 2014 +0200
# Node ID fda3d9fac3077936915fb9e56b40358f24302423
# Parent  8f40ca39bd68a470926e5088415e15c83e8b917c
test-revert: add case where wc content is different from "base" and "parent"

This test highlight a case where backup are not created and user may lose data.

Patch

diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -451,10 +451,12 @@  Write the python script to disk
   > wccontent = {
   >     # clean: wc content is the same as parent
   >     'clean': lambda cc: cc[1],
   >     # revert: wc content is the same as base
   >     'revert': lambda cc: cc[0],
+  >     # wc: file exist with a content different from base and parent
+  >     'wc': lambda cc: 'wc',
   > }
   > 
   > # build the combination of possible state
   > combination = []
   > for ctxkey in ctxcontent:
@@ -497,18 +499,23 @@  Write the python script to disk
 check list of planned files
 
   $ python gen-revert-cases.py filelist
   added_clean
   added_revert
+  added_wc
   clean_clean
   clean_revert
+  clean_wc
   missing_clean
   missing_revert
+  missing_wc
   modified_clean
   modified_revert
+  modified_wc
   removed_clean
   removed_revert
+  removed_wc
 
 Script to make a simple text version of the content
 ---------------------------------------------------
 
   $ cat << EOF >> dircontent.py
@@ -533,88 +540,122 @@  Generate base changeset
 
   $ python ../gen-revert-cases.py base
   $ hg addremove --similarity 0
   adding clean_clean
   adding clean_revert
+  adding clean_wc
   adding modified_clean
   adding modified_revert
+  adding modified_wc
   adding removed_clean
   adding removed_revert
+  adding removed_wc
   $ hg status
   A clean_clean
   A clean_revert
+  A clean_wc
   A modified_clean
   A modified_revert
+  A modified_wc
   A removed_clean
   A removed_revert
+  A removed_wc
   $ hg commit -m 'base'
 
 (create a simple text version of the content)
 
   $ python ../dircontent.py > ../content-base.txt
   $ cat ../content-base.txt
   base   clean_clean
   base   clean_revert
+  base   clean_wc
   base   modified_clean
   base   modified_revert
+  base   modified_wc
   base   removed_clean
   base   removed_revert
+  base   removed_wc
 
 Create parent changeset
 
   $ python ../gen-revert-cases.py parent
   $ hg addremove --similarity 0
   adding added_clean
   adding added_revert
+  adding added_wc
   removing removed_clean
   removing removed_revert
+  removing removed_wc
   $ hg status
   M modified_clean
   M modified_revert
+  M modified_wc
   A added_clean
   A added_revert
+  A added_wc
   R removed_clean
   R removed_revert
+  R removed_wc
   $ 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 added_revert
+  parent added_wc
   base   clean_clean
   base   clean_revert
+  base   clean_wc
   parent modified_clean
   parent modified_revert
+  parent modified_wc
 
 Setup working directory
 
   $ python ../gen-revert-cases.py wc | cat
   $ hg addremove --similarity 0
   removing added_revert
+  adding missing_wc
   adding removed_revert
+  adding removed_wc
   $ hg status
+  M added_wc
+  M clean_wc
   M modified_revert
+  M modified_wc
+  A missing_wc
   A removed_revert
+  A removed_wc
   R added_revert
 
   $ hg status --rev 'desc("base")'
+  M clean_wc
   M modified_clean
+  M modified_wc
+  M removed_wc
   A added_clean
+  A added_wc
+  A missing_wc
   R removed_clean
 
 (create a simple text version of the content)
 
   $ python ../dircontent.py > ../content-wc.txt
   $ cat ../content-wc.txt
   parent added_clean
+  wc     added_wc
   base   clean_clean
   base   clean_revert
+  wc     clean_wc
+  wc     missing_wc
   parent modified_clean
   base   modified_revert
+  wc     modified_wc
   base   removed_revert
+  wc     removed_wc
 
   $ cd ..
 
 Test revert --all to parent content
 -----------------------------------
@@ -626,23 +667,33 @@  Test revert --all to parent content
 
 check revert output
 
   $ hg revert --all
   undeleting added_revert
+  reverting added_wc
+  reverting clean_wc
+  forgetting missing_wc
   reverting modified_revert
+  reverting modified_wc
   forgetting removed_revert
+  forgetting removed_wc
 
 Compare resulting directory with revert target.
 
 The diff is filtered to include change only. The only difference should be
 additional `.orig` backup file when applicable.
 
   $ python ../dircontent.py > ../content-parent-all.txt
   $ cd ..
   $ diff -U 0 -- content-parent.txt content-parent-all.txt | grep _
+  +wc     added_wc.orig
+  +wc     clean_wc.orig
+  +wc     missing_wc
   +base   modified_revert.orig
+  +wc     modified_wc.orig
   +base   removed_revert
+  +wc     removed_wc
 
 Test revert --all to "base" content
 -----------------------------------
 
 (setup from reference repo)
@@ -659,24 +710,37 @@  Misbehavior:
 | - reverting modified_revert
 | - reverting removed_revert
 
   $ hg revert --all --rev 'desc(base)'
   removing added_clean
+  removing added_wc
+  reverting clean_wc
+  forgetting missing_wc
   reverting modified_clean
   reverting modified_revert
+  reverting modified_wc
   adding removed_clean
   reverting removed_revert
+  reverting removed_wc
 
 Compare resulting directory with revert target.
 
 The diff is filtered to include change only. The only difference should be
 additional `.orig` backup file when applicable.
 
+Misbehavior:
+
+- no backup for
+| - added_wc (DATA LOSS)
+
   $ python ../dircontent.py > ../content-base-all.txt
   $ cd ..
   $ diff -U 0 -- content-base.txt content-base-all.txt | grep _
-  [1]
+  +wc     clean_wc.orig
+  +wc     missing_wc
+  +wc     modified_wc.orig
+  +wc     removed_wc.orig
 
 Test revert to parent content with explicit file name
 -----------------------------------------------------
 
 (setup from reference repo)
@@ -695,32 +759,42 @@  revert all files individually and check 
   ### revert for: added_clean
   no changes needed to added_clean
   
   ### revert for: added_revert
   
+  ### revert for: added_wc
+  
   ### revert for: clean_clean
   no changes needed to clean_clean
   
   ### revert for: clean_revert
   no changes needed to clean_revert
   
+  ### revert for: clean_wc
+  
   ### revert for: missing_clean
   missing_clean: no such file in rev * (glob)
   
   ### revert for: missing_revert
   missing_revert: no such file in rev * (glob)
   
+  ### revert for: missing_wc
+  
   ### revert for: modified_clean
   no changes needed to modified_clean
   
   ### revert for: modified_revert
   
+  ### revert for: modified_wc
+  
   ### revert for: removed_clean
   removed_clean: no such file in rev * (glob)
   
   ### revert for: removed_revert
   
+  ### revert for: removed_wc
+  
 
 check resulting directory againt the --all run
 (There should be no difference)
 
   $ python ../dircontent.py > ../content-parent-explicit.txt
@@ -756,28 +830,38 @@  Misbehavior:
   > done
   ### revert for: added_clean
   
   ### revert for: added_revert
   
+  ### revert for: added_wc
+  
   ### revert for: clean_clean
   
   ### revert for: clean_revert
   
+  ### revert for: clean_wc
+  
   ### revert for: missing_clean
   missing_clean: no such file in rev * (glob)
   
   ### revert for: missing_revert
   missing_revert: no such file in rev * (glob)
   
+  ### revert for: missing_wc
+  
   ### revert for: modified_clean
   
   ### revert for: modified_revert
   
+  ### revert for: modified_wc
+  
   ### revert for: removed_clean
   
   ### revert for: removed_revert
   
+  ### revert for: removed_wc
+  
 
 check resulting directory againt the --all run
 (There should be no difference)
 
   $ python ../dircontent.py > ../content-base-explicit.txt