diff tests/test-rewind.t @ 5802:84efc2e92228

rewind: abort if some parts of a fold are unknown locally
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 22 Dec 2020 19:07:46 +0800
parents e8a43f5929f6
children abbc021c6f68
line wrap: on
line diff
--- a/tests/test-rewind.t	Tue Dec 22 19:06:36 2020 +0800
+++ b/tests/test-rewind.t	Tue Dec 22 19:07:46 2020 +0800
@@ -1517,8 +1517,123 @@
 
   $ 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: unknown revision '25210d726f527e03f1f148bb8048d571512146d9'
+  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]