mercurial/changelog.py
changeset 8443 53ff4a5af284
parent 8442 3acc6279b364
child 8499 fb9b83df45f3
--- a/mercurial/changelog.py	Sat May 16 11:16:23 2009 +0200
+++ b/mercurial/changelog.py	Fri May 15 01:21:24 2009 +0200
@@ -23,6 +23,19 @@
     text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r')
     return text.replace('\0', '\\0')
 
+def decodeextra(text):
+    extra = {}
+    for l in text.split('\0'):
+        if l:
+            k, v = l.decode('string_escape').split(':', 1)
+            extra[k] = v
+    return extra
+
+def encodeextra(d):
+    # keys must be sorted to produce a deterministic changelog entry
+    items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
+    return "\0".join(items)
+
 class appender:
     '''the changelog index must be updated last on disk, so we use this class
     to delay writes to it'''
@@ -145,19 +158,6 @@
             return
         return revlog.revlog.checkinlinesize(self, tr, fp)
 
-    def decode_extra(self, text):
-        extra = {}
-        for l in text.split('\0'):
-            if l:
-                k, v = l.decode('string_escape').split(':', 1)
-                extra[k] = v
-        return extra
-
-    def encode_extra(self, d):
-        # keys must be sorted to produce a deterministic changelog entry
-        items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
-        return "\0".join(items)
-
     def read(self, node):
         """
         format used:
@@ -192,7 +192,7 @@
         else:
             time, timezone, extra = extra_data
             time, timezone = float(time), int(timezone)
-            extra = self.decode_extra(extra)
+            extra = decodeextra(extra)
         if not extra.get('branch'):
             extra['branch'] = 'default'
         files = l[3:]
@@ -218,7 +218,7 @@
         if extra and extra.get("branch") in ("default", ""):
             del extra["branch"]
         if extra:
-            extra = self.encode_extra(extra)
+            extra = encodeextra(extra)
             parseddate = "%s %s" % (parseddate, extra)
         l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
         text = "\n".join(l)