evolve: preserve date when resolving content-divergence (issue6202) stable
authorManuel Jacob <me@manueljacob.de>
Fri, 11 Oct 2019 21:32:27 +0200
branchstable
changeset 4998 88b816a9d990
parent 4997 e989d109ca9c
child 4999 a9457b9aca4e
evolve: preserve date when resolving content-divergence (issue6202) This patch changes the implementation to do a 3 way merge. In case of actual conflict, it take the newest date from both sides of the content-divergence.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-issue5958.t
tests/test-topic-stack-complex.t
--- a/hgext3rd/evolve/evolvecmd.py	Tue Dec 10 19:58:51 2019 +0100
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Oct 11 21:32:27 2019 +0200
@@ -653,7 +653,17 @@
 
         mergehook(repo, base, divergent, other)
 
-        newnode = repo.commit(text=desc, user=user)
+        date = divergent.date()
+        if other.date() != divergent.date():
+            basedate = base.date()
+            if other.date() == basedate:
+                date = divergent.date()
+            elif divergent.date() == basedate:
+                date = other.date()
+            else:
+                date = max(divergent.date(), other.date())
+
+        newnode = repo.commit(text=desc, user=user, date=date)
         if newnode == divergent.node() or newnode is None:
             # no changes
             new = divergent
--- a/tests/test-evolve-issue5958.t	Tue Dec 10 19:58:51 2019 +0100
+++ b/tests/test-evolve-issue5958.t	Fri Oct 11 21:32:27 2019 +0200
@@ -96,42 +96,41 @@
   base: [1] add foo.txt
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   1 new orphan changesets
-  working directory is now at 2372e6d39855
+  working directory is now at 459c64f7eaad
   $ hg log -r 'desc("add foo.txt")' -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  4 c17bf400a278 1969-12-31 23:59 -0000: rewritten using evolve as 7:2372e6d39855
-  7 2372e6d39855 1970-01-01 00:00 +0000: 
-  7 bb2424887202 1969-12-31 23:59 +0000: (false !)
+  4 c17bf400a278 1969-12-31 23:59 -0000: rewritten using evolve as 7:459c64f7eaad
+  7 459c64f7eaad 1969-12-31 23:59 -0000: 
 
 date: updated one one side to an older value
 
   $ hg evolve -r .
   move:[7] add foo.txt
   atop:[0] add r0
-  working directory is now at 2b9788beff53
+  working directory is now at 545776b4e79f
   $ hg update --hidden --rev 'predecessors(.)'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset 2372e6d39855
-  (hidden revision '2372e6d39855' was rewritten as: 2b9788beff53)
-  working directory parent is obsolete! (2372e6d39855)
-  (use 'hg evolve' to update to its successor: 2b9788beff53)
-  $ hg amend --date "0 2"
+  updated to hidden changeset 459c64f7eaad
+  (hidden revision '459c64f7eaad' was rewritten as: 545776b4e79f)
+  working directory parent is obsolete! (459c64f7eaad)
+  (use 'hg evolve' to update to its successor: 545776b4e79f)
+  $ hg amend --date "0 3"
   1 new orphan changesets
   2 new content-divergent changesets
   $ hg rebase -r . -d 0
-  rebasing 9:88085147662e "add foo.txt" (tip)
+  rebasing 9:c117f15338e6 "add foo.txt" (tip)
   $ hg log -G
-  @  changeset:   10:873d828420d8
+  @  changeset:   10:7a09c7a39546
   |  tag:         tip
   |  parent:      0:a24ed8ad918c
   |  user:        test
-  |  date:        Wed Dec 31 23:59:58 1969 -0000
+  |  date:        Wed Dec 31 23:59:57 1969 -0000
   |  instability: content-divergent
   |  summary:     add foo.txt
   |
-  | *  changeset:   8:2b9788beff53
+  | *  changeset:   8:545776b4e79f
   |/   parent:      0:a24ed8ad918c
   |    user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    date:        Wed Dec 31 23:59:58 1969 -0000
   |    instability: content-divergent
   |    summary:     add foo.txt
   |
