evolve: compat patch for recordfilter change in mercurial
authorSushil khanchi <sushilkhanchi97@gmail.com>
Wed, 10 Apr 2019 23:19:29 +0530
changeset 4499 90f94231db5d
parent 4498 99dbe605fda5
child 4500 cfcb7eedc666
child 4502 84512556e148
evolve: compat patch for recordfilter change in mercurial This patch fix the broken things because of upstream changes in recordfilter() which is being used to select the hunks interactively. It fixes the test-uncommit-interactive.t by adding the compat layer. But for test-split.t I had to fix the tests manually. To make it more clear: splitting broke at evolve side because after that upstream change now interactive mode doesn't prompt "examine change to foo" if foo is mentioned explicitly using cli; and directly jumps to hunks selection prompt (well, only if there is any changes at hunks level) And the main issue is when file which is explicitly mentioned has no changes at hunk level (for e.g copy, rename, mode change, empty new file), because in that case you don't have any control on selection of that file and it would be included automatically in first cycle of interactive selection. And this "no changes at hunks level" was the reason for test-split.t breakage as now it didn't prompt for those files which are passed on cli. To fix this I have included some content in those files to make sure that tests still demonstrate the same behaviour as they were doing before breakage. Also, I replaced some "n" with "s" as it make more sense to skip all the changes to that file in one go instead of hitting "n" multiple times (if there were multiple hunks)
hgext3rd/evolve/cmdrewrite.py
tests/test-split.t
tests/test-uncommit-interactive.t
--- a/hgext3rd/evolve/cmdrewrite.py	Wed Apr 10 21:03:56 2019 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Wed Apr 10 23:19:29 2019 +0530
@@ -605,8 +605,13 @@
     # uncommit a removed file partially.
     # TODO: wrap the operations in mercurial/patch.py and mercurial/crecord.py
     # to add uncommit as an operation taking care of BC.
-    chunks, opts = cmdutil.recordfilter(repo.ui, originalchunks,
-                                        operation='discard')
+    try:
+        chunks, opts = cmdutil.recordfilter(repo.ui, originalchunks, match,
+                                            operation='discard')
+    except TypeError:
+        # hg <= 4.9 (db72f9f6580e)
+        chunks, opts = cmdutil.recordfilter(repo.ui, originalchunks,
+                                            operation='discard')
     if not chunks:
         raise error.Abort(_("nothing selected to uncommit"))
     fp = stringio()
--- a/tests/test-split.t	Wed Apr 10 21:03:56 2019 +0200
+++ b/tests/test-split.t	Wed Apr 10 23:19:29 2019 +0530
@@ -779,9 +779,18 @@
 
 (remaining changes gathered with unmatched one)
 
+adding content in files to make sure that it prompt us to select the changes,
+as it won't prompt if a file has no changes at hunk level and passed in cli
+(for more look into hg db72f9f6580e which made it to not prompt "examine changes to fileX"
+for files which are explicitly mentioned by user)
+  $ echo sp2 > SPLIT2
+  $ echo sp3 > SPLIT3
+  $ echo sp4 > SPLIT4
+  $ hg amend
+
   $ hg split SPLIT2 SPLIT3 << EOF
   > y
-  > n
+  > s
   > c
   > EOF
   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
@@ -790,13 +799,18 @@
   adding SPLIT4
   diff --git a/SPLIT2 b/SPLIT2
   new file mode 100644
-  examine changes to 'SPLIT2'? [Ynesfdaq?] y
+  @@ -0,0 +1,1 @@
+  +sp2
+  record change 1/2 to 'SPLIT2'? [Ynesfdaq?] y
   
   diff --git a/SPLIT3 b/SPLIT3
   new file mode 100644
-  examine changes to 'SPLIT3'? [Ynesfdaq?] n
+  @@ -0,0 +1,1 @@
+  +sp3
+  record change 2/2 to 'SPLIT3'? [Ynesfdaq?] s
   
   continue splitting? [Ycdq?] c
