Mercurial > hg
comparison hgext/rebase.py @ 29551:333dd3ab8fb2
rebase: replace extrafn field with _makeextrafn invocations
As per Yuya's advice, we would like to slightly reduce the amount of state
which is stored in rebaseruntime class. In this case, we don't need to store
extrafn field, as we can produce the necessary value by calling _makeextrafn
and the perf overhead is negligible.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Thu, 14 Jul 2016 02:59:27 -0700 |
parents | 5d16ebe7b14f |
children | db26925bdbb0 |
comparison
equal
deleted
inserted
replaced
29550:1c22400db72d | 29551:333dd3ab8fb2 |
---|---|
146 | 146 |
147 e = opts.get('extrafn') # internal, used by e.g. hgsubversion | 147 e = opts.get('extrafn') # internal, used by e.g. hgsubversion |
148 self.extrafns = [_savegraft] | 148 self.extrafns = [_savegraft] |
149 if e: | 149 if e: |
150 self.extrafns = [e] | 150 self.extrafns = [e] |
151 self.extrafn = None | |
152 | 151 |
153 self.keepf = opts.get('keep', False) | 152 self.keepf = opts.get('keep', False) |
154 self.keepbranchesf = opts.get('keepbranches', False) | 153 self.keepbranchesf = opts.get('keepbranches', False) |
155 # keepopen is not meant for use on the command line, but by | 154 # keepopen is not meant for use on the command line, but by |
156 # other extensions | 155 # other extensions |
333 # Keep track of the current bookmarks in order to reset them later | 332 # Keep track of the current bookmarks in order to reset them later |
334 self.currentbookmarks = repo._bookmarks.copy() | 333 self.currentbookmarks = repo._bookmarks.copy() |
335 self.activebookmark = self.activebookmark or repo._activebookmark | 334 self.activebookmark = self.activebookmark or repo._activebookmark |
336 if self.activebookmark: | 335 if self.activebookmark: |
337 bookmarks.deactivate(repo) | 336 bookmarks.deactivate(repo) |
338 | |
339 self.extrafn = _makeextrafn(self.extrafns) | |
340 | 337 |
341 self.sortedstate = sorted(self.state) | 338 self.sortedstate = sorted(self.state) |
342 total = len(self.sortedstate) | 339 total = len(self.sortedstate) |
343 pos = 0 | 340 pos = 0 |
344 for rev in self.sortedstate: | 341 for rev in self.sortedstate: |
379 if not self.collapsef: | 376 if not self.collapsef: |
380 merging = p2 != nullrev | 377 merging = p2 != nullrev |
381 editform = cmdutil.mergeeditform(merging, 'rebase') | 378 editform = cmdutil.mergeeditform(merging, 'rebase') |
382 editor = cmdutil.getcommiteditor(editform=editform, **opts) | 379 editor = cmdutil.getcommiteditor(editform=editform, **opts) |
383 newnode = concludenode(repo, rev, p1, p2, | 380 newnode = concludenode(repo, rev, p1, p2, |
384 extrafn=self.extrafn, | 381 extrafn=_makeextrafn(self.extrafns), |
385 editor=editor, | 382 editor=editor, |
386 keepbranches=self.keepbranchesf, | 383 keepbranches=self.keepbranchesf, |
387 date=self.date) | 384 date=self.date) |
388 else: | 385 else: |
389 # Skip commit if we are collapsing | 386 # Skip commit if we are collapsing |
442 editopt = True | 439 editopt = True |
443 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) | 440 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
444 revtoreuse = self.sortedstate[-1] | 441 revtoreuse = self.sortedstate[-1] |
445 newnode = concludenode(repo, revtoreuse, p1, self.external, | 442 newnode = concludenode(repo, revtoreuse, p1, self.external, |
446 commitmsg=commitmsg, | 443 commitmsg=commitmsg, |
447 extrafn=self.extrafn, editor=editor, | 444 extrafn=_makeextrafn(self.extrafns), |
445 editor=editor, | |
448 keepbranches=self.keepbranchesf, | 446 keepbranches=self.keepbranchesf, |
449 date=self.date) | 447 date=self.date) |
450 if newnode is None: | 448 if newnode is None: |
451 newrev = self.target | 449 newrev = self.target |
452 else: | 450 else: |