@@ -141,35 +140,34 @@
      summary:     add r0
   
   $ hg evolve --list -r .
-  873d828420d8: add foo.txt
-    content-divergent: 2b9788beff53 (draft) (precursor 2372e6d39855)
+  7a09c7a39546: add foo.txt
+    content-divergent: 545776b4e79f (draft) (precursor 459c64f7eaad)
   
-  $ hg log -r 2372e6d39855+873d828420d8+2b9788beff53 --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  7 2372e6d39855 1970-01-01 00:00 +0000: date-changed using amend as 9:88085147662e; rebased using evolve as 8:2b9788beff53
-  10 873d828420d8 1969-12-31 23:59 -0000: 
-  8 2b9788beff53 1970-01-01 00:00 +0000: 
+  $ hg log -r 459c64f7eaad+7a09c7a39546+545776b4e79f --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
+  7 459c64f7eaad 1969-12-31 23:59 -0000: date-changed using amend as 9:c117f15338e6; rebased using evolve as 8:545776b4e79f
+  10 7a09c7a39546 1969-12-31 23:59 -0000: 
+  8 545776b4e79f 1969-12-31 23:59 -0000: 
   $ hg evolve --content-divergent
   merge:[8] add foo.txt
   with: [10] add foo.txt
   base: [7] add foo.txt
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at bb2424887202
+  working directory is now at 39c4200c0d94
   $ hg log -r . --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  11 bb2424887202 1970-01-01 00:00 +0000: 
-  11 bb2424887202 1969-12-31 23:59 +0000: (false !)
+  11 39c4200c0d94 1969-12-31 23:59 -0000: 
 
 date: updated one side to an newer value
 
   $ hg update --hidden --rev 'predecessors(.)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset 873d828420d8
-  (hidden revision '873d828420d8' was rewritten as: bb2424887202)
-  working directory parent is obsolete! (873d828420d8)
-  (use 'hg evolve' to update to its successor: bb2424887202)
+  updated to hidden changeset 7a09c7a39546
+  (hidden revision '7a09c7a39546' was rewritten as: 39c4200c0d94)
+  working directory parent is obsolete! (7a09c7a39546)
+  (use 'hg evolve' to update to its successor: 39c4200c0d94)
   $ hg amend --date "120 0"
   2 new content-divergent changesets
   $ hg log -G
-  @  changeset:   12:902e190ef559
+  @  changeset:   12:da3be3d72fe2
   |  tag:         tip
   |  parent:      0:a24ed8ad918c
   |  user:        test
@@ -177,10 +175,10 @@
   |  instability: content-divergent
   |  summary:     add foo.txt
   |
-  | *  changeset:   11:bb2424887202
+  | *  changeset:   11:39c4200c0d94
   |/   parent:      0:a24ed8ad918c
   |    user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    date:        Wed Dec 31 23:59:57 1969 -0000
   |    instability: content-divergent
   |    summary:     add foo.txt
   |
@@ -190,38 +188,37 @@
      summary:     add r0
   
   $ hg evolve --list -r .
-  902e190ef559: add foo.txt
-    content-divergent: bb2424887202 (draft) (precursor 873d828420d8)
+  da3be3d72fe2: add foo.txt
+    content-divergent: 39c4200c0d94 (draft) (precursor 7a09c7a39546)
   
-  $ hg up bb2424887202
+  $ hg up 39c4200c0d94
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg log -r 873d828420d8+bb2424887202+902e190ef559 --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  10 873d828420d8 1969-12-31 23:59 -0000: date-changed using evolve as 11:bb2424887202; date-changed using amend as 12:902e190ef559
-  11 bb2424887202 1970-01-01 00:00 +0000: 
-  12 902e190ef559 1970-01-01 00:02 +0000: 
+  $ hg log -r 7a09c7a39546+39c4200c0d94+da3be3d72fe2 --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
+  10 7a09c7a39546 1969-12-31 23:59 -0000: date-changed using amend as 12:da3be3d72fe2; rewritten using evolve as 11:39c4200c0d94
+  11 39c4200c0d94 1969-12-31 23:59 -0000: 
+  12 da3be3d72fe2 1970-01-01 00:02 +0000: 
   $ hg evolve --content-divergent
   merge:[11] add foo.txt
   with: [12] add foo.txt
   base: [10] add foo.txt
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  nothing changed
+  working directory is now at 06cde6010a51
   $ hg log -r . --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  11 bb2424887202 1970-01-01 00:00 +0000: 
