test-revert: make sure all 'tracked' files are really tracked
authorMartin von Zweigbergk <martinvonz@google.com>
Sun, 19 Oct 2014 22:19:22 -0700
changeset 23161 6f31f46b8544
parent 23160 4f4e6815f286
child 23162 69524a05a7fa
test-revert: make sure all 'tracked' files are really tracked When a file is missing in the 'parent' version and is tracked but missing in the working directory, which happens by the 'missing' or 'removed' types, and the 'clean' type in the working directory, the file does not exist in the working directory (unlike it would had the 'deleted' type been used). Thus, the *_missing_missing_tracked are not actually tracked and they end up testing the same state as *_missing_missing_untracked. To make them tracked, add a temporary file, just like we do for the delete case. For simplicity's sake, let's make sure the gen-revert-cases.py script always puts a file in the working directory, whether or not it's going to be deleted.
tests/test-revert.t
--- a/tests/test-revert.t	Sat Oct 18 18:12:54 2014 -0700
+++ b/tests/test-revert.t	Sun Oct 19 22:19:22 2014 -0700
@@ -452,7 +452,7 @@
   >     'wc': (True, lambda cc: 'content3'),
   >     # deleted: file is recorded as tracked but missing
   >     #          rely on file deletion outside of this script
-  >     'deleted': (True, lambda cc:'TOBEDELETED'),
+  >     'deleted': (True, lambda cc: None),
   > }
   > # untracked-X is a version of X where the file is not tracked (? unknown)
   > wccontent['untracked-clean'] = (False, wccontent['clean'][1])
@@ -472,7 +472,7 @@
   >         if not parent and 'deleted' in wckey:
   >             continue
   >         def statestring(content):
-  >             return content in (None, 'TOBEDELETED') and 'missing' or content
+  >             return content is None and 'missing' or content
   >         wcc = wcfunc(ctxvalue)
   >         trackedstring = tracked and 'tracked' or 'untracked'
   >         filename = "%s_%s_%s-%s" % (statestring(base),
@@ -497,7 +497,9 @@
   >     elif target == 'parent':
   >         content.append((filename, parent))
   >     elif target == 'wc':
-  >         content.append((filename, wcc))
+  >         # Make sure there is content so the file gets written and can be
+  >         # tracked. It will be deleted outside of this script.
+  >         content.append((filename, wcc or 'TOBEDELETED'))
   >     else:
   >         print >> sys.stderr, "unknown target:", target
   >         sys.exit(1)
@@ -711,8 +713,12 @@
   adding content1_missing_content1-untracked
   adding content1_missing_content3-tracked
   adding content1_missing_content3-untracked
+  adding content1_missing_missing-tracked
+  adding content1_missing_missing-untracked
   adding missing_missing_content3-tracked
   adding missing_missing_content3-untracked
+  adding missing_missing_missing-tracked
+  adding missing_missing_missing-untracked
   $ hg forget *_*_*-untracked
   $ rm *_*_missing-*
   $ hg status
@@ -735,7 +741,9 @@
   R missing_content2_missing-untracked
   ! content1_content1_missing-tracked
   ! content1_content2_missing-tracked
+  ! content1_missing_missing-tracked
   ! missing_content2_missing-tracked
+  ! missing_missing_missing-tracked
   ? content1_missing_content1-untracked
   ? content1_missing_content3-untracked
   ? missing_missing_content3-untracked
@@ -761,7 +769,9 @@
   R content1_missing_missing-untracked
   ! content1_content1_missing-tracked
   ! content1_content2_missing-tracked
+  ! content1_missing_missing-tracked
   ! missing_content2_missing-tracked
+  ! missing_missing_missing-tracked
   ? missing_missing_content3-untracked
 
 (create a simple text version of the content)
@@ -816,12 +826,14 @@
   undeleting content1_content2_missing-untracked
   forgetting content1_missing_content1-tracked
   forgetting content1_missing_content3-tracked
+  forgetting content1_missing_missing-tracked
   undeleting missing_content2_content2-untracked
   reverting missing_content2_content3-tracked
   undeleting missing_content2_content3-untracked
   reverting missing_content2_missing-tracked
   undeleting missing_content2_missing-untracked
   forgetting missing_missing_content3-tracked
+  forgetting missing_missing_missing-tracked
 
 Compare resulting directory with revert target.
 
@@ -872,12 +884,13 @@
   adding content1_missing_content1-untracked
   reverting content1_missing_content3-tracked
   adding content1_missing_content3-untracked
-  adding content1_missing_missing-tracked
+  reverting content1_missing_missing-tracked
   adding content1_missing_missing-untracked
   removing missing_content2_content2-tracked
   removing missing_content2_content3-tracked
   removing missing_content2_missing-tracked
   forgetting missing_missing_content3-tracked
+  forgetting missing_missing_missing-tracked
 
 Compare resulting directory with revert target.
 
@@ -957,7 +970,6 @@
   file not managed: content1_missing_content3-untracked
   
   ### revert for: content1_missing_missing-tracked
-  content1_missing_missing-tracked: no such file in rev * (glob)
   
   ### revert for: content1_missing_missing-untracked
   content1_missing_missing-untracked: no such file in rev * (glob)
@@ -981,7 +993,6 @@
   file not managed: missing_missing_content3-untracked
   
   ### revert for: missing_missing_missing-tracked
-  missing_missing_missing-tracked: no such file in rev * (glob)
   
   ### revert for: missing_missing_missing-untracked
   missing_missing_missing-untracked: no such file in rev * (glob)
@@ -1075,7 +1086,6 @@
   file not managed: missing_missing_content3-untracked
   
   ### revert for: missing_missing_missing-tracked
-  missing_missing_missing-tracked: no such file in rev * (glob)
   
   ### revert for: missing_missing_missing-untracked
   missing_missing_missing-untracked: no such file in rev * (glob)