Mercurial > hg
comparison hgext/rebase.py @ 35480:01b084914a60
rebase: don't take out a dirstate guard for in-memory rebase
Since IMM doesn't affect the dirstate, it's not needed, and might be faster.
Differential Revision: https://phab.mercurial-scm.org/D1745
author | Phil Cohen <phillco@fb.com> |
---|---|
date | Fri, 22 Dec 2017 00:44:36 -0600 |
parents | 71446ca85813 |
children | bf556bd2f589 |
comparison
equal
deleted
inserted
replaced
35479:8d05705bde0a | 35480:01b084914a60 |
---|---|
565 editopt = True | 565 editopt = True |
566 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) | 566 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
567 revtoreuse = max(self.state) | 567 revtoreuse = max(self.state) |
568 | 568 |
569 dsguard = None | 569 dsguard = None |
570 if ui.configbool('rebase', 'singletransaction'): | |
571 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | |
572 if self.inmemory: | 570 if self.inmemory: |
573 newnode = concludememorynode(repo, revtoreuse, p1, | 571 newnode = concludememorynode(repo, revtoreuse, p1, |
574 self.external, | 572 self.external, |
575 commitmsg=commitmsg, | 573 commitmsg=commitmsg, |
576 extrafn=_makeextrafn(self.extrafns), | 574 extrafn=_makeextrafn(self.extrafns), |
577 editor=editor, | 575 editor=editor, |
578 keepbranches=self.keepbranchesf, | 576 keepbranches=self.keepbranchesf, |
579 date=self.date, wctx=self.wctx) | 577 date=self.date, wctx=self.wctx) |
580 else: | 578 else: |
579 if ui.configbool('rebase', 'singletransaction'): | |
580 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | |
581 with util.acceptintervention(dsguard): | 581 with util.acceptintervention(dsguard): |
582 newnode = concludenode(repo, revtoreuse, p1, self.external, | 582 newnode = concludenode(repo, revtoreuse, p1, self.external, |
583 commitmsg=commitmsg, | 583 commitmsg=commitmsg, |
584 extrafn=_makeextrafn(self.extrafns), | 584 extrafn=_makeextrafn(self.extrafns), |
585 editor=editor, | 585 editor=editor, |
849 dsguard = None | 849 dsguard = None |
850 | 850 |
851 singletr = ui.configbool('rebase', 'singletransaction') | 851 singletr = ui.configbool('rebase', 'singletransaction') |
852 if singletr: | 852 if singletr: |
853 tr = repo.transaction('rebase') | 853 tr = repo.transaction('rebase') |
854 | |
855 # If `rebase.singletransaction` is enabled, wrap the entire operation in | |
856 # one transaction here. Otherwise, transactions are obtained when | |
857 # committing each node, which is slower but allows partial success. | |
854 with util.acceptintervention(tr): | 858 with util.acceptintervention(tr): |
855 if singletr: | 859 # Same logic for the dirstate guard, except we don't create one when |
860 # rebasing in-memory (it's not needed). | |
861 if singletr and not inmemory: | |
856 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | 862 dsguard = dirstateguard.dirstateguard(repo, 'rebase') |
857 with util.acceptintervention(dsguard): | 863 with util.acceptintervention(dsguard): |
858 rbsrt._performrebase(tr) | 864 rbsrt._performrebase(tr) |
859 | 865 |
860 rbsrt._finishrebase() | 866 rbsrt._finishrebase() |
1030 ', '.join(str(p) for p in sorted(parents)))) | 1036 ', '.join(str(p) for p in sorted(parents)))) |
1031 | 1037 |
1032 def concludememorynode(repo, rev, p1, p2, wctx=None, | 1038 def concludememorynode(repo, rev, p1, p2, wctx=None, |
1033 commitmsg=None, editor=None, extrafn=None, | 1039 commitmsg=None, editor=None, extrafn=None, |
1034 keepbranches=False, date=None): | 1040 keepbranches=False, date=None): |
1035 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev | 1041 '''Commit the memory changes with parents p1 and p2. Reuse commit info from |
1036 but also store useful information in extra. | 1042 rev but also store useful information in extra. |
1037 Return node of committed revision.''' | 1043 Return node of committed revision.''' |
1038 ctx = repo[rev] | 1044 ctx = repo[rev] |
1039 if commitmsg is None: | 1045 if commitmsg is None: |
1040 commitmsg = ctx.description() | 1046 commitmsg = ctx.description() |
1041 keepbranch = keepbranches and repo[p1].branch() != ctx.branch() | 1047 keepbranch = keepbranches and repo[p1].branch() != ctx.branch() |