changeset 22848:72100c1d53d4

obsolete: gather _fm0 meta encoding with other _fm0 code
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 08 Oct 2014 22:34:48 -0700
parents 37460ee2003c
children fd759142c6e5
files mercurial/obsolete.py
diffstat 1 files changed, 21 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- 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"""