Mercurial > hg
comparison hgext/rebase.py @ 23459:2e047b1558a5
rebase: clarify naming of variables holding node hashes - don't call them rev
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 02 Dec 2014 05:12:53 +0100 |
parents | fc76f55705eb |
children | 8dc45c905989 |
comparison
equal
deleted
inserted
replaced
23458:756376ec6c12 | 23459:2e047b1558a5 |
---|---|
390 ui.setconfig('ui', 'forcemerge', '', 'rebase') | 390 ui.setconfig('ui', 'forcemerge', '', 'rebase') |
391 if not collapsef: | 391 if not collapsef: |
392 merging = repo[p2].rev() != nullrev | 392 merging = repo[p2].rev() != nullrev |
393 editform = cmdutil.mergeeditform(merging, 'rebase') | 393 editform = cmdutil.mergeeditform(merging, 'rebase') |
394 editor = cmdutil.getcommiteditor(editform=editform, **opts) | 394 editor = cmdutil.getcommiteditor(editform=editform, **opts) |
395 newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn, | 395 newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn, |
396 editor=editor) | 396 editor=editor) |
397 else: | 397 else: |
398 # Skip commit if we are collapsing | 398 # Skip commit if we are collapsing |
399 repo.dirstate.beginparentchange() | 399 repo.dirstate.beginparentchange() |
400 repo.setparents(repo[p1].node()) | 400 repo.setparents(repo[p1].node()) |
401 repo.dirstate.endparentchange() | 401 repo.dirstate.endparentchange() |
402 newrev = None | 402 newnode = None |
403 # Update the state | 403 # Update the state |
404 if newrev is not None: | 404 if newnode is not None: |
405 state[rev] = repo[newrev].rev() | 405 state[rev] = repo[newnode].rev() |
406 else: | 406 else: |
407 if not collapsef: | 407 if not collapsef: |
408 ui.note(_('no changes, revision %d skipped\n') % rev) | 408 ui.note(_('no changes, revision %d skipped\n') % rev) |
409 ui.debug('next revision set to %s\n' % p1) | 409 ui.debug('next revision set to %s\n' % p1) |
410 skipped.add(rev) | 410 skipped.add(rev) |
425 for rebased in state: | 425 for rebased in state: |
426 if rebased not in skipped and state[rebased] > nullmerge: | 426 if rebased not in skipped and state[rebased] > nullmerge: |
427 commitmsg += '\n* %s' % repo[rebased].description() | 427 commitmsg += '\n* %s' % repo[rebased].description() |
428 editopt = True | 428 editopt = True |
429 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) | 429 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
430 newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg, | 430 newnode = concludenode(repo, rev, p1, external, commitmsg=commitmsg, |
431 extrafn=extrafn, editor=editor) | 431 extrafn=extrafn, editor=editor) |
432 for oldrev in state.iterkeys(): | 432 for oldrev in state.iterkeys(): |
433 if state[oldrev] > nullmerge: | 433 if state[oldrev] > nullmerge: |
434 state[oldrev] = newrev | 434 state[oldrev] = newnode |
435 | 435 |
436 if 'qtip' in repo.tags(): | 436 if 'qtip' in repo.tags(): |
437 updatemq(repo, state, skipped, **opts) | 437 updatemq(repo, state, skipped, **opts) |
438 | 438 |
439 if currentbookmarks: | 439 if currentbookmarks: |
457 hg.updaterepo(repo, newwd, False) | 457 hg.updaterepo(repo, newwd, False) |
458 | 458 |
459 if not keepf: | 459 if not keepf: |
460 collapsedas = None | 460 collapsedas = None |
461 if collapsef: | 461 if collapsef: |
462 collapsedas = newrev | 462 collapsedas = newnode |
463 clearrebased(ui, repo, state, skipped, collapsedas) | 463 clearrebased(ui, repo, state, skipped, collapsedas) |
464 | 464 |
465 if currentbookmarks: | 465 if currentbookmarks: |
466 updatebookmarks(repo, targetnode, nstate, currentbookmarks) | 466 updatebookmarks(repo, targetnode, nstate, currentbookmarks) |
467 if activebookmark not in repo._bookmarks: | 467 if activebookmark not in repo._bookmarks: |
503 'than one external parent: %s') % | 503 'than one external parent: %s') % |
504 (max(targetancestors), | 504 (max(targetancestors), |
505 ', '.join(str(p) for p in sorted(parents)))) | 505 ', '.join(str(p) for p in sorted(parents)))) |
506 | 506 |
507 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None): | 507 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None): |
508 'Commit the changes and store useful information in extra' | 508 '''Commit the changes and store useful information in extra. |
509 Return node of committed revision.''' | |
509 try: | 510 try: |
510 repo.dirstate.beginparentchange() | 511 repo.dirstate.beginparentchange() |
511 repo.setparents(repo[p1].node(), repo[p2].node()) | 512 repo.setparents(repo[p1].node(), repo[p2].node()) |
512 repo.dirstate.endparentchange() | 513 repo.dirstate.endparentchange() |
513 ctx = repo[rev] | 514 ctx = repo[rev] |
520 backup = repo.ui.backupconfig('phases', 'new-commit') | 521 backup = repo.ui.backupconfig('phases', 'new-commit') |
521 try: | 522 try: |
522 targetphase = max(ctx.phase(), phases.draft) | 523 targetphase = max(ctx.phase(), phases.draft) |
523 repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase') | 524 repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase') |
524 # Commit might fail if unresolved files exist | 525 # Commit might fail if unresolved files exist |
525 newrev = repo.commit(text=commitmsg, user=ctx.user(), | 526 newnode = repo.commit(text=commitmsg, user=ctx.user(), |
526 date=ctx.date(), extra=extra, editor=editor) | 527 date=ctx.date(), extra=extra, editor=editor) |
527 finally: | 528 finally: |
528 repo.ui.restoreconfig(backup) | 529 repo.ui.restoreconfig(backup) |
529 | 530 |
530 repo.dirstate.setbranch(repo[newrev].branch()) | 531 repo.dirstate.setbranch(repo[newnode].branch()) |
531 return newrev | 532 return newnode |
532 except util.Abort: | 533 except util.Abort: |
533 # Invalidate the previous setparents | 534 # Invalidate the previous setparents |
534 repo.dirstate.invalidate() | 535 repo.dirstate.invalidate() |
535 raise | 536 raise |
536 | 537 |