##// END OF EJS Templates
rebase: move collapse-related local variables to the RR class...
Kostia Balytskyi -
r29400:c79da70a default
parent child Browse files
Show More
@@ -139,6 +139,9 b' class rebaseruntime(object):'
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)
143 self.collapsemsg = cmdutil.logmessage(ui, opts)
144
142 @command('rebase',
145 @command('rebase',
143 [('s', 'source', '',
146 [('s', 'source', '',
144 _('rebase the specified changeset and descendants'), _('REV')),
147 _('rebase the specified changeset and descendants'), _('REV')),
@@ -266,8 +269,6 b' def rebase(ui, repo, **opts):'
266 destspace = opts.get('_destspace')
269 destspace = opts.get('_destspace')
267 contf = opts.get('continue')
270 contf = opts.get('continue')
268 abortf = opts.get('abort')
271 abortf = opts.get('abort')
269 collapsef = opts.get('collapse', False)
270 collapsemsg = cmdutil.logmessage(ui, opts)
271 date = opts.get('date', None)
272 date = opts.get('date', None)
272 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
273 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
273 extrafns = [_savegraft]
274 extrafns = [_savegraft]
@@ -290,14 +291,14 b' def rebase(ui, repo, **opts):'
290 "'histedit' extension (see \"%s\")") % help
291 "'histedit' extension (see \"%s\")") % help
291 raise error.Abort(msg)
292 raise error.Abort(msg)
292
293
293 if collapsemsg and not collapsef:
294 if rbsrt.collapsemsg and not rbsrt.collapsef:
294 raise error.Abort(
295 raise error.Abort(
295 _('message can only be specified with collapse'))
296 _('message can only be specified with collapse'))
296
297
297 if contf or abortf:
298 if contf or abortf:
298 if contf and abortf:
299 if contf and abortf:
299 raise error.Abort(_('cannot use both abort and continue'))
300 raise error.Abort(_('cannot use both abort and continue'))
300 if collapsef:
301 if rbsrt.collapsef:
301 raise error.Abort(
302 raise error.Abort(
302 _('cannot use collapse with continue or abort'))
303 _('cannot use collapse with continue or abort'))
303 if srcf or basef or destf:
304 if srcf or basef or destf:
@@ -308,9 +309,9 b' def rebase(ui, repo, **opts):'
308
309
309 try:
310 try:
310 (rbsrt.originalwd, rbsrt.target, rbsrt.state,
311 (rbsrt.originalwd, rbsrt.target, rbsrt.state,
311 rbsrt.skipped, collapsef, keepf, keepbranchesf,
312 rbsrt.skipped, rbsrt.collapsef, keepf, keepbranchesf,
312 rbsrt.external, rbsrt.activebookmark) = restorestatus(repo)
313 rbsrt.external, rbsrt.activebookmark) = restorestatus(repo)
313 collapsemsg = restorecollapsemsg(repo)
314 rbsrt.collapsemsg = restorecollapsemsg(repo)
314 except error.RepoLookupError:
315 except error.RepoLookupError:
315 if abortf:
316 if abortf:
316 clearstatus(repo)
317 clearstatus(repo)
@@ -366,7 +367,7 b' def rebase(ui, repo, **opts):'
366 rebasesetrevs,
367 rebasesetrevs,
367 rebaseobsskipped)
368 rebaseobsskipped)
368
369
369 result = buildstate(repo, dest, rebaseset, collapsef,
370 result = buildstate(repo, dest, rebaseset, rbsrt.collapsef,
370 obsoletenotrebased)
371 obsoletenotrebased)
371
372
372 if not result:
373 if not result:
@@ -381,7 +382,7 b' def rebase(ui, repo, **opts):'
381 hint=_('see "hg help phases" for details'))
382 hint=_('see "hg help phases" for details'))
382
383
383 (rbsrt.originalwd, rbsrt.target, rbsrt.state) = result
384 (rbsrt.originalwd, rbsrt.target, rbsrt.state) = result
384 if collapsef:
385 if rbsrt.collapsef:
385 rbsrt.targetancestors = repo.changelog.ancestors([rbsrt.target],
386 rbsrt.targetancestors = repo.changelog.ancestors([rbsrt.target],
386 inclusive=True)
387 inclusive=True)
387 rbsrt.external = externalparent(repo, rbsrt.state,
388 rbsrt.external = externalparent(repo, rbsrt.state,
@@ -395,7 +396,7 b' def rebase(ui, repo, **opts):'
395 # there's a user-provided extrafn it can clobber branch if
396 # there's a user-provided extrafn it can clobber branch if
396 # desired
397 # desired
397 extrafns.insert(0, _savebranch)
398 extrafns.insert(0, _savebranch)
398 if collapsef:
399 if rbsrt.collapsef:
399 branches = set()
400 branches = set()
400 for rev in rbsrt.state:
401 for rev in rbsrt.state:
401 branches.add(repo[rev].branch())
402 branches.add(repo[rev].branch())
@@ -436,9 +437,10 b' def rebase(ui, repo, **opts):'
436 rbsrt.targetancestors,
437 rbsrt.targetancestors,
437 obsoletenotrebased)
438 obsoletenotrebased)
438 storestatus(repo, rbsrt.originalwd, rbsrt.target,
439 storestatus(repo, rbsrt.originalwd, rbsrt.target,
439 rbsrt.state, collapsef, keepf, keepbranchesf,
440 rbsrt.state, rbsrt.collapsef, keepf,
440 rbsrt.external, rbsrt.activebookmark)
441 keepbranchesf, rbsrt.external,
441 storecollapsemsg(repo, collapsemsg)
442 rbsrt.activebookmark)
443 storecollapsemsg(repo, rbsrt.collapsemsg)
442 if len(repo[None].parents()) == 2:
444 if len(repo[None].parents()) == 2:
443 repo.ui.debug('resuming interrupted rebase\n')
445 repo.ui.debug('resuming interrupted rebase\n')
444 else:
446 else:
@@ -446,14 +448,14 b' def rebase(ui, repo, **opts):'
446 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
448 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
447 'rebase')
449 'rebase')
448 stats = rebasenode(repo, rev, p1, base, rbsrt.state,
450 stats = rebasenode(repo, rev, p1, base, rbsrt.state,
449 collapsef, rbsrt.target)
451 rbsrt.collapsef, rbsrt.target)
450 if stats and stats[3] > 0:
452 if stats and stats[3] > 0:
451 raise error.InterventionRequired(
453 raise error.InterventionRequired(
452 _('unresolved conflicts (see hg '
454 _('unresolved conflicts (see hg '
453 'resolve, then hg rebase --continue)'))
455 'resolve, then hg rebase --continue)'))
454 finally:
456 finally:
455 ui.setconfig('ui', 'forcemerge', '', 'rebase')
457 ui.setconfig('ui', 'forcemerge', '', 'rebase')
456 if not collapsef:
458 if not rbsrt.collapsef:
457 merging = p2 != nullrev
459 merging = p2 != nullrev
458 editform = cmdutil.mergeeditform(merging, 'rebase')
460 editform = cmdutil.mergeeditform(merging, 'rebase')
459 editor = cmdutil.getcommiteditor(editform=editform, **opts)
461 editor = cmdutil.getcommiteditor(editform=editform, **opts)
@@ -472,7 +474,7 b' def rebase(ui, repo, **opts):'
472 rbsrt.state[rev] = repo[newnode].rev()
474 rbsrt.state[rev] = repo[newnode].rev()
473 ui.debug('rebased as %s\n' % short(newnode))
475 ui.debug('rebased as %s\n' % short(newnode))
474 else:
476 else:
475 if not collapsef:
477 if not rbsrt.collapsef:
476 ui.warn(_('note: rebase of %d:%s created no changes '
478 ui.warn(_('note: rebase of %d:%s created no changes '
477 'to commit\n') % (rev, ctx))
479 'to commit\n') % (rev, ctx))
478 rbsrt.skipped.add(rev)
480 rbsrt.skipped.add(rev)
@@ -498,15 +500,15 b' def rebase(ui, repo, **opts):'
498 ui.progress(_('rebasing'), None)
500 ui.progress(_('rebasing'), None)
499 ui.note(_('rebase merging completed\n'))
501 ui.note(_('rebase merging completed\n'))
500
502
501 if collapsef and not keepopen:
503 if rbsrt.collapsef and not keepopen:
502 p1, p2, _base = defineparents(repo, min(rbsrt.state),
504 p1, p2, _base = defineparents(repo, min(rbsrt.state),
503 rbsrt.target, rbsrt.state,
505 rbsrt.target, rbsrt.state,
504 rbsrt.targetancestors,
506 rbsrt.targetancestors,
505 obsoletenotrebased)
507 obsoletenotrebased)
506 editopt = opts.get('edit')
508 editopt = opts.get('edit')
507 editform = 'rebase.collapse'
509 editform = 'rebase.collapse'
508 if collapsemsg:
510 if rbsrt.collapsemsg:
509 commitmsg = collapsemsg
511 commitmsg = rbsrt.collapsemsg
510 else:
512 else:
511 commitmsg = 'Collapsed revision'
513 commitmsg = 'Collapsed revision'
512 for rebased in rbsrt.state:
514 for rebased in rbsrt.state:
@@ -558,7 +560,7 b' def rebase(ui, repo, **opts):'
558
560
559 if not keepf:
561 if not keepf:
560 collapsedas = None
562 collapsedas = None
561 if collapsef:
563 if rbsrt.collapsef:
562 collapsedas = newnode
564 collapsedas = newnode
563 clearrebased(ui, repo, rbsrt.state, rbsrt.skipped, collapsedas)
565 clearrebased(ui, repo, rbsrt.state, rbsrt.skipped, collapsedas)
564
566
General Comments 0
You need to be logged in to leave comments. Login now