[PATCH 06 of 21 RFC] filelog: make packmeta a public module function, to be used by censor

michaeljedgar at gmail.com michaeljedgar at gmail.com
Wed Sep 10 19:26:07 CDT 2014


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1410322637 14400
#      Wed Sep 10 00:17:17 2014 -0400
# Node ID 4e691a50e055b4d7c513fca76ae3eed969710ec4
# Parent  3e01be88aea964717573131aaea12e95b34d56d3
filelog: make packmeta a public module function, to be used by censor

diff -r 3e01be88aea9 -r 4e691a50e055 mercurial/filelog.py
--- a/mercurial/filelog.py	Wed Sep 03 22:14:20 2014 -0400
+++ b/mercurial/filelog.py	Wed Sep 10 00:17:17 2014 -0400
@@ -22,10 +22,10 @@
         meta[k] = v
     return meta, (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)
 
 def _censoredtext(text):
     m, offs = _parsemeta(text)
@@ -45,7 +45,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):


More information about the Mercurial-devel mailing list