tests/test-evolve-public-content-divergent-main.t
changeset 4660 b62ed7c69561
parent 4473 14437b18b024
parent 4633 61c2518cd6d2
child 4673 3ef4980353af
child 4676 b6c819facbe8
equal deleted inserted replaced
4659:4d2f8c99f23a 4660:b62ed7c69561
       
     1 =============================================================
       
     2 Tests the resolution of public content divergence: main cases
       
     3 =============================================================
       
     4 
       
     5 This file intend to cover all the common cases of public content divergence.
       
     6 That is all the variant of:
       
     7 parent: same/different
       
     8 relocation: [no-]conflict
       
     9 merging: [no-]conflict
       
    10 
       
    11 Setup
       
    12 =====
       
    13   $ cat >> $HGRCPATH <<EOF
       
    14   > [alias]
       
    15   > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {instabilities}\n\n"
       
    16   > [phases]
       
    17   > publish = False
       
    18   > [extensions]
       
    19   > rebase =
       
    20   > EOF
       
    21   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
       
    22 
       
    23 Testing when same parent, no conflict:
       
    24 --------------------------------------
       
    25 
       
    26 Prepare the repository:
       
    27 
       
    28   $ hg init pubdiv1
       
    29   $ cd pubdiv1
       
    30   $ for ch in a b; do
       
    31   >   echo $ch > $ch;
       
    32   >   hg ci -Aqm "added "$ch;
       
    33   > done;
       
    34   $ hg glog
       
    35   @  1:5f6d8a4bf34a added b
       
    36   |   draft
       
    37   |
       
    38   o  0:9092f1db7931 added a
       
    39       draft
       
    40   
       
    41 
       
    42 Make an amend and change phase to public:
       
    43 
       
    44   $ sed -i "1 i I am first" b
       
    45   $ hg amend
       
    46   $ hg phase --public
       
    47 
       
    48 Amend again to create a cset divergent to public one:
       
    49 
       
    50   $ hg up 1 --hidden -q
       
    51   updated to hidden changeset 5f6d8a4bf34a
       
    52   (hidden revision '5f6d8a4bf34a' was rewritten as: 44f360db368f)
       
    53   working directory parent is obsolete! (5f6d8a4bf34a)
       
    54 
       
    55   $ echo "I am second" >> b
       
    56   $ hg ci --amend -m "updated b"
       
    57   1 new content-divergent changesets
       
    58 
       
    59   $ hg glog
       
    60   @  3:dcdaf152280a updated b
       
    61   |   draft content-divergent
       
    62   |
       
    63   | o  2:44f360db368f added b
       
    64   |/    public
       
    65   |
       
    66   o  0:9092f1db7931 added a
       
    67       public
       
    68   
       
    69 
       
    70 Lets resolve the public content-divergence:
       
    71 
       
    72   $ hg evolve --content-divergent
       
    73   merge:[2] added b
       
    74   with: [3] updated b
       
    75   base: [1] added b
       
    76   merging b
       
    77   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
       
    78   committed as c1aa9cfb6cf8
       
    79   working directory is now at c1aa9cfb6cf8
       
    80 
       
    81 Following graph log shows that it correctly merged the two divergent csets:
       
    82 
       
    83   $ hg glog -p
       
    84   @  5:c1aa9cfb6cf8 phase-divergent update to 44f360db368f:
       
    85   |   draft
       
    86   |
       
    87   |  diff -r 44f360db368f -r c1aa9cfb6cf8 b
       
    88   |  --- a/b	Thu Jan 01 00:00:00 1970 +0000
       
    89   |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
       
    90   |  @@ -1,2 +1,3 @@
       
    91   |   I am first
       
    92   |   b
       
    93   |  +I am second
       
    94   |
       
    95   o  2:44f360db368f added b
       
    96   |   public
       
    97   |
       
    98   |  diff -r 9092f1db7931 -r 44f360db368f b
       
    99   |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   100   |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
       
   101   |  @@ -0,0 +1,2 @@
       
   102   |  +I am first
       
   103   |  +b
       
   104   |
       
   105   o  0:9092f1db7931 added a
       
   106       public
       
   107   
       
   108      diff -r 000000000000 -r 9092f1db7931 a
       
   109      --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   110      +++ b/a	Thu Jan 01 00:00:00 1970 +0000
       
   111      @@ -0,0 +1,1 @@
       
   112      +a
       
   113   
       
   114   $ hg evolve -l
       
   115   $ cd ..
       
   116 
       
   117 Testing when same parent, merging conflict:
       
   118 -------------------------------------------
       
   119 
       
   120 Prepare the repository:
       
   121 
       
   122   $ hg init pubdiv2
       
   123   $ cd pubdiv2
       
   124   $ for ch in a b; do
       
   125   >   echo $ch > $ch;
       
   126   >   hg ci -Aqm "added "$ch;
       
   127   > done;
       
   128   $ hg glog
       
   129   @  1:5f6d8a4bf34a added b
       
   130   |   draft
       
   131   |
       
   132   o  0:9092f1db7931 added a
       
   133       draft
       
   134   
       
   135 
       
   136 Make an amend and change phase to public:
       
   137 
       
   138   $ echo "I am foo" > b
       
   139   $ hg amend
       
   140   $ hg phase --public
       
   141 
       
   142 Amend again to create a cset divergent to public one:
       
   143 
       
   144   $ hg up 1 --hidden -q
       
   145   updated to hidden changeset 5f6d8a4bf34a
       
   146   (hidden revision '5f6d8a4bf34a' was rewritten as: 580f2d01e52c)
       
   147   working directory parent is obsolete! (5f6d8a4bf34a)
       
   148 
       
   149   $ echo "I am bar" > b
       
   150   $ hg ci --amend -m "updated b"
       
   151   1 new content-divergent changesets
       
   152 
       
   153   $ hg glog
       
   154   @  3:0e805383168e updated b
       
   155   |   draft content-divergent
       
   156   |
       
   157   | o  2:580f2d01e52c added b
       
   158   |/    public
       
   159   |
       
   160   o  0:9092f1db7931 added a
       
   161       public
       
   162   
       
   163 
       
   164 Lets resolve the divergence:
       
   165 
       
   166   $ hg evolve --content-divergent
       
   167   merge:[2] added b
       
   168   with: [3] updated b
       
   169   base: [1] added b
       
   170   merging b
       
   171   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
       
   172   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
       
   173   fix conflicts and see `hg help evolve.interrupted`
       
   174   [1]
       
   175 
       
   176   $ echo "I am foobar" > b
       
   177   $ hg resolve -m --tool union
       
   178   (no more unresolved files)
       
   179   continue: hg evolve --continue
       
   180   $ hg evolve --continue
       
   181   committed as 1a739394e9d4
       
   182   working directory is now at 1a739394e9d4
       
   183 
       
   184   $ hg glog
       
   185   @  5:1a739394e9d4 phase-divergent update to 580f2d01e52c:
       
   186   |   draft
       
   187   |
       
   188   o  2:580f2d01e52c added b
       
   189   |   public
       
   190   |
       
   191   o  0:9092f1db7931 added a
       
   192       public
       
   193   
       
   194 Testing when different parent, no conflict:
       
   195 -------------------------------------------
       
   196 
       
   197   $ hg init pubdiv3
       
   198   $ cd pubdiv3
       
   199   $ for ch in a b c d; do
       
   200   >   echo $ch > $ch;
       
   201   >   hg ci -Aqm "added "$ch;
       
   202   > done;
       
   203 
       
   204   $ hg up .^
       
   205   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   206   $ echo dd > d
       
   207   $ hg add d
       
   208   $ hg ci -m "added d"
       
   209   created new head
       
   210 
       
   211   $ hg up 1
       
   212   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   213   $ echo dd > d
       
   214   $ echo e > e
       
   215   $ hg add d e
       
   216   $ hg ci -m "added d e"
       
   217   created new head
       
   218 
       
   219   $ hg glog
       
   220   @  5:4291d72ee19a added d e
       
   221   |   draft
       
   222   |
       
   223   | o  4:93cd84bbdaca added d
       
   224   | |   draft
       
   225   | |
       
   226   | | o  3:9150fe93bec6 added d
       
   227   | |/    draft
       
   228   | |
       
   229   | o  2:155349b645be added c
       
   230   |/    draft
       
   231   |
       
   232   o  1:5f6d8a4bf34a added b
       
   233   |   draft
       
   234   |
       
   235   o  0:9092f1db7931 added a
       
   236       draft
       
   237   
       
   238 
       
   239   $ hg prune 3 -s 5
       
   240   1 changesets pruned
       
   241   $ hg prune 3 -s 4 --hidden
       
   242   1 changesets pruned
       
   243   2 new content-divergent changesets
       
   244 
       
   245 Change phase to public for one head:
       
   246   $ hg phase -r 4 --public
       
   247 
       
   248   $ hg glog
       
   249   @  5:4291d72ee19a added d e
       
   250   |   draft content-divergent
       
   251   |
       
   252   | o  4:93cd84bbdaca added d
       
   253   | |   public
       
   254   | |
       
   255   | o  2:155349b645be added c
       
   256   |/    public
       
   257   |
       
   258   o  1:5f6d8a4bf34a added b
       
   259   |   public
       
   260   |
       
   261   o  0:9092f1db7931 added a
       
   262       public
       
   263   
       
   264 
       
   265   $ hg evolve --content-divergent --any
       
   266   merge:[4] added d
       
   267   with: [5] added d e
       
   268   base: [3] added d
       
   269   rebasing "other" content-divergent changeset 4291d72ee19a on 155349b645be
       
   270   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   271   committed as 4cbe48a0c3d9
       
   272   working directory is now at 4cbe48a0c3d9
       
   273 
       
   274   $ hg glog -l 1
       
   275   @  8:4cbe48a0c3d9 phase-divergent update to 93cd84bbdaca:
       
   276   |   draft
       
   277   ~
       
   278 
       
   279   $ hg evolve -l
       
   280   $ cd ..
       
   281 
       
   282 Testing when different parents, relocation conflict:
       
   283 ----------------------------------------------------
       
   284 
       
   285   $ hg init pubdiv4
       
   286   $ cd pubdiv4
       
   287   $ for ch in a b c d; do
       
   288   >   echo $ch > $ch;
       
   289   >   hg ci -Aqm "added "$ch;
       
   290   > done;
       
   291 
       
   292   $ hg up .^^
       
   293   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   294   $ echo d > d
       
   295   $ echo cfoo > c
       
   296   $ echo e > e
       
   297   $ hg add d c e
       
   298   $ hg ci -m "added d c e"
       
   299   created new head
       
   300 
       
   301   $ hg up 'desc("added c")'
       
   302   1 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   303   $ echo dd > d
       
   304   $ hg add d
       
   305   $ hg ci -m "added d"
       
   306   created new head
       
   307 
       
   308   $ hg glog
       
   309   @  5:93cd84bbdaca added d
       
   310   |   draft
       
   311   |
       
   312   | o  4:f31bcc378766 added d c e
       
   313   | |   draft
       
   314   | |
       
   315   +---o  3:9150fe93bec6 added d
       
   316   | |     draft
       
   317   | |
       
   318   o |  2:155349b645be added c
       
   319   |/    draft
       
   320   |
       
   321   o  1:5f6d8a4bf34a added b
       
   322   |   draft
       
   323   |
       
   324   o  0:9092f1db7931 added a
       
   325       draft
       
   326   
       
   327   $ hg prune 'min(desc("re:added d$"))' -s 'max(desc("re:added d$"))'
       
   328   1 changesets pruned
       
   329   $ hg prune 'min(desc("re:added d$"))' -s 'desc("added d c e")' --hidden
       
   330   1 changesets pruned
       
   331   2 new content-divergent changesets
       
   332 
       
   333 Change phase to public for one head:
       
   334   $ hg phase --public -r 'max(desc("re:added d$"))'
       
   335 
       
   336   $ hg glog
       
   337   @  5:93cd84bbdaca added d
       
   338   |   public
       
   339   |
       
   340   | *  4:f31bcc378766 added d c e
       
   341   | |   draft content-divergent
       
   342   | |
       
   343   o |  2:155349b645be added c
       
   344   |/    public
       
   345   |
       
   346   o  1:5f6d8a4bf34a added b
       
   347   |   public
       
   348   |
       
   349   o  0:9092f1db7931 added a
       
   350       public
       
   351   
       
   352   $ hg evolve --content-divergent --any --update
       
   353   merge:[5] added d
       
   354   with: [4] added d c e
       
   355   base: [3] added d
       
   356   rebasing "other" content-divergent changeset f31bcc378766 on 155349b645be
       
   357   merging c
       
   358   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
       
   359   fix conflicts and see `hg help evolve.interrupted`
       
   360   [1]
       
   361 
       
   362   $ hg diff
       
   363   diff -r 155349b645be c
       
   364   --- a/c	Thu Jan 01 00:00:00 1970 +0000
       
   365   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
       
   366   @@ -1,1 +1,5 @@
       
   367   +<<<<<<< destination: 155349b645be - test: added c
       
   368    c
       
   369   +=======
       
   370   +cfoo
       
   371   +>>>>>>> evolving:    f31bcc378766 - test: added d c e
       
   372   diff -r 155349b645be d
       
   373   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   374   +++ b/d	Thu Jan 01 00:00:00 1970 +0000
       
   375   @@ -0,0 +1,1 @@
       
   376   +d
       
   377   diff -r 155349b645be e
       
   378   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   379   +++ b/e	Thu Jan 01 00:00:00 1970 +0000
       
   380   @@ -0,0 +1,1 @@
       
   381   +e
       
   382 
       
   383   $ echo c > c
       
   384   $ hg res -m
       
   385   (no more unresolved files)
       
   386   continue: hg evolve --continue
       
   387 
       
   388   $ hg evolve --continue
       
   389   evolving 4:f31bcc378766 "added d c e"
       
   390   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   391   committed as 412dde898967
       
   392   working directory is now at 412dde898967
       
   393   $ hg export
       
   394   # HG changeset patch
       
   395   # User test
       
   396   # Date 0 0
       
   397   #      Thu Jan 01 00:00:00 1970 +0000
       
   398   # Node ID 412dde898967b50e7d334aefff778a9af46d29d1
       
   399   # Parent  93cd84bbdacaeb8f881c29a609dbdd30c38cbc57
       
   400   phase-divergent update to 93cd84bbdaca:
       
   401   
       
   402   added d c e
       
   403   
       
   404   diff -r 93cd84bbdaca -r 412dde898967 e
       
   405   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   406   +++ b/e	Thu Jan 01 00:00:00 1970 +0000
       
   407   @@ -0,0 +1,1 @@
       
   408   +e
       
   409 
       
   410   $ hg evolve -l
       
   411   $ cd ..
       
   412 
       
   413 Testing when merging conflicts, relocation don't:
       
   414 -------------------------------------------------
       
   415 
       
   416   $ hg init pubdiv5
       
   417   $ cd pubdiv5
       
   418   $ for ch in a b c d; do
       
   419   >   echo $ch > $ch;
       
   420   >   hg ci -Aqm "added "$ch;
       
   421   > done;
       
   422 
       
   423   $ hg up .^^
       
   424   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   425   $ echo dconflict > d
       
   426   $ hg add d
       
   427   $ hg ci -m "added d"
       
   428   created new head
       
   429 
       
   430   $ hg up 2
       
   431   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   432   $ echo dd > d
       
   433   $ hg add d
       
   434   $ hg ci -m "added d"
       
   435   created new head
       
   436 
       
   437   $ hg glog
       
   438   @  5:93cd84bbdaca added d
       
   439   |   draft
       
   440   |
       
   441   | o  4:9411ad1fe615 added d
       
   442   | |   draft
       
   443   | |
       
   444   +---o  3:9150fe93bec6 added d
       
   445   | |     draft
       
   446   | |
       
   447   o |  2:155349b645be added c
       
   448   |/    draft
       
   449   |
       
   450   o  1:5f6d8a4bf34a added b
       
   451   |   draft
       
   452   |
       
   453   o  0:9092f1db7931 added a
       
   454       draft
       
   455   
       
   456   $ hg prune 3 -s 5
       
   457   1 changesets pruned
       
   458   $ hg prune 3 -s 4 --hidden
       
   459   1 changesets pruned
       
   460   2 new content-divergent changesets
       
   461 
       
   462 Change phase to public for one head:
       
   463   $ hg phase --public -r 5
       
   464 
       
   465   $ hg glog
       
   466   @  5:93cd84bbdaca added d
       
   467   |   public
       
   468   |
       
   469   | *  4:9411ad1fe615 added d
       
   470   | |   draft content-divergent
       
   471   | |
       
   472   o |  2:155349b645be added c
       
   473   |/    public
       
   474   |
       
   475   o  1:5f6d8a4bf34a added b
       
   476   |   public
       
   477   |
       
   478   o  0:9092f1db7931 added a
       
   479       public
       
   480   
       
   481   $ hg evolve --content-divergent --any
       
   482   merge:[5] added d
       
   483   with: [4] added d
       
   484   base: [3] added d
       
   485   rebasing "other" content-divergent changeset 9411ad1fe615 on 155349b645be
       
   486   merging d
       
   487   warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
       
   488   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
       
   489   fix conflicts and see `hg help evolve.interrupted`
       
   490   [1]
       
   491 
       
   492   $ echo d > d
       
   493   $ hg res -m
       
   494   (no more unresolved files)
       
   495   continue: hg evolve --continue
       
   496 
       
   497   $ hg evolve --continue
       
   498   committed as 2a0f44767904
       
   499   working directory is now at 93cd84bbdaca
       
   500 
       
   501   $ hg evolve -l
       
   502   $ cd ..
       
   503 
       
   504 Testing when relocation, merging both conflict:
       
   505 -----------------------------------------------
       
   506 
       
   507   $ hg init pubdiv6
       
   508   $ cd pubdiv6
       
   509   $ for ch in a b c d; do
       
   510   >   echo $ch > $ch;
       
   511   >   hg ci -Aqm "added "$ch;
       
   512   > done;
       
   513 
       
   514   $ hg up .^^
       
   515   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   516   $ echo cfoo > c
       
   517   $ echo e > e
       
   518   $ echo dconflict > d
       
   519   $ hg add c e d
       
   520   $ hg ci -m "added c e"
       
   521   created new head
       
   522 
       
   523   $ hg up 2
       
   524   1 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   525   $ echo dd > d
       
   526   $ hg add d
       
   527   $ hg ci -m "added d"
       
   528   created new head
       
   529 
       
   530   $ hg glog
       
   531   @  5:93cd84bbdaca added d
       
   532   |   draft
       
   533   |
       
   534   | o  4:3c17c7afaf6e added c e
       
   535   | |   draft
       
   536   | |
       
   537   +---o  3:9150fe93bec6 added d
       
   538   | |     draft
       
   539   | |
       
   540   o |  2:155349b645be added c
       
   541   |/    draft
       
   542   |
       
   543   o  1:5f6d8a4bf34a added b
       
   544   |   draft
       
   545   |
       
   546   o  0:9092f1db7931 added a
       
   547       draft
       
   548   
       
   549   $ hg prune 3 -s 5
       
   550   1 changesets pruned
       
   551   $ hg prune 3 -s 4 --hidden
       
   552   1 changesets pruned
       
   553   2 new content-divergent changesets
       
   554 
       
   555 Change phase to public for one head:
       
   556   $ hg phase --public -r 5
       
   557 
       
   558   $ hg glog
       
   559   @  5:93cd84bbdaca added d
       
   560   |   public
       
   561   |
       
   562   | *  4:3c17c7afaf6e added c e
       
   563   | |   draft content-divergent
       
   564   | |
       
   565   o |  2:155349b645be added c
       
   566   |/    public
       
   567   |
       
   568   o  1:5f6d8a4bf34a added b
       
   569   |   public
       
   570   |
       
   571   o  0:9092f1db7931 added a
       
   572       public
       
   573   
       
   574   $ hg evolve --content-divergent --any
       
   575   merge:[5] added d
       
   576   with: [4] added c e
       
   577   base: [3] added d
       
   578   rebasing "other" content-divergent changeset 3c17c7afaf6e on 155349b645be
       
   579   merging c
       
   580   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
       
   581   fix conflicts and see `hg help evolve.interrupted`
       
   582   [1]
       
   583 
       
   584   $ hg diff
       
   585   diff -r 155349b645be c
       
   586   --- a/c	Thu Jan 01 00:00:00 1970 +0000
       
   587   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
       
   588   @@ -1,1 +1,5 @@
       
   589   +<<<<<<< destination: 155349b645be - test: added c
       
   590    c
       
   591   +=======
       
   592   +cfoo
       
   593   +>>>>>>> evolving:    3c17c7afaf6e - test: added c e
       
   594   diff -r 155349b645be d
       
   595   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   596   +++ b/d	Thu Jan 01 00:00:00 1970 +0000
       
   597   @@ -0,0 +1,1 @@
       
   598   +dconflict
       
   599   diff -r 155349b645be e
       
   600   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   601   +++ b/e	Thu Jan 01 00:00:00 1970 +0000
       
   602   @@ -0,0 +1,1 @@
       
   603   +e
       
   604 
       
   605   $ echo cfoo > c
       
   606   $ hg res -m
       
   607   (no more unresolved files)
       
   608   continue: hg evolve --continue
       
   609 
       
   610   $ hg evolve --continue
       
   611   evolving 4:3c17c7afaf6e "added c e"
       
   612   merging d
       
   613   warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
       
   614   2 files updated, 0 files merged, 0 files removed, 1 files unresolved
       
   615   fix conflicts and see `hg help evolve.interrupted`
       
   616   [1]
       
   617 
       
   618   $ echo d > d
       
   619   $ hg res -m
       
   620   (no more unresolved files)
       
   621   continue: hg evolve --continue
       
   622 
       
   623   $ hg evolve --continue
       
   624   committed as b9082a9e66ce
       
   625   working directory is now at 93cd84bbdaca
       
   626 
       
   627   $ hg evolve -l
       
   628   $ cd ..