D1047: tweakdefaults: add restack command

quark (Jun Wu) phabricator at mercurial-scm.org
Fri Oct 13 03:23:58 EDT 2017


quark updated this revision to Diff 2665.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1047?vs=2654&id=2665

REVISION DETAIL
  https://phab.mercurial-scm.org/D1047

AFFECTED FILES
  mercurial/ui.py
  tests/test-tweakdefaults-restack.t

CHANGE DETAILS

diff --git a/tests/test-tweakdefaults-restack.t b/tests/test-tweakdefaults-restack.t
new file mode 100644
--- /dev/null
+++ b/tests/test-tweakdefaults-restack.t
@@ -0,0 +1,80 @@
+  $ cat >> $HGRCPATH<<EOF
+  > [ui]
+  > tweakdefaults=1
+  > [extensions]
+  > drawdag=$TESTDIR/drawdag.py
+  > [experimental]
+  > stabilization=createmarkers allowunstable
+  > EOF
+
+  $ hg init repo1
+  $ cd repo1
+  $ hg debugdrawdag <<'EOS'
+  >   H    I
+  >   |    |
+  >   G   E2   # rebase: E1 -> E2
+  >   |    |
+  >  E1    F   # prune: F
+  >   |    |
+  >   C    D
+  >   |    |
+  >  B1 B2 B3  # amend: B1 -> B2 -> B3
+  >   \ | /
+  >    \|/
+  >     A1  A2 # amend: A1 -> A2
+  >     |   |
+  >     X   Y
+  > EOS
+  $ hg restack
+  rebasing 6:799bf3a4122a "B3" (B3)
+  rebasing 8:288ec50c8e7e "D" (D)
+  rebasing 11:eccb0cc6c7e4 "E2" (E2)
+  rebasing 14:4d27b6814343 "I" (I tip)
+  rebasing 7:5c2d17df3d86 "C" (C)
+  rebasing 12:f2b51a466fe6 "G" (G)
+  rebasing 13:7aee36f22fb4 "H" (H)
+  $ hg log -G -T '{desc}' -r 'sort(all(), topo)'
+  o  H
+  |
+  o  G
+  |
+  o  C
+  |
+  o  I
+  |
+  o  E2
+  |
+  o  D
+  |
+  o  B3
+  |
+  o  A2
+  |
+  | x  I
+  | |
+  | x  E2
+  | |
+  | x  F
+  | |
+  | x  D
+  | |
+  | x  B3
+  | |
+  | | x  H
+  | | |
+  | | x  G
+  | | |
+  | | x  E1
+  | | |
+  | | x  C
+  | | |
+  | | x  B1
+  | |/
+  | | x  B2
+  | |/
+  | x  A1
+  | |
+  o |  Y
+   /
+  o  X
+  
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -50,6 +50,27 @@
 # The rollback command is dangerous. As a rule, don't use it.
 rollback = False
 
+[alias]
+# Move orphaned changesets to better places.
+# Destination revset explanation:
+# - max(roots(ALLSRC) & ::SRC)^
+#   The obsoleted changeset that the SRC stack is based on.
+# - successors(...)-obsolete()
+#   A non-obsoleted successor. Or an empty set (no successor).
+# - max(...::)
+#   Get the top of the stack, so history is more linear.
+#   This is the rebase destination for SRC when there is a successor.
+# - max(::((roots(ALLSRC) & ::SRC)^)-obsolete())
+#   The first non-obsoleted changeset before the obsoleted changeset that the
+#   SRC stack is based on.
+#   This is the rebase destination for SRC when there is no successor.
+# - first(A+B)
+#   Pick B if A is empty.
+restack = rebase
+ -r 'orphan()-obsolete()'
+ -d 'first(max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::)+
+           max(::((roots(ALLSRC) & ::SRC)^)-obsolete()))'
+
 [commands]
 # Make `hg status` emit cwd-relative paths by default.
 status.relative = yes
@@ -60,6 +81,9 @@
 
 [diff]
 git = 1
+
+[experimental]
+rebase.multidest = 1
 """
 
 samplehgrcs = {



To: quark, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list