--- a/mercurial/obsolete.py Wed Oct 08 22:12:06 2014 -0700
+++ b/mercurial/obsolete.py Wed Oct 08 22:34:48 2014 -0700
@@ -208,6 +208,27 @@
data.extend(sucs)
return _pack(format, *data) + metadata
+def _fm0encodemeta(meta):
+ """Return encoded metadata string to string mapping.
+
+ Assume no ':' in key and no '\0' in both key and value."""
+ for key, value in meta.iteritems():
+ if ':' in key or '\0' in key:
+ raise ValueError("':' and '\0' are forbidden in metadata key'")
+ if '\0' in value:
+ raise ValueError("':' is forbidden in metadata value'")
+ return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)])
+
+def _fm0decodemeta(data):
+ """Return string to string dictionary from encoded version."""
+ d = {}
+ for l in data.split('\0'):
+ if l:
+ key, value = l.split(':')
+ d[key] = value
+ return d
+
+
# mapping to read/write various marker formats
# <version> -> (decoder, encoder)
formats = {_fm0version: (_fm0readmarkers, _fm0encodeonemarker)}
@@ -232,26 +253,6 @@
yield encodeone(marker)
-def _fm0encodemeta(meta):
- """Return encoded metadata string to string mapping.
-
- Assume no ':' in key and no '\0' in both key and value."""
- for key, value in meta.iteritems():
- if ':' in key or '\0' in key:
- raise ValueError("':' and '\0' are forbidden in metadata key'")
- if '\0' in value:
- raise ValueError("':' is forbidden in metadata value'")
- return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)])
-
-def _fm0decodemeta(data):
- """Return string to string dictionary from encoded version."""
- d = {}
- for l in data.split('\0'):
- if l:
- key, value = l.split(':')
- d[key] = value
- return d
-
class marker(object):
"""Wrap obsolete marker raw data"""