+
   $ hg status --change '.~1'
   A SPLIT2
   $ hg status --change '.'
@@ -810,7 +824,7 @@
 
   $ hg split SPLIT2 SPLIT3 << EOF
   > y
-  > n
+  > s
   > y
   > y
   > EOF
@@ -820,18 +834,25 @@
   adding SPLIT4
   diff --git a/SPLIT2 b/SPLIT2
   new file mode 100644
-  examine changes to 'SPLIT2'? [Ynesfdaq?] y
+  @@ -0,0 +1,1 @@
+  +sp2
+  record change 1/2 to 'SPLIT2'? [Ynesfdaq?] y
   
   diff --git a/SPLIT3 b/SPLIT3
   new file mode 100644
-  examine changes to 'SPLIT3'? [Ynesfdaq?] n
+  @@ -0,0 +1,1 @@
+  +sp3
+  record change 2/2 to 'SPLIT3'? [Ynesfdaq?] s
   
   continue splitting? [Ycdq?] y
   diff --git a/SPLIT3 b/SPLIT3
   new file mode 100644
-  examine changes to 'SPLIT3'? [Ynesfdaq?] y
+  @@ -0,0 +1,1 @@
+  +sp3
+  record this change to 'SPLIT3'? [Ynesfdaq?] y
   
   no more change to split
+
   $ hg status --change '.~2'
   A SPLIT2
   $ hg status --change '.~1'
@@ -854,11 +875,15 @@
   adding SPLIT4
   diff --git a/SPLIT2 b/SPLIT2
   new file mode 100644
-  examine changes to 'SPLIT2'? [Ynesfdaq?] y
+  @@ -0,0 +1,1 @@
+  +sp2
+  record change 1/2 to 'SPLIT2'? [Ynesfdaq?] y
   
   diff --git a/SPLIT3 b/SPLIT3
   new file mode 100644
-  examine changes to 'SPLIT3'? [Ynesfdaq?] y
+  @@ -0,0 +1,1 @@
+  +sp3
+  record change 2/2 to 'SPLIT3'? [Ynesfdaq?] y
   
   no more change to split
   $ hg status --change '.~1'
@@ -874,7 +899,7 @@
 
   $ hg split SPLIT2 SPLIT3 << EOF
   > y
-  > n
+  > s
   > d
   > EOF
   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
@@ -883,11 +908,15 @@
   adding SPLIT4
   diff --git a/SPLIT2 b/SPLIT2
   new file mode 100644
-  examine changes to 'SPLIT2'? [Ynesfdaq?] y
+  @@ -0,0 +1,1 @@
+  +sp2
+  record change 1/2 to 'SPLIT2'? [Ynesfdaq?] y
   
   diff --git a/SPLIT3 b/SPLIT3
   new file mode 100644
-  examine changes to 'SPLIT3'? [Ynesfdaq?] n
+  @@ -0,0 +1,1 @@
+  +sp3
+  record change 2/2 to 'SPLIT3'? [Ynesfdaq?] s
   
   continue splitting? [Ycdq?] d
   discarding remaining changes
--- a/tests/test-uncommit-interactive.t	Wed Apr 10 21:03:56 2019 +0200
+++ b/tests/test-uncommit-interactive.t	Wed Apr 10 23:19:29 2019 +0530
@@ -780,12 +780,9 @@
 
   $ hg uncommit -i a << DONE
   > y
-  > y
   > DONE
   diff --git a/a b/a
   1 hunks, 1 lines changed
-  examine changes to 'a'? [Ynesfdaq?] y
-  
   @@ -9,3 +9,4 @@
    4
    5
@@ -846,13 +843,10 @@
 
   $ hg uncommit -i a << DONE
   > y
-  > y
   > n
   > DONE
   diff --git a/a b/a
   2 hunks, 2 lines changed
-  examine changes to 'a'? [Ynesfdaq?] y
-  
   @@ -1,3 +1,4 @@
   +-3
    -2