Patchwork D9830: commit: look-up new revision once

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2021, 11:51 p.m.
Message ID <differential-rev-PHID-DREV-wz6qhwomrkdguwnf4cu2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48141/
State Superseded
Headers show

Comments

phabricator - Jan. 18, 2021, 11:51 p.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Look-up by node is slightly more expensive, so since it is necessary
  more than once, do it explicitly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9830

AFFECTED FILES
  mercurial/commit.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -96,6 +96,7 @@ 
             ctx.date(),
             extra,
         )
+        rev = repo[n].rev()
         xp1, xp2 = p1.hex(), p2 and p2.hex() or b''
         repo.hook(
             b'pretxncommit',
@@ -108,7 +109,7 @@ 
         targetphase = subrepoutil.newcommitphase(repo.ui, ctx)
 
         # prevent unmarking changesets as public on recommit
-        waspublic = oldtip == repo.changelog.tiprev() and not repo[n].phase()
+        waspublic = oldtip == repo.changelog.tiprev() and not repo[rev].phase()
 
         if targetphase and not waspublic:
             # retract boundary do not alter parent changeset.
@@ -116,7 +117,7 @@ 
             # be compliant anyway
             #
             # if minimal phase was 0 we don't need to retract anything
-            phases.registernew(repo, tr, targetphase, [repo[n].rev()])
+            phases.registernew(repo, tr, targetphase, [rev])
         return n