Patchwork [3,of,3] tags: establish a list of (rev, node) for heads

login
register
mail settings
Submitter Gregory Szorc
Date April 14, 2015, 6:19 p.m.
Message ID <b752d7abbd7ec2c210ca.1429035586@gps-mbp.local>
Download mbox | patch
Permalink /patch/8654/
State Rejected
Headers show

Comments

Gregory Szorc - April 14, 2015, 6:19 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1429035402 14400
#      Tue Apr 14 14:16:42 2015 -0400
# Node ID b752d7abbd7ec2c210ca5d36e8f0ef2f1b7d644f
# Parent  3ff6f1a639e2633af1ee8be2c354ebd2fb023bf2
tags: establish a list of (rev, node) for heads

A future patch will introduce a function that needs to be fed both the
numeric revision and binary node for each head. Refactor the code to
establish this variable.
Pierre-Yves David - April 14, 2015, 6:51 p.m.
On 04/14/2015 02:19 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1429035402 14400
> #      Tue Apr 14 14:16:42 2015 -0400
> # Node ID b752d7abbd7ec2c210ca5d36e8f0ef2f1b7d644f
> # Parent  3ff6f1a639e2633af1ee8be2c354ebd2fb023bf2
> tags: establish a list of (rev, node) for heads

This patch is dropped after discussing with greg IRL.

The complexity/benefit ratio is too low,

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -289,12 +289,18 @@  def _readtagcache(ui, repo):
         return (None, None, tags, False)
     if cachefile:
         cachefile.close()               # ignore rest of file
 
-    repoheads = repo.heads()
+    heads = []
+    headnodes = []
+    for rev in sorted(repo.changelog.headrevs(), reverse=True):
+        node = repo[rev].node()
+        heads.append((rev, node))
+        headnodes.append(node)
+
     # Case 2 (uncommon): empty repo; get out quickly and don't bother
     # writing an empty cache.
-    if repoheads == [nullid]:
+    if headnodes == [nullid]:
         return ([], {}, {}, False)
 
     # Case 3 (uncommon): cache file missing or empty.
 
@@ -311,14 +317,14 @@  def _readtagcache(ui, repo):
     # exposed".
     if not len(repo.file('.hgtags')):
         # No tags have ever been committed, so we can avoid a
         # potentially expensive search.
-        return (repoheads, cachefnode, None, True)
+        return (headnodes, cachefnode, None, True)
 
     starttime = time.time()
 
     newheads = [head
-                for head in repoheads
+                for head in headnodes
                 if head not in set(cacheheads)]
 
     # Now we have to lookup the .hgtags filenode for every new head.
     # This is the most expensive part of finding tags, so performance
@@ -340,9 +346,9 @@  def _readtagcache(ui, repo):
            len(cachefnode), len(newheads), duration)
 
     # Caller has to iterate over all heads, but can use the filenodes in
     # cachefnode to get to each .hgtags revision quickly.
-    return (repoheads, cachefnode, None, True)
+    return (headnodes, cachefnode, None, True)
 
 def _writetagcache(ui, repo, heads, tagfnode, cachetags):
     try:
         cachefile = repo.vfs('cache/tags', 'w', atomictemp=True)