comparison tests/test-revert.t @ 23161:6f31f46b8544

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 19 Oct 2014 22:19:22 -0700
parents 4f4e6815f286
children 8c29000c4295
comparison
equal deleted inserted replaced
23160:4f4e6815f286 23161:6f31f46b8544
450 > 'revert': (True, lambda cc: cc[0]), 450 > 'revert': (True, lambda cc: cc[0]),
451 > # wc: file exist with a content different from base and parent 451 > # wc: file exist with a content different from base and parent
452 > 'wc': (True, lambda cc: 'content3'), 452 > 'wc': (True, lambda cc: 'content3'),
453 > # deleted: file is recorded as tracked but missing 453 > # deleted: file is recorded as tracked but missing
454 > # rely on file deletion outside of this script 454 > # rely on file deletion outside of this script
455 > 'deleted': (True, lambda cc:'TOBEDELETED'), 455 > 'deleted': (True, lambda cc: None),
456 > } 456 > }
457 > # untracked-X is a version of X where the file is not tracked (? unknown) 457 > # untracked-X is a version of X where the file is not tracked (? unknown)
458 > wccontent['untracked-clean'] = (False, wccontent['clean'][1]) 458 > wccontent['untracked-clean'] = (False, wccontent['clean'][1])
459 > wccontent['untracked-deleted'] = (False, wccontent['deleted'][1]) 459 > wccontent['untracked-deleted'] = (False, wccontent['deleted'][1])
460 > wccontent['untracked-revert'] = (False, wccontent['revert'][1]) 460 > wccontent['untracked-revert'] = (False, wccontent['revert'][1])
470 > if not base and 'revert' in wckey: 470 > if not base and 'revert' in wckey:
471 > continue 471 > continue
472 > if not parent and 'deleted' in wckey: 472 > if not parent and 'deleted' in wckey:
473 > continue 473 > continue
474 > def statestring(content): 474 > def statestring(content):
475 > return content in (None, 'TOBEDELETED') and 'missing' or content 475 > return content is None and 'missing' or content
476 > wcc = wcfunc(ctxvalue) 476 > wcc = wcfunc(ctxvalue)
477 > trackedstring = tracked and 'tracked' or 'untracked' 477 > trackedstring = tracked and 'tracked' or 'untracked'
478 > filename = "%s_%s_%s-%s" % (statestring(base), 478 > filename = "%s_%s_%s-%s" % (statestring(base),
479 > statestring(parent), 479 > statestring(parent),
480 > statestring(wcc), 480 > statestring(wcc),
495 > elif target == 'base': 495 > elif target == 'base':
496 > content.append((filename, base)) 496 > content.append((filename, base))
497 > elif target == 'parent': 497 > elif target == 'parent':
498 > content.append((filename, parent)) 498 > content.append((filename, parent))
499 > elif target == 'wc': 499 > elif target == 'wc':
500 > content.append((filename, wcc)) 500 > # Make sure there is content so the file gets written and can be
501 > # tracked. It will be deleted outside of this script.
502 > content.append((filename, wcc or 'TOBEDELETED'))
501 > else: 503 > else:
502 > print >> sys.stderr, "unknown target:", target 504 > print >> sys.stderr, "unknown target:", target
503 > sys.exit(1) 505 > sys.exit(1)
504 > 506 >
505 > # write actual content 507 > # write actual content
709 $ hg addremove --similarity 0 711 $ hg addremove --similarity 0
710 adding content1_missing_content1-tracked 712 adding content1_missing_content1-tracked
711 adding content1_missing_content1-untracked 713 adding content1_missing_content1-untracked
712 adding content1_missing_content3-tracked 714 adding content1_missing_content3-tracked
713 adding content1_missing_content3-untracked 715 adding content1_missing_content3-untracked
716 adding content1_missing_missing-tracked
717 adding content1_missing_missing-untracked
714 adding missing_missing_content3-tracked 718 adding missing_missing_content3-tracked
715 adding missing_missing_content3-untracked 719 adding missing_missing_content3-untracked
720 adding missing_missing_missing-tracked
721 adding missing_missing_missing-untracked
716 $ hg forget *_*_*-untracked 722 $ hg forget *_*_*-untracked
717 $ rm *_*_missing-* 723 $ rm *_*_missing-*
718 $ hg status 724 $ hg status
719 M content1_content1_content3-tracked 725 M content1_content1_content3-tracked
720 M content1_content2_content1-tracked 726 M content1_content2_content1-tracked
733 R missing_content2_content2-untracked 739 R missing_content2_content2-untracked
734 R missing_content2_content3-untracked 740 R missing_content2_content3-untracked
735 R missing_content2_missing-untracked 741 R missing_content2_missing-untracked
736 ! content1_content1_missing-tracked 742 ! content1_content1_missing-tracked
737 ! content1_content2_missing-tracked 743 ! content1_content2_missing-tracked
744 ! content1_missing_missing-tracked
738 ! missing_content2_missing-tracked 745 ! missing_content2_missing-tracked
746 ! missing_missing_missing-tracked
739 ? content1_missing_content1-untracked 747 ? content1_missing_content1-untracked
740 ? content1_missing_content3-untracked 748 ? content1_missing_content3-untracked
741 ? missing_missing_content3-untracked 749 ? missing_missing_content3-untracked
742 750
743 $ hg status --rev 'desc("base")' 751 $ hg status --rev 'desc("base")'
759 R content1_missing_content3-untracked 767 R content1_missing_content3-untracked
760 R content1_missing_missing-tracked 768 R content1_missing_missing-tracked
761 R content1_missing_missing-untracked 769 R content1_missing_missing-untracked
762 ! content1_content1_missing-tracked 770 ! content1_content1_missing-tracked
763 ! content1_content2_missing-tracked 771 ! content1_content2_missing-tracked
772 ! content1_missing_missing-tracked
764 ! missing_content2_missing-tracked 773 ! missing_content2_missing-tracked
774 ! missing_missing_missing-tracked
765 ? missing_missing_content3-untracked 775 ? missing_missing_content3-untracked
766 776
767 (create a simple text version of the content) 777 (create a simple text version of the content)
768 778
769 $ python ../dircontent.py > ../content-wc.txt 779 $ python ../dircontent.py > ../content-wc.txt
814 undeleting content1_content2_content3-untracked 824 undeleting content1_content2_content3-untracked
815 reverting content1_content2_missing-tracked 825 reverting content1_content2_missing-tracked
816 undeleting content1_content2_missing-untracked 826 undeleting content1_content2_missing-untracked
817 forgetting content1_missing_content1-tracked 827 forgetting content1_missing_content1-tracked
818 forgetting content1_missing_content3-tracked 828 forgetting content1_missing_content3-tracked
829 forgetting content1_missing_missing-tracked
819 undeleting missing_content2_content2-untracked 830 undeleting missing_content2_content2-untracked
820 reverting missing_content2_content3-tracked 831 reverting missing_content2_content3-tracked
821 undeleting missing_content2_content3-untracked 832 undeleting missing_content2_content3-untracked
822 reverting missing_content2_missing-tracked 833 reverting missing_content2_missing-tracked
823 undeleting missing_content2_missing-untracked 834 undeleting missing_content2_missing-untracked
824 forgetting missing_missing_content3-tracked 835 forgetting missing_missing_content3-tracked
836 forgetting missing_missing_missing-tracked
825 837
826 Compare resulting directory with revert target. 838 Compare resulting directory with revert target.
827 839
828 The diff is filtered to include change only. The only difference should be 840 The diff is filtered to include change only. The only difference should be
829 additional `.orig` backup file when applicable. 841 additional `.orig` backup file when applicable.
870 reverting content1_content2_missing-tracked 882 reverting content1_content2_missing-tracked
871 undeleting content1_content2_missing-untracked 883 undeleting content1_content2_missing-untracked
872 adding content1_missing_content1-untracked 884 adding content1_missing_content1-untracked
873 reverting content1_missing_content3-tracked 885 reverting content1_missing_content3-tracked
874 adding content1_missing_content3-untracked 886 adding content1_missing_content3-untracked
875 adding content1_missing_missing-tracked 887 reverting content1_missing_missing-tracked
876 adding content1_missing_missing-untracked 888 adding content1_missing_missing-untracked
877 removing missing_content2_content2-tracked 889 removing missing_content2_content2-tracked
878 removing missing_content2_content3-tracked 890 removing missing_content2_content3-tracked
879 removing missing_content2_missing-tracked 891 removing missing_content2_missing-tracked
880 forgetting missing_missing_content3-tracked 892 forgetting missing_missing_content3-tracked
893 forgetting missing_missing_missing-tracked
881 894
882 Compare resulting directory with revert target. 895 Compare resulting directory with revert target.
883 896
884 The diff is filtered to include change only. The only difference should be 897 The diff is filtered to include change only. The only difference should be
885 additional `.orig` backup file when applicable. 898 additional `.orig` backup file when applicable.
955 968
956 ### revert for: content1_missing_content3-untracked 969 ### revert for: content1_missing_content3-untracked
957 file not managed: content1_missing_content3-untracked 970 file not managed: content1_missing_content3-untracked
958 971
959 ### revert for: content1_missing_missing-tracked 972 ### revert for: content1_missing_missing-tracked
960 content1_missing_missing-tracked: no such file in rev * (glob)
961 973
962 ### revert for: content1_missing_missing-untracked 974 ### revert for: content1_missing_missing-untracked
963 content1_missing_missing-untracked: no such file in rev * (glob) 975 content1_missing_missing-untracked: no such file in rev * (glob)
964 976
965 ### revert for: missing_content2_content2-tracked 977 ### revert for: missing_content2_content2-tracked
979 991
980 ### revert for: missing_missing_content3-untracked 992 ### revert for: missing_missing_content3-untracked
981 file not managed: missing_missing_content3-untracked 993 file not managed: missing_missing_content3-untracked
982 994
983 ### revert for: missing_missing_missing-tracked 995 ### revert for: missing_missing_missing-tracked
984 missing_missing_missing-tracked: no such file in rev * (glob)
985 996
986 ### revert for: missing_missing_missing-untracked 997 ### revert for: missing_missing_missing-untracked
987 missing_missing_missing-untracked: no such file in rev * (glob) 998 missing_missing_missing-untracked: no such file in rev * (glob)
988 999
989 1000
1073 1084
1074 ### revert for: missing_missing_content3-untracked 1085 ### revert for: missing_missing_content3-untracked
1075 file not managed: missing_missing_content3-untracked 1086 file not managed: missing_missing_content3-untracked
1076 1087
1077 ### revert for: missing_missing_missing-tracked 1088 ### revert for: missing_missing_missing-tracked
1078 missing_missing_missing-tracked: no such file in rev * (glob)
1079 1089
1080 ### revert for: missing_missing_missing-untracked 1090 ### revert for: missing_missing_missing-untracked
1081 missing_missing_missing-untracked: no such file in rev * (glob) 1091 missing_missing_missing-untracked: no such file in rev * (glob)
1082 1092
1083 1093