changeset 22420:4669e26747c3

filelog: make packmeta a public module function, to be used by censor
author Mike Edgar <adgar@google.com>
date Wed, 10 Sep 2014 00:17:17 -0400
parents fdfc9faca273
children 30a610424eff
files mercurial/filelog.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filelog.py	Thu Sep 11 12:26:12 2014 -0500
+++ b/mercurial/filelog.py	Wed Sep 10 00:17:17 2014 -0400
@@ -24,10 +24,10 @@
         keys.append(k)
     return meta, keys, (s + 2)
 
-def _packmeta(meta, keys=None):
-    if not keys:
-        keys = sorted(meta.iterkeys())
-    return "".join("%s: %s\n" % (k, meta[k]) for k in keys)
+def packmeta(meta, text):
+    keys = sorted(meta.iterkeys())
+    metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys)
+    return "\1\n%s\1\n%s" % (metatext, text)
 
 class filelog(revlog.revlog):
     def __init__(self, opener, path):
@@ -43,7 +43,7 @@
 
     def add(self, text, meta, transaction, link, p1=None, p2=None):
         if meta or text.startswith('\1\n'):
-            text = "\1\n%s\1\n%s" % (_packmeta(meta), text)
+            text = packmeta(meta, text)
         return self.addrevision(text, transaction, link, p1, p2)
 
     def renamed(self, node):