-  13 bb2424887202 1970-01-01 00:02 +0000: (false !)
+  13 06cde6010a51 1970-01-01 00:02 +0000: 
 
 date: updated each side to a different value, newer should win
 
   $ hg amend --date "235 0"
   $ hg update --hidden --rev 'predecessors(.)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset bb2424887202
-  (hidden revision 'bb2424887202' was rewritten as: 48132e92d706)
-  working directory parent is obsolete! (bb2424887202)
-  (use 'hg evolve' to update to its successor: 48132e92d706)
+  updated to hidden changeset 06cde6010a51
+  (hidden revision '06cde6010a51' was rewritten as: a7412ff9bfb3)
+  working directory parent is obsolete! (06cde6010a51)
+  (use 'hg evolve' to update to its successor: a7412ff9bfb3)
   $ hg amend --date "784 0"
   2 new content-divergent changesets
   $ hg log -G
-  @  changeset:   14:694c3cf6b929
+  @  changeset:   15:e3077936ec52
   |  tag:         tip
   |  parent:      0:a24ed8ad918c
   |  user:        test
@@ -229,7 +226,7 @@
   |  instability: content-divergent
   |  summary:     add foo.txt
   |
-  | *  changeset:   13:48132e92d706
+  | *  changeset:   14:a7412ff9bfb3
   |/   parent:      0:a24ed8ad918c
   |    user:        test
   |    date:        Thu Jan 01 00:03:55 1970 +0000
@@ -242,19 +239,18 @@
      summary:     add r0
   
   $ hg evolve --list -r .
-  694c3cf6b929: add foo.txt
-    content-divergent: 48132e92d706 (draft) (precursor bb2424887202)
+  e3077936ec52: add foo.txt
+    content-divergent: a7412ff9bfb3 (draft) (precursor 06cde6010a51)
   
-  $ hg log -r bb2424887202+48132e92d706+694c3cf6b929 --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  11 bb2424887202 1970-01-01 00:00 +0000: date-changed using amend as 14:694c3cf6b929; date-changed using amend as 13:48132e92d706
-  13 48132e92d706 1970-01-01 00:03 +0000: 
-  14 694c3cf6b929 1970-01-01 00:13 +0000: 
+  $ hg log -r 39c4200c0d94+a7412ff9bfb3+e3077936ec52 --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
+  11 39c4200c0d94 1969-12-31 23:59 -0000: date-changed using evolve as 13:06cde6010a51
+  14 a7412ff9bfb3 1970-01-01 00:03 +0000: 
+  15 e3077936ec52 1970-01-01 00:13 +0000: 
   $ hg evolve --content-divergent
-  merge:[13] add foo.txt
-  with: [14] add foo.txt
-  base: [12] add foo.txt
+  merge:[14] add foo.txt
+  with: [15] add foo.txt
+  base: [13] add foo.txt
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at a24ed8ad918c
+  working directory is now at 1a39f3901288
   $ hg log -r . --hidden -T '{rev} {node|short} {date|isodate}: {join(obsfate, "; ")}\n'
-  0 a24ed8ad918c 1970-01-01 00:00 +0000: 
-  16 bb2424887202 1970-01-01 00:13 +0000: (false !)
+  16 1a39f3901288 1970-01-01 00:13 +0000: 
--- a/tests/test-topic-stack-complex.t	Tue Dec 10 19:58:51 2019 +0100
+++ b/tests/test-topic-stack-complex.t	Fri Oct 11 21:32:27 2019 +0200
@@ -176,4 +176,7 @@
   with: [s4] Added e and f
   base: [3] Added e and f
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 8faad6276dc6
+  working directory is now at 80b2ddbf01d3
+
+  $ hg log -r 80b2ddbf01d3 -T '{date|hgdate}\n'
+  0 1