# HG changeset patch # User Martin von Zweigbergk # Date 2019-12-05 17:34:43 # Node ID fb07126dadbe02a5392288affc52f7ef1ffaff50 # Parent ebfd349eac46458d46d8770df09905558869a065 graft: extract `repo['.']` to local variable It's used in two places and I'm about to use it more. Differential Revision: https://phab.mercurial-scm.org/D7548 diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -2605,7 +2605,8 @@ def graft( # to copy commits), and 2) informs update that the incoming changes are # newer than the destination so it doesn't prompt about "remote changed foo # which local deleted". - mergeancestor = repo.changelog.isancestor(repo[b'.'].node(), ctx.node()) + pctx = repo[b'.'] + mergeancestor = repo.changelog.isancestor(pctx.node(), ctx.node()) stats = update( repo, @@ -2627,7 +2628,7 @@ def graft( pother = parents[0].node() with repo.dirstate.parentchange(): - repo.setparents(repo[b'.'].node(), pother) + repo.setparents(pctx.node(), pother) repo.dirstate.write(repo.currenttransaction()) # fix up dirstate for copies and renames copies.duplicatecopies(repo, repo[None], ctx.rev(), base.rev())