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

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 11, 2014, 12:26 a.m.
Message ID <4e691a50e055b4d7c513.1410395167@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5781/
State Accepted
Commit 4669e26747c3c592738cf9d9c836706151aa1da4
Headers show

Comments

michaeljedgar@gmail.com - Sept. 11, 2014, 12:26 a.m.
# HG changeset patch
# User Mike Edgar <adgar@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

Patch

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):