comparison hgext/rebase.py @ 29401:87acd047711e

rebase: move local variables 'date' and 'extrafns' to the RR class This commit moves the following variables, local to the rebase function to be fields of the rebaseruntime: -date -extrafns
author Kostia Balytskyi <ikostia@fb.com>
date Tue, 21 Jun 2016 06:29:23 -0700
parents c79da70a4659
children 7481ffb7ff83
comparison
equal deleted inserted replaced
29400:c79da70a4659 29401:87acd047711e
139 self.skipped = set() 139 self.skipped = set()
140 self.targetancestors = set() 140 self.targetancestors = set()
141 141
142 self.collapsef = opts.get('collapse', False) 142 self.collapsef = opts.get('collapse', False)
143 self.collapsemsg = cmdutil.logmessage(ui, opts) 143 self.collapsemsg = cmdutil.logmessage(ui, opts)
144 self.date = opts.get('date', None)
145
146 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
147 self.extrafns = [_savegraft]
148 if e:
149 self.extrafns = [e]
144 150
145 @command('rebase', 151 @command('rebase',
146 [('s', 'source', '', 152 [('s', 'source', '',
147 _('rebase the specified changeset and descendants'), _('REV')), 153 _('rebase the specified changeset and descendants'), _('REV')),
148 ('b', 'base', '', 154 ('b', 'base', '',
267 # search default destination in this space 273 # search default destination in this space
268 # used in the 'hg pull --rebase' case, see issue 5214. 274 # used in the 'hg pull --rebase' case, see issue 5214.
269 destspace = opts.get('_destspace') 275 destspace = opts.get('_destspace')
270 contf = opts.get('continue') 276 contf = opts.get('continue')
271 abortf = opts.get('abort') 277 abortf = opts.get('abort')
272 date = opts.get('date', None)
273 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
274 extrafns = [_savegraft]
275 if e:
276 extrafns = [e]
277 keepf = opts.get('keep', False) 278 keepf = opts.get('keep', False)
278 keepbranchesf = opts.get('keepbranches', False) 279 keepbranchesf = opts.get('keepbranches', False)
279 # keepopen is not meant for use on the command line, but by 280 # keepopen is not meant for use on the command line, but by
280 # other extensions 281 # other extensions
281 keepopen = opts.get('keepopen', False) 282 keepopen = opts.get('keepopen', False)
393 394
394 if keepbranchesf: 395 if keepbranchesf:
395 # insert _savebranch at the start of extrafns so if 396 # insert _savebranch at the start of extrafns so if
396 # there's a user-provided extrafn it can clobber branch if 397 # there's a user-provided extrafn it can clobber branch if
397 # desired 398 # desired
398 extrafns.insert(0, _savebranch) 399 rbsrt.extrafns.insert(0, _savebranch)
399 if rbsrt.collapsef: 400 if rbsrt.collapsef:
400 branches = set() 401 branches = set()
401 for rev in rbsrt.state: 402 for rev in rbsrt.state:
402 branches.add(repo[rev].branch()) 403 branches.add(repo[rev].branch())
403 if len(branches) > 1: 404 if len(branches) > 1:
413 currentbookmarks = repo._bookmarks.copy() 414 currentbookmarks = repo._bookmarks.copy()
414 rbsrt.activebookmark = rbsrt.activebookmark or repo._activebookmark 415 rbsrt.activebookmark = rbsrt.activebookmark or repo._activebookmark
415 if rbsrt.activebookmark: 416 if rbsrt.activebookmark:
416 bookmarks.deactivate(repo) 417 bookmarks.deactivate(repo)
417 418
418 extrafn = _makeextrafn(extrafns) 419 extrafn = _makeextrafn(rbsrt.extrafns)
419 420
420 sortedstate = sorted(rbsrt.state) 421 sortedstate = sorted(rbsrt.state)
421 total = len(sortedstate) 422 total = len(sortedstate)
422 pos = 0 423 pos = 0
423 for rev in sortedstate: 424 for rev in sortedstate:
460 editform = cmdutil.mergeeditform(merging, 'rebase') 461 editform = cmdutil.mergeeditform(merging, 'rebase')
461 editor = cmdutil.getcommiteditor(editform=editform, **opts) 462 editor = cmdutil.getcommiteditor(editform=editform, **opts)
462 newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn, 463 newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
463 editor=editor, 464 editor=editor,
464 keepbranches=keepbranchesf, 465 keepbranches=keepbranchesf,
465 date=date) 466 date=rbsrt.date)
466 else: 467 else:
467 # Skip commit if we are collapsing 468 # Skip commit if we are collapsing
468 repo.dirstate.beginparentchange() 469 repo.dirstate.beginparentchange()
469 repo.setparents(repo[p1].node()) 470 repo.setparents(repo[p1].node())
470 repo.dirstate.endparentchange() 471 repo.dirstate.endparentchange()
519 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) 520 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
520 newnode = concludenode(repo, rev, p1, rbsrt.external, 521 newnode = concludenode(repo, rev, p1, rbsrt.external,
521 commitmsg=commitmsg, 522 commitmsg=commitmsg,
522 extrafn=extrafn, editor=editor, 523 extrafn=extrafn, editor=editor,
523 keepbranches=keepbranchesf, 524 keepbranches=keepbranchesf,
524 date=date) 525 date=rbsrt.date)
525 if newnode is None: 526 if newnode is None:
526 newrev = rbsrt.target 527 newrev = rbsrt.target
527 else: 528 else:
528 newrev = repo[newnode].rev() 529 newrev = repo[newnode].rev()
529 for oldrev in rbsrt.state.iterkeys(): 530 for oldrev in rbsrt.state.iterkeys():