Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 2679:5156a67f66a6
topics: update current topic to the topic of newly rebased commit (issue5551)
The rebase code passes branchmerge equals to True while updating to the rebased
commit. We need to make sure topic is preserved even after rebase and hence we
need to update the topic even when branchmerge argument is set to True. But
there is a twist in the tale, merge also uses this part of code and we allow to
update topic when brancmerge is True, in merge cases the topic after merge will
the topic of the destination commit, not the topic of working directory parent.
So we need the function to have information about whether a rebase is going on,
and we do it by wrapping the rebase command and storing some value in the
config. This is a bit hacky but works for now. This patch fixes issue related to
loosing of topic while rebase.
Thanks to Boris Feld for the rigourous tests.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 29 Jun 2017 02:31:55 +0530 |
parents | 8cdee1b9ee92 |
children | 9b68a2083dac |
comparison
equal
deleted
inserted
replaced
2678:da2b3e5e4f69 | 2679:5156a67f66a6 |
---|---|
490 | 490 |
491 def mergeupdatewrap(orig, repo, node, branchmerge, force, *args, **kwargs): | 491 def mergeupdatewrap(orig, repo, node, branchmerge, force, *args, **kwargs): |
492 matcher = kwargs.get('matcher') | 492 matcher = kwargs.get('matcher') |
493 partial = not (matcher is None or matcher.always()) | 493 partial = not (matcher is None or matcher.always()) |
494 wlock = repo.wlock() | 494 wlock = repo.wlock() |
495 isrebase = False | |
495 try: | 496 try: |
496 ret = orig(repo, node, branchmerge, force, *args, **kwargs) | 497 ret = orig(repo, node, branchmerge, force, *args, **kwargs) |
497 if not partial and not branchmerge: | 498 # The mergeupdatewrap function makes the destination's topic as the |
499 # current topic. This is right for merge but wrong for rebase. We check | |
500 # if rebase is running and update the currenttopic to topic of new | |
501 # rebased commit. We have explicitly stored in config if rebase is | |
502 # running. | |
503 if repo.ui.hasconfig('experimental', 'topicrebase'): | |
504 isrebase = True | |
505 if (not partial and not branchmerge) or isrebase: | |
498 ot = repo.currenttopic | 506 ot = repo.currenttopic |
499 t = '' | 507 t = '' |
500 pctx = repo[node] | 508 pctx = repo[node] |
501 if pctx.phase() > phases.public: | 509 if pctx.phase() > phases.public: |
502 t = pctx.topic() | 510 t = pctx.topic() |
517 extra[constants.extrakey] = ctx.topic() | 525 extra[constants.extrakey] = ctx.topic() |
518 | 526 |
519 def newmakeextrafn(orig, copiers): | 527 def newmakeextrafn(orig, copiers): |
520 return orig(copiers + [savetopic]) | 528 return orig(copiers + [savetopic]) |
521 | 529 |
530 def setrebaseconfig(orig, ui, repo, **opts): | |
531 repo.ui.setconfig('experimental', 'topicrebase', 'yes', | |
532 source='topic-extension') | |
533 return orig(ui, repo, **opts) | |
534 | |
522 try: | 535 try: |
523 rebase = extensions.find("rebase") | 536 rebase = extensions.find("rebase") |
524 extensions.wrapfunction(rebase, '_makeextrafn', newmakeextrafn) | 537 extensions.wrapfunction(rebase, '_makeextrafn', newmakeextrafn) |
538 # This exists to store in the config that rebase is running so that we can | |
539 # update the topic according to rebase. This is a hack and should be removed | |
540 # when we have better options. | |
541 extensions.wrapcommand(rebase.cmdtable, 'rebase', setrebaseconfig) | |
525 except KeyError: | 542 except KeyError: |
526 pass | 543 pass |
527 | 544 |
528 ## preserve topic during import/export | 545 ## preserve topic during import/export |
529 | 546 |