[PATCH 1 of 9 V3] localrepo: add _encodetags method
Sean Farley
sean.michael.farley at gmail.com
Fri Mar 28 17:05:59 CDT 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1396036685 18000
# Fri Mar 28 14:58:05 2014 -0500
# Node ID 9bab4721b0f6821f1f03d8a3eb9780dd14171000
# Parent dfad9bb23ab49bd461544c1d5fab3318ab637d23
localrepo: add _encodetags method
This will be used in upcoming patches to help reduce code duplication.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -579,10 +579,24 @@ class localrepository(object):
t[k] = v
except (error.LookupError, ValueError):
pass
return t
+ def _encodetags(self, tags, tagtypes):
+ '''Build the return dicts for tags and tagtypes. Have to
+ re-encode tag names because the tags module always uses UTF-8
+ (in order not to lose info writing to the cache), but the rest
+ of Mercurial wants them in local encoding.'''
+ oldtags = tags
+ tags = {}
+ for (name, (node, hist)) in oldtags.iteritems():
+ if node != nullid:
+ tags[encoding.tolocal(name)] = node
+ tagtypes = dict([(encoding.tolocal(name), value)
+ for (name, value) in tagtypes.iteritems()])
+ return (tags, tagtypes)
+
def _findtags(self):
'''Do the hard work of finding tags. Return a pair of dicts
(tags, tagtypes) where tags maps tag name to node, and tagtypes
maps tag name to a string like \'global\' or \'local\'.
Subclasses or extensions are free to add their own tags, but
More information about the Mercurial-devel
mailing list