diff tests/test-rewind.t @ 5830:67fc03f42d92 mercurial-5.0

test-compat: merge mercurial-5.1 into mercurial-5.0 # no-check-commit
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 11 Mar 2021 14:22:45 +0800
parents c2c85576ddfb fd039a7f0c3c
children be8f7eb3f3a0
line wrap: on
line diff
--- a/tests/test-rewind.t	Sun Jan 31 15:39:25 2021 +0800
+++ b/tests/test-rewind.t	Thu Mar 11 14:22:45 2021 +0800
@@ -8,6 +8,7 @@
   > publish = false
   > [alias]
   > glf = log -GT "{rev}: {desc} ({files})"
+  > glhf = log -GT "{rev}:{node|short} {desc} ({files})"
   > [extensions]
   > evolve =
   > EOF
@@ -663,16 +664,13 @@
   rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
   $ hg rewind --to '9576e80d6851' --hidden --dry-run
   rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
-
-XXX this should also give us 2 changesets
-
   $ hg rewind --to 'a0316c4c5417' --hidden --dry-run
-  rewinding 4535d0af405c to 1 changesets: a0316c4c5417
+  rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
 
   $ hg rewind --to '9576e80d6851' --exact --hidden --dry-run
-  rewinding 4535d0af405c to 1 changesets: 9576e80d6851
+  rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
   $ hg rewind --to 'a0316c4c5417' --exact --hidden --dry-run
-  rewinding 4535d0af405c to 1 changesets: a0316c4c5417
+  rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
 
 actual rewind
 
@@ -866,6 +864,19 @@
      summary:     c_ROOT
   
 
+  $ hg rewind --hidden --to 'allpredecessors(desc("c_B0"))' --dry-run
+  abort: not rewinding, a65fceb2324a is a successor of 7e594302a05d
+  (pick only one of these changesets, possibly with --exact)
+  [255]
+  $ hg rewind --hidden --to 'allpredecessors(desc("c_B0"))' --dry-run --exact
+  abort: not rewinding, a65fceb2324a is a successor of 7e594302a05d
+  (pick only one of these changesets, possibly with --exact)
+  [255]
+  $ hg rewind --hidden --to 'allpredecessors(desc("c_B0"))' --dry-run --as-divergence
+  abort: not rewinding, a65fceb2324a is a successor of 7e594302a05d
+  (pick only one of these changesets, possibly with --exact)
+  [255]
+
 Testing the defaults
 --------------------
 
@@ -1195,3 +1206,436 @@
   $ hg rewind --keep --to 'desc("amended")' --hidden
   abort: uncommitted changes
   [255]
