Mercurial > evolve
changeset 5592:95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
We had very similar code for updating bookmarks to handle the case
when the relocation resulted in no changes and for the normal
case. This restructures the code a bit so the common part is better
reused.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 24 Sep 2020 16:34:04 -0700 |
parents | 18fa4797b5dd |
children | 28dc9ac2958a |
files | hgext3rd/evolve/evolvecmd.py |
diffstat | 1 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Thu Sep 24 16:15:58 2020 -0700 +++ b/hgext3rd/evolve/evolvecmd.py Thu Sep 24 16:34:04 2020 -0700 @@ -956,26 +956,25 @@ date=orig.date(), extra=extra) def _finalizerelocate(repo, orig, dest, nodenew, tr, category, evolvestate): - nodesrc = orig.node() - oldbookmarks = repo.nodebookmarks(nodesrc) - bmchanges = [] - if nodenew is not None: obsolete.createmarkers(repo, [(orig, (repo[nodenew],))], operation=b'evolve') - for book in oldbookmarks: - bmchanges.append((book, nodenew)) - evolvestate[b'bookmarkchanges'].append((book, nodesrc)) + bmdest = nodenew else: if category == b'orphan': repo.ui.status(_(b"evolution of %d:%s created no changes " b"to commit\n") % (orig.rev(), orig)) obsolete.createmarkers(repo, [(orig, ())], operation=b'evolve') # Behave like rebase, move bookmarks to dest + bmdest = dest.node() + + nodesrc = orig.node() + oldbookmarks = repo.nodebookmarks(nodesrc) + if oldbookmarks: + bmchanges = [] for book in oldbookmarks: evolvestate[b'bookmarkchanges'].append((book, nodesrc)) - bmchanges.append((book, dest.node())) - if bmchanges: + bmchanges.append((book, bmdest)) repo._bookmarks.applychanges(repo, tr, bmchanges) def _evolvemerge(repo, orig, dest, pctx, keepbranch):