Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/obsutil.py @ 38707:6b5ca1d0aa1e
obsolete: store user name and note in UTF-8 (issue5754) (BC)
Before, user names were stored in local encoding and transferred across
repositories, which made it impossible to restore non-ASCII user names on
different platforms. This patch fixes new markers to be encoded in UTF-8
and decoded back to local encoding when displaying. Existing markers are
unfixable so they may result in mojibake.
I don't like the API that requires metadata dict to be UTF-8 encoded, which
is a source of bugs, but there's no abstraction layer to process the encoding
thingy efficiently. So we apply the same rule as extras dict to obsstore
metadata.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 15 Jul 2018 18:24:57 +0900 |
parents | 83d965803325 |
children | 52e6171ec822 |
comparison
equal
deleted
inserted
replaced
38706:83d965803325 | 38707:6b5ca1d0aa1e |
---|---|
10 import re | 10 import re |
11 | 11 |
12 from .i18n import _ | 12 from .i18n import _ |
13 from . import ( | 13 from . import ( |
14 diffutil, | 14 diffutil, |
15 encoding, | |
15 node as nodemod, | 16 node as nodemod, |
16 phases, | 17 phases, |
17 util, | 18 util, |
18 ) | 19 ) |
19 from .utils import ( | 20 from .utils import ( |
820 | 821 |
821 def markersusers(markers): | 822 def markersusers(markers): |
822 """ Returns a sorted list of markers users without duplicates | 823 """ Returns a sorted list of markers users without duplicates |
823 """ | 824 """ |
824 markersmeta = [dict(m[3]) for m in markers] | 825 markersmeta = [dict(m[3]) for m in markers] |
825 users = set(meta['user'] for meta in markersmeta if meta.get('user')) | 826 users = set(encoding.tolocal(meta['user']) for meta in markersmeta |
827 if meta.get('user')) | |
826 | 828 |
827 return sorted(users) | 829 return sorted(users) |
828 | 830 |
829 def markersoperations(markers): | 831 def markersoperations(markers): |
830 """ Returns a sorted list of markers operations without duplicates | 832 """ Returns a sorted list of markers operations without duplicates |