filelog: make packmeta a public module function, to be used by censor
authorMike Edgar <adgar@google.com>
Wed, 10 Sep 2014 00:17:17 -0400
changeset 22420 4669e26747c3
parent 22419 fdfc9faca273
child 22421 30a610424eff
filelog: make packmeta a public module function, to be used by censor
mercurial/filelog.py
--- 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):