tests/test-revert.t
changeset 22139 1ecd6f1f9869
parent 22138 80206e63c3cc
child 22140 74e932047975
equal deleted inserted replaced
22138:80206e63c3cc 22139:1ecd6f1f9869
   451   > wccontent = {
   451   > wccontent = {
   452   >     # clean: wc content is the same as parent
   452   >     # clean: wc content is the same as parent
   453   >     'clean': lambda cc: cc[1],
   453   >     'clean': lambda cc: cc[1],
   454   >     # revert: wc content is the same as base
   454   >     # revert: wc content is the same as base
   455   >     'revert': lambda cc: cc[0],
   455   >     'revert': lambda cc: cc[0],
       
   456   >     # wc: file exist with a content different from base and parent
       
   457   >     'wc': lambda cc: 'wc',
   456   > }
   458   > }
   457   > 
   459   > 
   458   > # build the combination of possible states
   460   > # build the combination of possible states
   459   > combination = []
   461   > combination = []
   460   > for ctxkey in ctxcontent:
   462   > for ctxkey in ctxcontent:
   497 check list of planned files
   499 check list of planned files
   498 
   500 
   499   $ python gen-revert-cases.py filelist
   501   $ python gen-revert-cases.py filelist
   500   added_clean
   502   added_clean
   501   added_revert
   503   added_revert
       
   504   added_wc
   502   clean_clean
   505   clean_clean
   503   clean_revert
   506   clean_revert
       
   507   clean_wc
   504   missing_clean
   508   missing_clean
   505   missing_revert
   509   missing_revert
       
   510   missing_wc
   506   modified_clean
   511   modified_clean
   507   modified_revert
   512   modified_revert
       
   513   modified_wc
   508   removed_clean
   514   removed_clean
   509   removed_revert
   515   removed_revert
       
   516   removed_wc
   510 
   517 
   511 Script to make a simple text version of the content
   518 Script to make a simple text version of the content
   512 ---------------------------------------------------
   519 ---------------------------------------------------
   513 
   520 
   514   $ cat << EOF >> dircontent.py
   521   $ cat << EOF >> dircontent.py
   533 
   540 
   534   $ python ../gen-revert-cases.py base
   541   $ python ../gen-revert-cases.py base
   535   $ hg addremove --similarity 0
   542   $ hg addremove --similarity 0
   536   adding clean_clean
   543   adding clean_clean
   537   adding clean_revert
   544   adding clean_revert
       
   545   adding clean_wc
   538   adding modified_clean
   546   adding modified_clean
   539   adding modified_revert
   547   adding modified_revert
       
   548   adding modified_wc
   540   adding removed_clean
   549   adding removed_clean
   541   adding removed_revert
   550   adding removed_revert
       
   551   adding removed_wc
   542   $ hg status
   552   $ hg status
   543   A clean_clean
   553   A clean_clean
   544   A clean_revert
   554   A clean_revert
       
   555   A clean_wc
   545   A modified_clean
   556   A modified_clean
   546   A modified_revert
   557   A modified_revert
       
   558   A modified_wc
   547   A removed_clean
   559   A removed_clean
   548   A removed_revert
   560   A removed_revert
       
   561   A removed_wc
   549   $ hg commit -m 'base'
   562   $ hg commit -m 'base'
   550 
   563 
   551 (create a simple text version of the content)
   564 (create a simple text version of the content)
   552 
   565 
   553   $ python ../dircontent.py > ../content-base.txt
   566   $ python ../dircontent.py > ../content-base.txt
   554   $ cat ../content-base.txt
   567   $ cat ../content-base.txt
   555   base   clean_clean
   568   base   clean_clean
   556   base   clean_revert
   569   base   clean_revert
       
   570   base   clean_wc
   557   base   modified_clean
   571   base   modified_clean
   558   base   modified_revert
   572   base   modified_revert
       
   573   base   modified_wc
   559   base   removed_clean
   574   base   removed_clean
   560   base   removed_revert
   575   base   removed_revert
       
   576   base   removed_wc
   561 
   577 
   562 Create parent changeset
   578 Create parent changeset
   563 
   579 
   564   $ python ../gen-revert-cases.py parent
   580   $ python ../gen-revert-cases.py parent
   565   $ hg addremove --similarity 0
   581   $ hg addremove --similarity 0
   566   adding added_clean
   582   adding added_clean
   567   adding added_revert
   583   adding added_revert
       
   584   adding added_wc
   568   removing removed_clean
   585   removing removed_clean
   569   removing removed_revert
   586   removing removed_revert
       
   587   removing removed_wc
   570   $ hg status
   588   $ hg status
   571   M modified_clean
   589   M modified_clean
   572   M modified_revert
   590   M modified_revert
       
   591   M modified_wc
   573   A added_clean
   592   A added_clean
   574   A added_revert
   593   A added_revert
       
   594   A added_wc
   575   R removed_clean
   595   R removed_clean
   576   R removed_revert
   596   R removed_revert
       
   597   R removed_wc
   577   $ hg commit -m 'parent'
   598   $ hg commit -m 'parent'
   578 
   599 
   579 (create a simple text version of the content)
   600 (create a simple text version of the content)
   580 
   601 
   581   $ python ../dircontent.py > ../content-parent.txt
   602   $ python ../dircontent.py > ../content-parent.txt
   582   $ cat ../content-parent.txt
   603   $ cat ../content-parent.txt
   583   parent added_clean
   604   parent added_clean
   584   parent added_revert
   605   parent added_revert
       
   606   parent added_wc
   585   base   clean_clean
   607   base   clean_clean
   586   base   clean_revert
   608   base   clean_revert
       
   609   base   clean_wc
   587   parent modified_clean
   610   parent modified_clean
   588   parent modified_revert
   611   parent modified_revert
       
   612   parent modified_wc
   589 
   613 
   590 Setup working directory
   614 Setup working directory
   591 
   615 
   592   $ python ../gen-revert-cases.py wc | cat
   616   $ python ../gen-revert-cases.py wc | cat
   593   $ hg addremove --similarity 0
   617   $ hg addremove --similarity 0
   594   removing added_revert
   618   removing added_revert
       
   619   adding missing_wc
   595   adding removed_revert
   620   adding removed_revert
   596   $ hg status
   621   adding removed_wc
       
   622   $ hg status
       
   623   M added_wc
       
   624   M clean_wc
   597   M modified_revert
   625   M modified_revert
       
   626   M modified_wc
       
   627   A missing_wc
   598   A removed_revert
   628   A removed_revert
       
   629   A removed_wc
   599   R added_revert
   630   R added_revert
   600 
   631 
   601   $ hg status --rev 'desc("base")'
   632   $ hg status --rev 'desc("base")'
       
   633   M clean_wc
   602   M modified_clean
   634   M modified_clean
       
   635   M modified_wc
       
   636   M removed_wc
   603   A added_clean
   637   A added_clean
       
   638   A added_wc
       
   639   A missing_wc
   604   R removed_clean
   640   R removed_clean
   605 
   641 
   606 (create a simple text version of the content)
   642 (create a simple text version of the content)
   607 
   643 
   608   $ python ../dircontent.py > ../content-wc.txt
   644   $ python ../dircontent.py > ../content-wc.txt
   609   $ cat ../content-wc.txt
   645   $ cat ../content-wc.txt
   610   parent added_clean
   646   parent added_clean
       
   647   wc     added_wc
   611   base   clean_clean
   648   base   clean_clean
   612   base   clean_revert
   649   base   clean_revert
       
   650   wc     clean_wc
       
   651   wc     missing_wc
   613   parent modified_clean
   652   parent modified_clean
   614   base   modified_revert
   653   base   modified_revert
       
   654   wc     modified_wc
   615   base   removed_revert
   655   base   removed_revert
       
   656   wc     removed_wc
   616 
   657 
   617   $ cd ..
   658   $ cd ..
   618 
   659 
   619 Test revert --all to parent content
   660 Test revert --all to parent content
   620 -----------------------------------
   661 -----------------------------------
   626 
   667 
   627 check revert output
   668 check revert output
   628 
   669 
   629   $ hg revert --all
   670   $ hg revert --all
   630   undeleting added_revert
   671   undeleting added_revert
       
   672   reverting added_wc
       
   673   reverting clean_wc
       
   674   forgetting missing_wc
   631   reverting modified_revert
   675   reverting modified_revert
       
   676   reverting modified_wc
   632   forgetting removed_revert
   677   forgetting removed_revert
       
   678   forgetting removed_wc
   633 
   679 
   634 Compare resulting directory with revert target.
   680 Compare resulting directory with revert target.
   635 
   681 
   636 The diff is filtered to include change only. The only difference should be
   682 The diff is filtered to include change only. The only difference should be
   637 additional `.orig` backup file when applicable.
   683 additional `.orig` backup file when applicable.
   638 
   684 
   639   $ python ../dircontent.py > ../content-parent-all.txt
   685   $ python ../dircontent.py > ../content-parent-all.txt
   640   $ cd ..
   686   $ cd ..
   641   $ diff -U 0 -- content-parent.txt content-parent-all.txt | grep _
   687   $ diff -U 0 -- content-parent.txt content-parent-all.txt | grep _
       
   688   +wc     added_wc.orig
       
   689   +wc     clean_wc.orig
       
   690   +wc     missing_wc
   642   +base   modified_revert.orig
   691   +base   modified_revert.orig
       
   692   +wc     modified_wc.orig
   643   +base   removed_revert
   693   +base   removed_revert
       
   694   +wc     removed_wc
   644 
   695 
   645 Test revert --all to "base" content
   696 Test revert --all to "base" content
   646 -----------------------------------
   697 -----------------------------------
   647 
   698 
   648 (setup from reference repo)
   699 (setup from reference repo)
   659 | - reverting modified_revert
   710 | - reverting modified_revert
   660 | - reverting removed_revert
   711 | - reverting removed_revert
   661 
   712 
   662   $ hg revert --all --rev 'desc(base)'
   713   $ hg revert --all --rev 'desc(base)'
   663   removing added_clean
   714   removing added_clean
       
   715   removing added_wc
       
   716   reverting clean_wc
       
   717   forgetting missing_wc
   664   reverting modified_clean
   718   reverting modified_clean
   665   reverting modified_revert
   719   reverting modified_revert
       
   720   reverting modified_wc
   666   adding removed_clean
   721   adding removed_clean
   667   reverting removed_revert
   722   reverting removed_revert
       
   723   reverting removed_wc
   668 
   724 
   669 Compare resulting directory with revert target.
   725 Compare resulting directory with revert target.
   670 
   726 
   671 The diff is filtered to include change only. The only difference should be
   727 The diff is filtered to include change only. The only difference should be
   672 additional `.orig` backup file when applicable.
   728 additional `.orig` backup file when applicable.
       
   729 
       
   730 Misbehavior:
       
   731 
       
   732 - no backup for
       
   733 | - added_wc (DATA LOSS)
   673 
   734 
   674   $ python ../dircontent.py > ../content-base-all.txt
   735   $ python ../dircontent.py > ../content-base-all.txt
   675   $ cd ..
   736   $ cd ..
   676   $ diff -U 0 -- content-base.txt content-base-all.txt | grep _
   737   $ diff -U 0 -- content-base.txt content-base-all.txt | grep _
   677   [1]
   738   +wc     clean_wc.orig
       
   739   +wc     missing_wc
       
   740   +wc     modified_wc.orig
       
   741   +wc     removed_wc.orig
   678 
   742 
   679 Test revert to parent content with explicit file name
   743 Test revert to parent content with explicit file name
   680 -----------------------------------------------------
   744 -----------------------------------------------------
   681 
   745 
   682 (setup from reference repo)
   746 (setup from reference repo)
   695   ### revert for: added_clean
   759   ### revert for: added_clean
   696   no changes needed to added_clean
   760   no changes needed to added_clean
   697   
   761   
   698   ### revert for: added_revert
   762   ### revert for: added_revert
   699   
   763   
       
   764   ### revert for: added_wc
       
   765   
   700   ### revert for: clean_clean
   766   ### revert for: clean_clean
   701   no changes needed to clean_clean
   767   no changes needed to clean_clean
   702   
   768   
   703   ### revert for: clean_revert
   769   ### revert for: clean_revert
   704   no changes needed to clean_revert
   770   no changes needed to clean_revert
   705   
   771   
       
   772   ### revert for: clean_wc
       
   773   
   706   ### revert for: missing_clean
   774   ### revert for: missing_clean
   707   missing_clean: no such file in rev * (glob)
   775   missing_clean: no such file in rev * (glob)
   708   
   776   
   709   ### revert for: missing_revert
   777   ### revert for: missing_revert
   710   missing_revert: no such file in rev * (glob)
   778   missing_revert: no such file in rev * (glob)
   711   
   779   
       
   780   ### revert for: missing_wc
       
   781   
   712   ### revert for: modified_clean
   782   ### revert for: modified_clean
   713   no changes needed to modified_clean
   783   no changes needed to modified_clean
   714   
   784   
   715   ### revert for: modified_revert
   785   ### revert for: modified_revert
   716   
   786   
       
   787   ### revert for: modified_wc
       
   788   
   717   ### revert for: removed_clean
   789   ### revert for: removed_clean
   718   removed_clean: no such file in rev * (glob)
   790   removed_clean: no such file in rev * (glob)
   719   
   791   
   720   ### revert for: removed_revert
   792   ### revert for: removed_revert
       
   793   
       
   794   ### revert for: removed_wc
   721   
   795   
   722 
   796 
   723 check resulting directory againt the --all run
   797 check resulting directory againt the --all run
   724 (There should be no difference)
   798 (There should be no difference)
   725 
   799 
   756   > done
   830   > done
   757   ### revert for: added_clean
   831   ### revert for: added_clean
   758   
   832   
   759   ### revert for: added_revert
   833   ### revert for: added_revert
   760   
   834   
       
   835   ### revert for: added_wc
       
   836   
   761   ### revert for: clean_clean
   837   ### revert for: clean_clean
   762   
   838   
   763   ### revert for: clean_revert
   839   ### revert for: clean_revert
       
   840   
       
   841   ### revert for: clean_wc
   764   
   842   
   765   ### revert for: missing_clean
   843   ### revert for: missing_clean
   766   missing_clean: no such file in rev * (glob)
   844   missing_clean: no such file in rev * (glob)
   767   
   845   
   768   ### revert for: missing_revert
   846   ### revert for: missing_revert
   769   missing_revert: no such file in rev * (glob)
   847   missing_revert: no such file in rev * (glob)
   770   
   848   
       
   849   ### revert for: missing_wc
       
   850   
   771   ### revert for: modified_clean
   851   ### revert for: modified_clean
   772   
   852   
   773   ### revert for: modified_revert
   853   ### revert for: modified_revert
   774   
   854   
       
   855   ### revert for: modified_wc
       
   856   
   775   ### revert for: removed_clean
   857   ### revert for: removed_clean
   776   
   858   
   777   ### revert for: removed_revert
   859   ### revert for: removed_revert
       
   860   
       
   861   ### revert for: removed_wc
   778   
   862   
   779 
   863 
   780 check resulting directory againt the --all run
   864 check resulting directory againt the --all run
   781 (There should be no difference)
   865 (There should be no difference)
   782 
   866