# HG changeset patch # User Martin von Zweigbergk # Date 1600990444 25200 # Node ID 95949b06bd484af0c8fd11b7a690c1f3c620d886 # Parent 18fa4797b5dd1253f1378cba52aedd7dcc2d8df4 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. diff -r 18fa4797b5dd -r 95949b06bd48 hgext3rd/evolve/evolvecmd.py --- 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):