repo: don't look up context for tip node if it's not needed
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 26 Sep 2018 10:38:37 -0700
changeset 39895 1a184b727aff
parent 39894 d739f423bf06
child 39896 642cbc228bad
repo: don't look up context for tip node if it's not needed We were doing repo['tip'].node() or similar in a few places where repo.changelog.tip() would be enough. Differential Revision: https://phab.mercurial-scm.org/D4781
contrib/python-hook-examples.py
hgext/mq.py
tests/test-commit.t
--- a/contrib/python-hook-examples.py	Wed Sep 26 22:17:34 2018 -0700
+++ b/contrib/python-hook-examples.py	Wed Sep 26 10:38:37 2018 -0700
@@ -19,7 +19,7 @@
     node = kwargs['node']
     first = repo[node].p1().node()
     if 'url' in kwargs:
-        last = repo['tip'].node()
+        last = repo.changelog.tip()
     else:
         last = node
     diff = patch.diff(repo, first, last)
--- a/hgext/mq.py	Wed Sep 26 22:17:34 2018 -0700
+++ b/hgext/mq.py	Wed Sep 26 10:38:37 2018 -0700
@@ -980,10 +980,10 @@
                 files += mergedsubstate.keys()
 
             match = scmutil.matchfiles(repo, files or [])
-            oldtip = repo['tip']
+            oldtip = repo.changelog.tip()
             n = newcommit(repo, None, message, ph.user, ph.date, match=match,
                           force=True)
-            if repo['tip'] == oldtip:
+            if repo.changelog.tip() == oldtip:
                 raise error.Abort(_("qpush exactly duplicates child changeset"))
             if n is None:
                 raise error.Abort(_("repository commit failed"))
--- a/tests/test-commit.t	Wed Sep 26 22:17:34 2018 -0700
+++ b/tests/test-commit.t	Wed Sep 26 10:38:37 2018 -0700
@@ -650,7 +650,7 @@
   > def filectxfn(repo, memctx, path):
   >     return context.memfilectx(repo, memctx, path,
   >         b'[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  > c = context.memctx(r, [r.changelog.tip(), node.nullid],
   >                    b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF