Patchwork [2,of,3,V2] tags: read tag info into a sorted dict (rather than into a regular dict)

login
register
mail settings
Submitter Angel Ezquerra
Date March 17, 2014, 6:36 a.m.
Message ID <d2b518fe1a6c7d113cd0.1395038212@ubuntu>
Download mbox | patch
Permalink /patch/3954/
State Superseded
Commit 5125856a28cf96ab4b54712ab86732f06e87b34a
Headers show

Comments

Angel Ezquerra - March 17, 2014, 6:36 a.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1393121601 -3600
#      Sun Feb 23 03:13:21 2014 +0100
# Node ID d2b518fe1a6c7d113cd0d8df5ce1f687e6ec0219
# Parent  2080392f1e7380880935f646a7751d79f4ab6b7d
tags: read tag info into a sorted dict (rather than into a regular dict)

This lets us preserve the original tag order (as specified on the .hgtags file
that is being read). This will be useful to preserve the tag order when saving
the result of a successful automated .hgtags merge (which will be introduced on
a future patch).

There shouldn't be much impact on performance because the sortdict that
_readtags returns is then used to update the alltags regular dict (which
remains a regular dict).

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -12,6 +12,7 @@ 
 
 from node import nullid, bin, hex, short
 from i18n import _
+from sortdict import sortdict
 import encoding
 import error
 import errno
@@ -80,7 +81,7 @@ 
     ids previously associated with it (in file order).  All node ids are
     binary, not hex.'''
 
-    filetags = {}               # map tag name to (node, hist)
+    filetags = sortdict()       # map tag name to (node, hist)
     count = 0
 
     def warn(msg):