--- a/hgext/rebase.py Wed Jun 28 17:41:25 2017 +0200
+++ b/hgext/rebase.py Thu Jun 29 15:21:52 2017 -0700
@@ -343,7 +343,7 @@
if dest.closesbranch() and not self.keepbranchesf:
self.ui.status(_('reopening closed branch head %s\n') % dest)
- def _performrebase(self, tr):
+ def _performrebase(self):
repo, ui, opts = self.repo, self.ui, self.opts
if self.keepbranchesf:
# insert _savebranch at the start of extrafns so if
@@ -395,7 +395,7 @@
self.state,
self.destancestors,
self.obsoletenotrebased)
- self.storestatus(tr=tr)
+ self.storestatus()
storecollapsemsg(repo, self.collapsemsg)
if len(repo[None].parents()) == 2:
repo.ui.debug('resuming interrupted rebase\n')
@@ -480,24 +480,12 @@
editopt = True
editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
revtoreuse = max(self.state)
- dsguard = dirstateguard.dirstateguard(repo, 'rebase')
- try:
- newnode = concludenode(repo, revtoreuse, p1, self.external,
- commitmsg=commitmsg,
- extrafn=_makeextrafn(self.extrafns),
- editor=editor,
- keepbranches=self.keepbranchesf,
- date=self.date)
- dsguard.close()
- release(dsguard)
- except error.InterventionRequired:
- dsguard.close()
- release(dsguard)
- raise
- except Exception:
- release(dsguard)
- raise
-
+ newnode = concludenode(repo, revtoreuse, p1, self.external,
+ commitmsg=commitmsg,
+ extrafn=_makeextrafn(self.extrafns),
+ editor=editor,
+ keepbranches=self.keepbranchesf,
+ date=self.date)
if newnode is None:
newrev = self.dest
else:
@@ -734,20 +722,7 @@
if retcode is not None:
return retcode
- with repo.transaction('rebase') as tr:
- dsguard = dirstateguard.dirstateguard(repo, 'rebase')
- try:
- rbsrt._performrebase(tr)
- dsguard.close()
- release(dsguard)
- except error.InterventionRequired:
- dsguard.close()
- release(dsguard)
- tr.close()
- raise
- except Exception:
- release(dsguard)
- raise
+ rbsrt._performrebase()
rbsrt._finishrebase()
def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=None,
@@ -873,28 +848,33 @@
'''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
but also store useful information in extra.
Return node of committed revision.'''
- repo.setparents(repo[p1].node(), repo[p2].node())
- ctx = repo[rev]
- if commitmsg is None:
- commitmsg = ctx.description()
- keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
- extra = {'rebase_source': ctx.hex()}
- if extrafn:
- extrafn(ctx, extra)
+ dsguard = dirstateguard.dirstateguard(repo, 'rebase')
+ try:
+ repo.setparents(repo[p1].node(), repo[p2].node())
+ ctx = repo[rev]
+ if commitmsg is None:
+ commitmsg = ctx.description()
+ keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
+ extra = {'rebase_source': ctx.hex()}
+ if extrafn:
+ extrafn(ctx, extra)
- destphase = max(ctx.phase(), phases.draft)
- overrides = {('phases', 'new-commit'): destphase}
- with repo.ui.configoverride(overrides, 'rebase'):
- if keepbranch:
- repo.ui.setconfig('ui', 'allowemptycommit', True)
- # Commit might fail if unresolved files exist
- if date is None:
- date = ctx.date()
- newnode = repo.commit(text=commitmsg, user=ctx.user(),
- date=date, extra=extra, editor=editor)
+ destphase = max(ctx.phase(), phases.draft)
+ overrides = {('phases', 'new-commit'): destphase}
+ with repo.ui.configoverride(overrides, 'rebase'):
+ if keepbranch:
+ repo.ui.setconfig('ui', 'allowemptycommit', True)
+ # Commit might fail if unresolved files exist
+ if date is None:
+ date = ctx.date()
+ newnode = repo.commit(text=commitmsg, user=ctx.user(),
+ date=date, extra=extra, editor=editor)
- repo.dirstate.setbranch(repo[newnode].branch())
- return newnode
+ repo.dirstate.setbranch(repo[newnode].branch())
+ dsguard.close()
+ return newnode
+ finally:
+ release(dsguard)
def rebasenode(repo, rev, p1, base, state, collapse, dest):
'Rebase a single revision rev on top of p1 using base as merge ancestor'
--- a/tests/test-dirstate-race.t Wed Jun 28 17:41:25 2017 +0200
+++ b/tests/test-dirstate-race.t Thu Jun 29 15:21:52 2017 -0700
@@ -220,11 +220,13 @@
> test.args=$TESTTMP/mergetool-race.sh \$output
> EOF
+BROKEN: the "M b" line should not be there
$ hg rebase -s . -d 3 --tool test
rebasing 4:b08445fd6b2a "c4" (tip)
merging a
custom merge tool
M a
+ M b
? a.orig
custom merge tool end
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
--- a/tests/test-rebase-abort.t Wed Jun 28 17:41:25 2017 +0200
+++ b/tests/test-rebase-abort.t Thu Jun 29 15:21:52 2017 -0700
@@ -374,11 +374,10 @@
$ hg --config extensions.n=$TESTDIR/failfilemerge.py rebase -s 3 -d tip
rebasing 3:3a71550954f1 "b"
rebasing 4:e80b69427d80 "c"
- transaction abort!
- rollback completed
abort: ^C
[255]
$ hg rebase --abort
+ saved backup bundle to $TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg (glob)
rebase aborted
$ hg log -G --template "{rev} {desc} {bookmarks}"
o 6 no-a
@@ -399,7 +398,7 @@
parent: 0:df4f53cec30a
base
branch: default
- commit: 1 unknown (clean)
+ commit: (clean)
update: 6 new changesets (update)
phases: 7 draft
--- a/tests/test-rebase-collapse.t Wed Jun 28 17:41:25 2017 +0200
+++ b/tests/test-rebase-collapse.t Thu Jun 29 15:21:52 2017 -0700
@@ -572,8 +572,6 @@
o 0: 'A'
$ hg rebase --keepbranches --collapse -s 1 -d 3
- transaction abort!
- rollback completed
abort: cannot collapse multiple named branches
[255]
--- a/tests/test-rebase-conflicts.t Wed Jun 28 17:41:25 2017 +0200
+++ b/tests/test-rebase-conflicts.t Thu Jun 29 15:21:52 2017 -0700
@@ -226,6 +226,7 @@
ignoring null merge rebase of 8
rebasing 9:e31216eec445 "more changes to f1"
future parents are 2 and -1
+ rebase status stored
update to 2:4bc80088dc6b
resolving manifests
branchmerge: False, force: True, partial: False
@@ -248,9 +249,11 @@
f1.txt
committing manifest
committing changelog
+ updating the branch cache
rebased as 19c888675e13
rebasing 10:2f2496ddf49d "merge" (tip)
future parents are 11 and 7
+ rebase status stored
already in destination
merge against 10:2f2496ddf49d
detach base 9:e31216eec445
@@ -266,10 +269,9 @@
f1.txt
committing manifest
committing changelog
+ updating the branch cache
rebased as 2a7f09cac94c
rebase merging completed
- rebase status stored
- updating the branch cache
update back to initial working directory parent
resolving manifests
branchmerge: False, force: False, partial: False
--- a/tests/test-rebase-interruptions.t Wed Jun 28 17:41:25 2017 +0200
+++ b/tests/test-rebase-interruptions.t Thu Jun 29 15:21:52 2017 -0700
@@ -271,6 +271,162 @@
|/
o 0:public 'A'
+Test rebase interrupted by hooks
+
+ $ hg up 2
+ 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ echo F > F
+ $ hg add F
+ $ hg ci -m F
+
+ $ cd ..
+
+(precommit version)
+
+ $ cp -R a3 hook-precommit
+ $ cd hook-precommit
+ $ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.precommit=hg status | grep "M A"'
+ rebasing 2:965c486023db "C"
+ M A
+ rebasing 6:a0b2430ebfb8 "F" (tip)
+ abort: precommit hook exited with status 1
+ [255]
+ $ hg tglogp
+ @ 7:secret 'C'
+ |
+ | @ 6:secret 'F'
+ | |
+ o | 5:public 'B'
+ | |
+ o | 4:public 'E'
+ | |
+ o | 3:public 'D'
+ | |
+ | o 2:secret 'C'
+ | |
+ | o 1:public 'B'
+ |/
+ o 0:public 'A'
+
+ $ hg rebase --continue
+ already rebased 2:965c486023db "C" as 401ccec5e39f
+ rebasing 6:a0b2430ebfb8 "F"
+ saved backup bundle to $TESTTMP/hook-precommit/.hg/strip-backup/965c486023db-aa6250e7-backup.hg (glob)
+ $ hg tglogp
+ @ 6:secret 'F'
+ |
+ o 5:secret 'C'
+ |
+ o 4:public 'B'
+ |
+ o 3:public 'E'
+ |
+ o 2:public 'D'
+ |
+ | o 1:public 'B'
+ |/
+ o 0:public 'A'
+
+ $ cd ..
+
+(pretxncommit version)
+
+ $ cp -R a3 hook-pretxncommit
+ $ cd hook-pretxncommit
+ $ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.pretxncommit=hg log -r $HG_NODE | grep "summary: C"'
+ rebasing 2:965c486023db "C"
+ summary: C
+ rebasing 6:a0b2430ebfb8 "F" (tip)
+ transaction abort!
+ rollback completed
+ abort: pretxncommit hook exited with status 1
+ [255]
+ $ hg tglogp
+ @ 7:secret 'C'
+ |
+ | @ 6:secret 'F'
+ | |
+ o | 5:public 'B'
+ | |
+ o | 4:public 'E'
+ | |
+ o | 3:public 'D'
+ | |
+ | o 2:secret 'C'
+ | |
+ | o 1:public 'B'
+ |/
+ o 0:public 'A'
+
+ $ hg rebase --continue
+ already rebased 2:965c486023db "C" as 401ccec5e39f
+ rebasing 6:a0b2430ebfb8 "F"
+ saved backup bundle to $TESTTMP/hook-pretxncommit/.hg/strip-backup/965c486023db-aa6250e7-backup.hg (glob)
+ $ hg tglogp
+ @ 6:secret 'F'
+ |
+ o 5:secret 'C'
+ |
+ o 4:public 'B'
+ |
+ o 3:public 'E'
+ |
+ o 2:public 'D'
+ |
+ | o 1:public 'B'
+ |/
+ o 0:public 'A'
+
+ $ cd ..
+
+(pretxnclose version)
+
+ $ cp -R a3 hook-pretxnclose
+ $ cd hook-pretxnclose
+ $ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.pretxnclose=hg log -r tip | grep "summary: C"'
+ rebasing 2:965c486023db "C"
+ summary: C
+ rebasing 6:a0b2430ebfb8 "F" (tip)
+ transaction abort!
+ rollback completed
+ abort: pretxnclose hook exited with status 1
+ [255]
+ $ hg tglogp
+ @ 7:secret 'C'
+ |
+ | @ 6:secret 'F'
+ | |
+ o | 5:public 'B'
+ | |
+ o | 4:public 'E'
+ | |
+ o | 3:public 'D'
+ | |
+ | o 2:secret 'C'
+ | |
+ | o 1:public 'B'
+ |/
+ o 0:public 'A'
+
+ $ hg rebase --continue
+ already rebased 2:965c486023db "C" as 401ccec5e39f
+ rebasing 6:a0b2430ebfb8 "F"
+ saved backup bundle to $TESTTMP/hook-pretxnclose/.hg/strip-backup/965c486023db-aa6250e7-backup.hg (glob)
+ $ hg tglogp
+ @ 6:secret 'F'
+ |
+ o 5:secret 'C'
+ |
+ o 4:public 'B'
+ |
+ o 3:public 'E'
+ |
+ o 2:public 'D'
+ |
+ | o 1:public 'B'
+ |/
+ o 0:public 'A'
+
$ cd ..
Make sure merge state is cleaned up after a no-op rebase merge (issue5494)
@@ -302,4 +458,3 @@
$ hg resolve --list
$ test -f .hg/merge
[1]
-
--- a/tests/test-rebase-scenario-global.t Wed Jun 28 17:41:25 2017 +0200
+++ b/tests/test-rebase-scenario-global.t Thu Jun 29 15:21:52 2017 -0700
@@ -271,8 +271,6 @@
$ hg rebase -s 6 -d 1
rebasing 6:eea13746799a "G"
- transaction abort!
- rollback completed
abort: cannot use revision 6 as base, result would have 3 parents
[255]
$ hg rebase --abort