convert.monotone: fix quotes and backslashes in change descriptions.
authorDavid Reiss <davidn@gmail.com>
Fri, 16 May 2008 00:48:23 -0700
changeset 6632 aa3f61884a48
parent 6631 a2b13cac0922
child 6633 67a2d2d9bf21
convert.monotone: fix quotes and backslashes in change descriptions.
hgext/convert/monotone.py
--- a/hgext/convert/monotone.py	Thu May 29 22:21:29 2008 +0200
+++ b/hgext/convert/monotone.py	Fri May 16 00:48:23 2008 -0700
@@ -16,7 +16,7 @@
 
         # regular expressions for parsing monotone output
         space    = r'\s*'
-        name     = r'\s+"((?:[^"]|\\")*)"\s*'
+        name     = r'\s+"((?:\\"|[^"])*)"\s*'
         value    = name
         revision = r'\s+\[(\w+)\]\s*'
         lines    = r'(?:.|\n)+'
@@ -98,11 +98,14 @@
     def mtngetcerts(self, rev):
         certs = {"author":"<missing>", "date":"<missing>",
             "changelog":"<missing>", "branch":"<missing>"}
-        cert_list = self.mtnrun("certs", rev).split("\n\n")
+        cert_list = self.mtnrun("certs", rev).split('\n\n      key "')
         for e in cert_list:
             m = self.cert_re.match(e)
             if m:
-                certs[m.group(1)] = m.group(2)
+                name, value = m.groups()
+                value = value.replace(r'\"', '"')
+                value = value.replace(r'\\', '\\')
+                certs[name] = value
         return certs
 
     def mtnrenamefiles(self, files, fromdir, todir):