Submitter | Sean Farley |
---|---|
Date | March 28, 2014, 10:05 p.m. |
Message ID | <9bab4721b0f6821f1f03.1396044359@laptop.local> |
Download | mbox | patch |
Permalink | /patch/4109/ |
State | Superseded |
Headers | show |
Comments
On Fri, 2014-03-28 at 17:05 -0500, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@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. Do you know about the localstr magic used for branches? http://mercurial.selenic.com/wiki/EncodingStrategy#Round-trip_conversion
Matt Mackall <mpm@selenic.com> writes: > On Fri, 2014-03-28 at 17:05 -0500, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@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. > > Do you know about the localstr magic used for branches? > > http://mercurial.selenic.com/wiki/EncodingStrategy#Round-trip_conversion I did not. Though, I think I will go a different route and not muck around with localrepo.
Patch
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