rdamazio updated this revision to Diff 19812. REPOSITORY rHG Mercurial
CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7630?vs=19049&id=19812 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7630/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7630 AFFECTED FILES hgext/absorb.py tests/test-absorb-rev.t CHANGE DETAILS diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t --- a/tests/test-absorb-rev.t +++ b/tests/test-absorb-rev.t @@ -86,11 +86,10 @@ Run absorb: $ hg absorb --apply-changes -s . - 1 new orphan changesets 2 of 2 chunk(s) applied -Note: this only shows disconnected graphs because the root node was also -absorbed into. $ hg glog + @ 9a0ec5cae1a1 commit to absorb + | o 2f7ba78d6abc commit 5 | o 04c8ba6df782 commit 4 @@ -101,18 +100,6 @@ | o 241ace8326d0 commit 1 - @ 1631091f9648 commit to absorb orphan - | - x 4f55fa657dae commit 5 - | - x ad8b8b75557f commit 4 - | - x 43f0a75bede7 commit 3 - | - x 5c5f95224a50 commit 2 - | - x 4ec16f85269a commit 1 - Check that the pending wdir change was left alone: @@ -127,34 +114,21 @@ 4d 5e +6 - $ hg update -Cq . - -Rebase the absorbed revision on top of the destination (as evolve would): -TODO: the evolve-type operation should happen automatically for the changeset -being absorbed, and even through that the pending wdir change should be left -alone. - - $ hg rebase -d tip -r . - rebasing 5:1631091f9648 "commit to absorb" - note: not rebasing 5:1631091f9648 "commit to absorb", its destination already has all its changes - $ hg glog - @ 2f7ba78d6abc commit 5 - | - o 04c8ba6df782 commit 4 - | - o 484c6ac0cea3 commit 3 - | - o 9b19176bb127 commit 2 - | - o 241ace8326d0 commit 1 - - $ hg annotate -c a - 241ace8326d0: 1a - 9b19176bb127: 2b - 484c6ac0cea3: 3 - 04c8ba6df782: 4d - 2f7ba78d6abc: 5e + $ hg annotate -c a -r 'wdir()' + 241ace8326d0 : 1a + 9b19176bb127 : 2b + 484c6ac0cea3 : 3 + 04c8ba6df782 : 4d + 2f7ba78d6abc : 5e + 9a0ec5cae1a1+: 6 + +TODO: The absorbed commit should have disappeared when it became empty. + $ hg diff -c . + $ hg debugobsolete $(hg log -T "{node}\n" -r .) + 1 new obsolescence markers + obsoleted 1 changesets + $ hg update -Cq '.^' Do it again, but this time with an unrelated commit checked out (plus working directory changes on top): @@ -200,22 +174,17 @@ 2 changesets affected 2f7ba78 commit 5 04c8ba6 commit 4 - 1 new orphan changesets 1 of 1 chunk(s) applied $ hg glog + o da8aed1fcb63 commit to absorb 2 + | o 789b01face13 commit 5 | o 9c83c60f49f2 commit 4 | | @ dbce69d9fe03 unrelated commit | | - | | * 410fcc72c5c9 commit to absorb 2 orphan - | | | - | | x 2f7ba78d6abc commit 5 - | | | - +---x 04c8ba6df782 commit 4 - | | o | 484c6ac0cea3 commit 3 | | o | 9b19176bb127 commit 2 @@ -228,18 +197,16 @@ dbce69d9fe03 : committed unrelated dbce69d9fe03+: pending wdir change - $ hg update -Cq . - - $ hg rebase -d tip -r ${TOABSORB} - rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re) - note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination already has all its changes (re) + $ hg update -Cq tip $ hg glog + o da8aed1fcb63 commit to absorb 2 + | o 789b01face13 commit 5 | o 9c83c60f49f2 commit 4 | - | @ dbce69d9fe03 unrelated commit + | o dbce69d9fe03 unrelated commit | | o | 484c6ac0cea3 commit 3 | | @@ -248,7 +215,7 @@ o 241ace8326d0 commit 1 - $ hg annotate -c a -r tip + $ hg annotate -c a 241ace8326d0: 1a 9b19176bb127: 2b 484c6ac0cea3: 3 diff --git a/hgext/absorb.py b/hgext/absorb.py --- a/hgext/absorb.py +++ b/hgext/absorb.py @@ -34,6 +34,7 @@ from __future__ import absolute_import import collections +import itertools from mercurial.i18n import _ from mercurial import ( @@ -662,16 +663,19 @@ 4. call commit, to commit changes to hg database """ - def __init__(self, stack, ui=None, opts=None): + def __init__(self, stack, fixuptargets=[], ui=None, opts=None): """([ctx], ui or None) -> None stack: should be linear, and sorted by topo order - oldest first. + fixuptargets: changeset contexts that need to be fixed up, but are not + used for fixup computation. all commits in stack are considered mutable. """ assert stack self.ui = ui or nullui() self.opts = opts or {} self.stack = stack + self.fixuptargets = fixuptargets self.repo = stack[-1].repo().unfiltered() # following fields will be filled later @@ -777,7 +781,7 @@ # p1 which overrides the parent of the next commit, "None" means use # the original parent unchanged nextp1 = None - for ctx in self.stack: + for ctx in itertools.chain(self.stack, self.fixuptargets): memworkingcopy = self._getnewfilecontents(ctx) if not memworkingcopy and not lastcommitted: # nothing changed, nothing commited @@ -1011,7 +1015,10 @@ pats = () if opts is None: opts = {} - state = fixupstate(stack, ui=ui, opts=opts) + fixuptargets = [] + if targetctx.rev() is not None: + fixuptargets.append(targetctx) + state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts) matcher = scmutil.match(targetctx, pats, opts) if opts.get(b'interactive'): diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher) To: rdamazio, #hg-reviewers Cc: marmoute, pulkit, martinvonz, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel