[Svnmerge] [PATCH] indent nested log messages

Alan Barrett apb at cequrux.com
Tue Feb 14 00:57:44 PST 2006


I find the log messages generated by svnmerge.py easier to read if
the nested copies of the original logs are indented (in addition to
being separated by the "........" lines).  Here's a patch to indent by
two spaces.  The amount of indentation is configurable by editing the
definition of LOG_LINE_PREFIX.

--apb (Alan Barrett)

Index: svnmerge.py
===================================================================
--- svnmerge.py
+++ svnmerge.py
@@ -65,6 +65,9 @@
 LOG_SEPARATOR = 8 * '.'
 LOG_SEPARATOR_RE = re.compile('^((%s)+)' % re.escape(LOG_SEPARATOR),
                               re.MULTILINE)
+# Each line of the embedded log messages will be prefixed by LOG_LINE_PREFIX.
+#LOG_LINE_PREFIX = ''
+LOG_LINE_PREFIX = 2 * ' '
 
 # We expect non-localized output from SVN
 os.environ["LC_MESSAGES"] = "C"
@@ -169,6 +172,15 @@
     if opts["verbose"]:
         print "%s: %s" % (NAME, s)
 
+def prefix_lines(prefix, lines):
+	"""Given a string representing lines of text,
+	insert the specified prefix at the begining of each line,
+	and return the result."""
+	result = ""
+	for line in lines.split("\n"):
+		result = result + prefix + line + "\n"
+	return result
+
 class LaunchError(Exception):
     """Signal a failure in execution of an external command. Parameters are the
     exit code of the process, the original command line, and the output of the
@@ -482,7 +493,7 @@
     longest_sep = ''
     for r in revnums:
         message = get_commit_log(opts["head_url"], r)
-        logs.append(message)
+        logs.append(prefix_lines(LOG_LINE_PREFIX, message))
         for match in LOG_SEPARATOR_RE.findall(message):
             sep = match[1]
             if len(sep) > len(longest_sep):




More information about the Svnmerge mailing list