diff tests/test-fix-topology.t @ 44574:5205b46bd887

fix: add a -s option to format a revision and its descendants `hg fix -r abc123` will format that commit but not its descendants. That seems expected given the option name (`-r`), but it's very rarely what the user wants to do. The problem is that any descendants of that commit will not be formatted, leaving them as orphans that are hard to evolve. They are hard to evolve because the new parent will have formatting changes that the orphan doesn't have. I talked to Danny Hooper (who wrote most of the fix extension) about the problem and we agreed that deprecating `-r` in favor of a new `-s` argument (mimicing rebase's `-s`) would be a good way of reducing the risk that users end up with these hard-to-evolve orphans. So that's what this patch implements. Differential Revision: https://phab.mercurial-scm.org/D8287
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 13 Mar 2020 12:16:00 -0700
parents 40f4a75938ba
children 04de8a1ec08f
line wrap: on
line diff
--- a/tests/test-fix-topology.t	Thu Dec 12 16:32:01 2019 -0800
+++ b/tests/test-fix-topology.t	Fri Mar 13 12:16:00 2020 -0700
@@ -21,6 +21,7 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > fix =
+  > strip =
   > [fix]
   > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
   > uppercase-whole-file:pattern=set:**
@@ -262,6 +263,111 @@
 
   $ cd ..
 
+
+Test the --source option. We only do this with obsstore on to avoid duplicating
+test code. We rely on the other tests to prove that obsolescence is not an
+important factor here.
+
+#if obsstore-on
+  $ hg init source-arg
+  $ cd source-arg
+  $ printf "aaaa\n" > a
+  $ hg commit -Am "change A"
+  adding a
+  $ printf "bbbb\n" > b
+  $ hg commit -Am "change B"
+  adding b
+  $ printf "cccc\n" > c
+  $ hg commit -Am "change C"
+  adding c
+  $ hg checkout 0
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ printf "dddd\n" > d
+  $ hg commit -Am "change D"
+  adding d
+  created new head
+  $ hg log --graph --template '{rev} {desc}\n'
+  @  3 change D
+  |
+  | o  2 change C
+  | |
+  | o  1 change B
+  |/
+  o  0 change A
+  
+
+Test passing 'wdir()' to --source
+  $ printf "xxxx\n" > x
+  $ hg add x
+  $ hg fix -s 'wdir()'
+  $ cat *
+  aaaa
+  dddd
+  XXXX
+
+Test passing '.' to --source
+  $ printf "xxxx\n" > x
+  $ hg fix -s .
+  $ hg log --graph --template '{rev} {desc}\n'
+  @  4 change D
+  |
+  | o  2 change C
+  | |
+  | o  1 change B
+  |/
+  o  0 change A
+  
+  $ cat *
+  aaaa
+  DDDD
+  XXXX
+  $ hg strip -qf 4
+  $ hg co -q 3
+
+Test passing other branch to --source
+  $ printf "xxxx\n" > x
+  $ hg add x
+  $ hg fix -s 2
+  $ hg log --graph --template '{rev} {desc}\n'
+  o  4 change C
+  |
+  | @  3 change D
+  | |
+  o |  1 change B
+  |/
+  o  0 change A
+  
+  $ hg cat -r 4 b c
+  bbbb
+  CCCC
+  $ cat *
+  aaaa
+  dddd
+  xxxx
+  $ hg strip -qf 4
+
+Test passing multiple revisions to --source
+  $ hg fix -s '2 + .'
+  $ hg log --graph --template '{rev} {desc}\n'
+  @  5 change D
+  |
+  | o  4 change C
+  | |
+  | o  1 change B
+  |/
+  o  0 change A
+  
+  $ hg cat -r 4 b c
+  bbbb
+  CCCC
+  $ cat *
+  aaaa
+  DDDD
+  XXXX
+
+  $ cd ..
+#endif
+
 The --all flag should fix anything that wouldn't cause a problem if you fixed
 it, including the working copy. Obsolete revisions are not fixed because that
 could cause divergence. Public revisions would cause an abort because they are