Show More
@@ -479,12 +479,17 b' class rebaseruntime(object):' | |||||
479 | editopt = True |
|
479 | editopt = True | |
480 | editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
|
480 | editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) | |
481 | revtoreuse = max(self.state) |
|
481 | revtoreuse = max(self.state) | |
482 | newnode = concludenode(repo, revtoreuse, p1, self.external, |
|
482 | ||
483 | commitmsg=commitmsg, |
|
483 | dsguard = None | |
484 | extrafn=_makeextrafn(self.extrafns), |
|
484 | if ui.configbool('rebase', 'singletransaction'): | |
485 | editor=editor, |
|
485 | dsguard = dirstateguard.dirstateguard(repo, 'rebase') | |
486 | keepbranches=self.keepbranchesf, |
|
486 | with util.acceptintervention(dsguard): | |
487 | date=self.date) |
|
487 | newnode = concludenode(repo, revtoreuse, p1, self.external, | |
|
488 | commitmsg=commitmsg, | |||
|
489 | extrafn=_makeextrafn(self.extrafns), | |||
|
490 | editor=editor, | |||
|
491 | keepbranches=self.keepbranchesf, | |||
|
492 | date=self.date) | |||
488 | if newnode is None: |
|
493 | if newnode is None: | |
489 | newrev = self.dest |
|
494 | newrev = self.dest | |
490 | else: |
|
495 | else: | |
@@ -711,10 +716,16 b' def rebase(ui, repo, **opts):' | |||||
711 | return retcode |
|
716 | return retcode | |
712 |
|
717 | |||
713 | tr = None |
|
718 | tr = None | |
714 | if ui.configbool('rebase', 'singletransaction'): |
|
719 | dsguard = None | |
|
720 | ||||
|
721 | singletr = ui.configbool('rebase', 'singletransaction') | |||
|
722 | if singletr: | |||
715 | tr = repo.transaction('rebase') |
|
723 | tr = repo.transaction('rebase') | |
716 | with util.acceptintervention(tr): |
|
724 | with util.acceptintervention(tr): | |
717 | rbsrt._performrebase(tr) |
|
725 | if singletr: | |
|
726 | dsguard = dirstateguard.dirstateguard(repo, 'rebase') | |||
|
727 | with util.acceptintervention(dsguard): | |||
|
728 | rbsrt._performrebase(tr) | |||
718 |
|
729 | |||
719 | rbsrt._finishrebase() |
|
730 | rbsrt._finishrebase() | |
720 |
|
731 | |||
@@ -841,8 +852,10 b' def concludenode(repo, rev, p1, p2, comm' | |||||
841 | '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev |
|
852 | '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev | |
842 | but also store useful information in extra. |
|
853 | but also store useful information in extra. | |
843 | Return node of committed revision.''' |
|
854 | Return node of committed revision.''' | |
844 | dsguard = dirstateguard.dirstateguard(repo, 'rebase') |
|
855 | dsguard = util.nullcontextmanager() | |
845 | try: |
|
856 | if not repo.ui.configbool('rebase', 'singletransaction'): | |
|
857 | dsguard = dirstateguard.dirstateguard(repo, 'rebase') | |||
|
858 | with dsguard: | |||
846 | repo.setparents(repo[p1].node(), repo[p2].node()) |
|
859 | repo.setparents(repo[p1].node(), repo[p2].node()) | |
847 | ctx = repo[rev] |
|
860 | ctx = repo[rev] | |
848 | if commitmsg is None: |
|
861 | if commitmsg is None: | |
@@ -864,10 +877,7 b' def concludenode(repo, rev, p1, p2, comm' | |||||
864 | date=date, extra=extra, editor=editor) |
|
877 | date=date, extra=extra, editor=editor) | |
865 |
|
878 | |||
866 | repo.dirstate.setbranch(repo[newnode].branch()) |
|
879 | repo.dirstate.setbranch(repo[newnode].branch()) | |
867 | dsguard.close() |
|
|||
868 | return newnode |
|
880 | return newnode | |
869 | finally: |
|
|||
870 | release(dsguard) |
|
|||
871 |
|
881 | |||
872 | def rebasenode(repo, rev, p1, base, state, collapse, dest): |
|
882 | def rebasenode(repo, rev, p1, base, state, collapse, dest): | |
873 | 'Rebase a single revision rev on top of p1 using base as merge ancestor' |
|
883 | 'Rebase a single revision rev on top of p1 using base as merge ancestor' |
@@ -43,6 +43,16 b' class dirstateguard(object):' | |||||
43 | # ``release(tr, ....)``. |
|
43 | # ``release(tr, ....)``. | |
44 | self._abort() |
|
44 | self._abort() | |
45 |
|
45 | |||
|
46 | def __enter__(self): | |||
|
47 | return self | |||
|
48 | ||||
|
49 | def __exit__(self, exc_type, exc_val, exc_tb): | |||
|
50 | try: | |||
|
51 | if exc_type is None: | |||
|
52 | self.close() | |||
|
53 | finally: | |||
|
54 | self.release() | |||
|
55 | ||||
46 | def close(self): |
|
56 | def close(self): | |
47 | if not self._active: # already inactivated |
|
57 | if not self._active: # already inactivated | |
48 | msg = (_("can't close already inactivated backup: %s") |
|
58 | msg = (_("can't close already inactivated backup: %s") |
@@ -602,6 +602,10 b' def acceptintervention(tr=None):' | |||||
602 | finally: |
|
602 | finally: | |
603 | tr.release() |
|
603 | tr.release() | |
604 |
|
604 | |||
|
605 | @contextlib.contextmanager | |||
|
606 | def nullcontextmanager(): | |||
|
607 | yield | |||
|
608 | ||||
605 | class _lrucachenode(object): |
|
609 | class _lrucachenode(object): | |
606 | """A node in a doubly linked list. |
|
610 | """A node in a doubly linked list. | |
607 |
|
611 |
@@ -379,3 +379,40 b' Multiple roots. Two children share two p' | |||||
379 | / |
|
379 | / | |
380 | o 0: A |
|
380 | o 0: A | |
381 |
|
381 | |||
|
382 | Rebasing using a single transaction | |||
|
383 | ||||
|
384 | $ hg init singletr && cd singletr | |||
|
385 | $ cat >> .hg/hgrc <<EOF | |||
|
386 | > [rebase] | |||
|
387 | > singletransaction=True | |||
|
388 | > EOF | |||
|
389 | $ hg debugdrawdag <<'EOF' | |||
|
390 | > Z | |||
|
391 | > | | |||
|
392 | > | D | |||
|
393 | > | | | |||
|
394 | > | C | |||
|
395 | > | | | |||
|
396 | > Y B | |||
|
397 | > |/ | |||
|
398 | > A | |||
|
399 | > EOF | |||
|
400 | - We should only see two status stored messages. One from the start, one from | |||
|
401 | - the end. | |||
|
402 | $ hg rebase --debug -b D -d Z | grep 'status stored' | |||
|
403 | rebase status stored | |||
|
404 | rebase status stored | |||
|
405 | $ hg tglog | |||
|
406 | o 5: D | |||
|
407 | | | |||
|
408 | o 4: C | |||
|
409 | | | |||
|
410 | o 3: B | |||
|
411 | | | |||
|
412 | o 2: Z | |||
|
413 | | | |||
|
414 | o 1: Y | |||
|
415 | | | |||
|
416 | o 0: A | |||
|
417 | ||||
|
418 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now