+
+  $ cd ..
+
+Extra cases related to folds
+============================
+
+folding with a changeset created after the rewind target
+--------------------------------------------------------
+
+..      B0 ⇠\
+..      |    ⇠ AB2
+.. A0 ⇠ A1 ⇠/
+
+this simple test case introduces the idea of making rewind consider different
+evolutions of fold components: "parent" evolution of A has more predecessors
+
+  $ hg init extra-fold-case-1
+  $ cd extra-fold-case-1
+
+  $ echo R > R
+  $ hg ci -qAm R
+  $ echo A > A
+  $ hg ci -qAm A0
+  $ hg amend -m A1
+  $ echo B > B
+  $ hg ci -qAm B0
+  $ hg fold -r 'desc("A1")::' -m AB2 --exact -q
+
+  $ hg glhf --hidden
+  @  4:7f9a5314ef94 AB2 (A B)
+  |
+  | x  3:16429ed4b6cb B0 (B)
+  | |
+  | x  2:3748b241cad8 A1 (A)
+  |/
+  | x  1:fa8956746c52 A0 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+target selection
+
+when rewinding from a fold, rewind to all of its components (at various points
+in their evolution) to not lose work
+
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: fa8956746c52 16429ed4b6cb
+  $ hg rewind --hidden --to 'desc("B0")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 16429ed4b6cb
+  $ hg rewind --from 'desc("AB2")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 16429ed4b6cb
+
+  $ hg rewind --hidden --to 'allpredecessors(desc("AB2"))' --dry-run
+  abort: not rewinding, 3748b241cad8 is a successor of fa8956746c52
+  (pick only one of these changesets, possibly with --exact)
+  [255]
+
+  $ cd ..
+
+folding with a changeset we rebased onto
+----------------------------------------
+
+.. A0 ⇠ A1 ⇠\
+..      |    ⇠ AB2
+..      B0 ⇠/
+
+similar to the previous case, but this time evolution of A has more
+predecessors and at some point starts to be based on B
+
+  $ hg init extra-fold-case-2
+  $ cd extra-fold-case-2
+
+  $ echo R > R
+  $ hg ci -qAm R
+  $ echo A > A
+  $ hg ci -qAm A0
+  $ hg up 'desc("R")' -q
+  $ echo B > B
+  $ hg ci -qAm B0
+  $ echo A > A
+  $ hg ci -qAm A1
+  $ hg prune -r 'desc("A0")' -s 'desc("A1")'
+  1 changesets pruned
+
+  $ hg fold -r 'desc("B0")::' -m AB2 --exact -q
+
+  $ hg glhf --hidden
+  @  4:1988e9fe9517 AB2 (A B)
+  |
+  | x  3:7175ff74409b A1 (A)
+  | |
+  | x  2:d6ed1d624918 B0 (B)
+  |/
+  | x  1:fa8956746c52 A0 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+target selection
+
+when rewinding from a fold, rewind to all of its components (at various points
+in their evolution) to not lose work
+
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 d6ed1d624918
+  $ hg rewind --hidden --to 'desc("B0")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: d6ed1d624918 7175ff74409b
+  $ hg rewind --from 'desc("AB2")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: d6ed1d624918 7175ff74409b
+
+  $ cd ..
+
+folding with a changeset that rebased on us
+-------------------------------------------
+
+.. B0 ⇠⇠⇠⇠ B1 ⇠\
+.. |       |    ⇠ AB2
+.. |  A0 ⇠ A1 ⇠/
+
+now evolutions of A and B have the same amount of changesets, but at point 0
+they aren't yet related
+
+  $ hg init extra-fold-case-3
+  $ cd extra-fold-case-3
+
+  $ echo R > R
+  $ hg ci -qAm R
+  $ echo A > A
+  $ hg ci -qAm A0
+  $ hg amend -m A1
+  $ hg up 'desc("R")' -q
+  $ echo B > B
+  $ hg ci -qAm B0
+  $ hg up 'desc("A1")' -q
+  $ echo B > B
+  $ hg ci -qAm B1
+  $ hg prune -r 'desc("B0")' -s 'desc("B1")'
+  1 changesets pruned
+
+  $ hg fold -r 'desc("A1")::' -m AB2 --exact -q
+
+  $ hg glhf --hidden
+  @  5:7f9a5314ef94 AB2 (A B)
+  |
+  | x  4:fe7a7d317e16 B1 (B)
+  | |
+  +---x  3:d6ed1d624918 B0 (B)
+  | |
+  | x  2:3748b241cad8 A1 (A)
+  |/
+  | x  1:fa8956746c52 A0 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+target selection
+
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: fa8956746c52 fe7a7d317e16
+  $ hg rewind --hidden --to 'desc("B0")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 d6ed1d624918
+  $ hg rewind --hidden --to 'desc("A1")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 fe7a7d317e16
+  $ hg rewind --hidden --to 'desc("B1")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 fe7a7d317e16
+  $ hg rewind --from 'desc("AB2")' --dry-run
+  rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 fe7a7d317e16
+
+actual rewind
+
+  $ hg rewind --hidden --to 'desc("A0")'
+  1 new orphan changesets
+  rewound to 2 changesets
+  (1 changesets obsoleted)
+  working directory is now at e492d2f9be46
+
+after rewind to A0:
+- A0' and B1' are successors to AB2 (split using rewind)
+- A0' is a successor of A0 (operation: rewind)
+- A0' is a child of R (just like A0)
+- B1' is a successor of B1 (operation: rewind)
+- B1' is a child of A1 (just like B1), and therefore an orphan
+
+  $ hg obslog -a
+  o    54b340ce1d87 (6) A0
+  |\     split(description, meta, parent, content) from 7f9a5314ef94 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
+  | |    meta-changed(meta) from fa8956746c52 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
+  | |
+  +---@  e492d2f9be46 (7) B1
+  | | |    split(description, meta, parent, content) from 7f9a5314ef94 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
+  | | |    meta-changed(meta) from fe7a7d317e16 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
+  | | |
+  x---+  7f9a5314ef94 (5) AB2
+  | | |    folded(description, parent, content) from 3748b241cad8, fe7a7d317e16 using fold by test (Thu Jan 01 00:00:06 1970 +0000)
+  | | |
+  x | |  3748b241cad8 (2) A1
+  |/ /     reworded(description) from fa8956746c52 using amend by test (Thu Jan 01 00:00:06 1970 +0000)
+  | |
+  | x  fe7a7d317e16 (4) B1
+  | |    rewritten(description, parent) from d6ed1d624918 using prune by test (Thu Jan 01 00:00:06 1970 +0000)
+  | |
+  | x  d6ed1d624918 (3) B0
+  |
+  x  fa8956746c52 (1) A0
+  
+  $ hg glhf
+  @  7:e492d2f9be46 B1 (B)
+  |
+  | o  6:54b340ce1d87 A0 (A)
+  | |
+  x |  2:3748b241cad8 A1 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+  $ hg debugobsolete --exclusive -r 'first(head())'
+  7f9a5314ef94f5856ee90661268194cc5ce9b332 54b340ce1d87f3593fd9de2a742e7b444e5136ed e492d2f9be46b73c0cfa51709e92db864b8f3ed9 0 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '15', 'operation': 'rewind', 'user': 'test'}
+  fa8956746c5294ce3351309133b450c5930f30f5 54b340ce1d87f3593fd9de2a742e7b444e5136ed 4 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '2', 'operation': 'rewind', 'user': 'test'}
+  $ hg debugobsolete --exclusive -r 'last(head())'
+  7f9a5314ef94f5856ee90661268194cc5ce9b332 54b340ce1d87f3593fd9de2a742e7b444e5136ed e492d2f9be46b73c0cfa51709e92db864b8f3ed9 0 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '15', 'operation': 'rewind', 'user': 'test'}
+  fe7a7d317e168a15e8aa43131b54d3256443d728 e492d2f9be46b73c0cfa51709e92db864b8f3ed9 4 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '2', 'operation': 'rewind', 'user': 'test'}
+
+  $ cd ..
+
+simple fold with a missing part
+-------------------------------
+
+.. B0 ⇠ (B1) ⇠\
+.. |     |     ⇠ AB2
+.. A0 ⇠  A1  ⇠/
+
+a stack was rewritten, but then a part of it became unknown locally
+
+  $ hg init extra-fold-case-4
+  $ cd extra-fold-case-4
+
+  $ echo R > R
+  $ hg ci -qAm R
+  $ echo A > A
+  $ hg ci -qAm A0
+  $ echo B > B
+  $ hg ci -qAm B0
+  $ hg up 'desc("R")' -q
+  $ echo A > A
+  $ hg ci -qAm A1
+  $ echo B > B
+  $ hg ci -qAm B1
+  $ hg prune -r 'desc("A0")+desc("B0")' -s 'desc("A1")+desc("B1")' --biject
+  2 changesets pruned
+
+  $ hg fold -r 'desc("A1") + desc("B1")' -m AB2 --exact -q
+
+  $ hg glhf --hidden
+  @  5:1988e9fe9517 AB2 (A B)
+  |
+  | x  4:25210d726f52 B1 (B)
+  | |
+  | x  3:9c76368ab336 A1 (A)
+  |/
+  | x  2:a07c12c45197 B0 (B)
+  | |
+  | x  1:fa8956746c52 A0 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+target selection
+
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 25210d726f52
+  $ hg rewind --hidden --to 'desc("A1")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: 9c76368ab336 25210d726f52
+  $ hg rewind --hidden --to 'desc("B1")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: 9c76368ab336 25210d726f52
+
+because B0 is a child of A0, we use A0 instead of A1 unless --exact is given
+
+XXX the semantic of --exact might need clarification here,
+XXX for example, shouln't --exact make sure we only rewind to the `--to` target ?
+
+  $ hg rewind --hidden --to 'desc("B0")' --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 a07c12c45197
+  $ hg rewind --hidden --to 'desc("B0")' --exact --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: a07c12c45197 9c76368ab336
+
+stripping one of the fold parts
+
+  $ hg strip --config extensions.strip= -r 'desc("B1")' --hidden -q
+
+  $ hg glhf --hidden
+  @  4:1988e9fe9517 AB2 (A B)
+  |
+  | x  3:9c76368ab336 A1 (A)
+  |/
+  | x  2:a07c12c45197 B0 (B)
+  | |
+  | x  1:fa8956746c52 A0 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+target selection
+
+the obvious challenge here is to somehow work around the missing fold
+component, but we can't do much because it is one of the latest predecessors of
+AB2 fold
+
+in future we might have a way to allow rewind to skip changesets unknown
+locally and still proceed (and lose the least amount of work possible)
+
+  $ hg rewind --hidden --to 'desc("A0")+desc("B0")' --exact --dry-run
+  rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 a07c12c45197
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 25210d726f52
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+  $ hg rewind --hidden --to 'desc("A1")' --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 25210d726f52
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+
+XXX the semantic of --exact might need clarification here,
+XXX for example, shouln't --exact make sure we only rewind to the `--to` target ?
+
+  $ hg rewind --hidden --to 'desc("A1")' --exact --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 25210d726f52
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+  $ hg rewind --from 'desc("AB2")' --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 25210d726f52
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+  $ hg rewind --from 'desc("AB2")' --exact --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 25210d726f52
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+
+  $ cd ..
+
+split and then fold with a missing part
+---------------------------------------
+
+..      /⇠ (C1) ⇠\
+.. BC0 ⇠    |     \
+..  |   \⇠  B1     ⇠ AC2
+..  A0 ⇠⇠⇠⇠⇠⇠⇠⇠⇠⇠⇠/
+
+here we have a case when walking successors and then predecessors of target
+revisions just once might not be enough, because it's a more complex DAG with a
+changeset missing from local repo
+
+  $ hg init extra-fold-case-5
+  $ cd extra-fold-case-5
+
+  $ echo R > R
+  $ hg ci -qAm R
+  $ echo A > A
+  $ hg ci -qAm A0
+  $ echo B > B
+  $ echo C > C
+  $ hg ci -qAm BC0
+  $ hg up 'desc("A0")' -q
+  $ echo B > B
+  $ hg ci -qAm B1
+  $ echo C > C
+  $ hg ci -qAm C1
+
+  $ hg prune -r 'desc("BC0")' -s 'desc("B1")+desc("C1")' --split
+  1 changesets pruned
+
+  $ hg up 'desc("R")' -q
+  $ echo A > A
+  $ echo C > C
+  $ hg ci -qAm AC2
+
+  $ hg prune -r 'desc("A0")+desc("C1")' -s 'desc("AC2")' --fold
+  2 changesets pruned
+  1 new orphan changesets
+
+  $ hg glhf --hidden
+  @  5:9ccaac2e5fbb AC2 (A C)
+  |
+  | x  4:2e4ab803d8ae C1 (C)
+  | |
+  | *  3:44774eafdc1c B1 (B)
+  | |
+  | | x  2:883d75400657 BC0 (B C)
+  | |/
+  | x  1:fa8956746c52 A0 (A)
+  |/
+  o  0:167e04d3d1b2 R (R)
+  
+
+target selection
+
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 2e4ab803d8ae
+  $ hg rewind --hidden --to 'desc("BC0")' --dry-run
+  rewinding 44774eafdc1c to 1 changesets: 883d75400657
+  rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 883d75400657
+  $ hg rewind --from 'desc("AC2")' --dry-run
+  rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 2e4ab803d8ae
+
+stripping a component of AC2 fold
+
+  $ hg strip --config extensions.strip= --hidden -r 'desc("C1")' -q
+  warning: ignoring unknown working parent 9ccaac2e5fbb!
+
+target selection
+
+at the moment, there's not much that we can do here because of missing C1
+
+in future we might have a way to allow rewind to skip changesets unknown
+locally and still proceed (and lose the least amount of work possible)
+
+XXX the semantic of --exact might need clarification here,
+XXX for example, shouln't --exact make sure we only rewind to the `--to` target ?
+
+  $ hg rewind --hidden --to 'desc("A0")' --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 2e4ab803d8ae
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+  $ hg rewind --hidden --to 'desc("BC0")' --dry-run
+  rewinding 44774eafdc1c to 1 changesets: 883d75400657
+  rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 883d75400657
+  $ hg rewind --from 'desc("AC2")' --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 2e4ab803d8ae
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]
+  $ hg rewind --from 'desc("AC2")' --exact --dry-run
+  abort: not rewinding, some predecessors are unknown locally: 2e4ab803d8ae
+  (try selecting all changesets to rewind to manually, possibly with --exact)
+  [255]