short and long log messages

Matthieu Moy Matthieu.Moy at
Mon May 15 18:25:09 BST 2006


Something I liked in GNU Arch was the short Vs long log message (-s and 
-L on the command line, or Summary: ... and body in the log message header).

This allows a simple one-line description, convenient in, at least, "bzr 
log --line" and perhaps "bzr log --short", as well as a detailed one 
(that you can get with "bzr log -r XX").

AFAIK, there is no such thing in bzr. Indeed, a user can use the first 
line of the log message as a short description, and the next as a long 
one. I think this is the way to do it, but this deserve a little support 
in bzr itself: the log formatter for "--line" and "--short" should split 
the message at the first newline, instead of truncating after a number 
of characters. The patch below does this for --line.

Also, this should be documented as such (in the tutorial probably).

Any opinion?


=== modified file 'bzrlib/'
--- bzrlib/ 

+++ bzrlib/
@@ -430,6 +430,13 @@
              return str
          return str[:max_len-3]+'...'

+    def firstline(self, str):
+        idx = str.find("\n")
+        if idx != -1:
+            return str[:idx]
+        else:
+            return str
      def date_string(self, rev):
          from bzrlib.osutils import format_date
          return format_date(rev.timestamp, rev.timezone or 0,
@@ -449,7 +456,7 @@
      def log_string(self, rev, max_chars):
          out = [self.truncate(self.short_committer(rev), 20)]
-        out.append(self.message(rev).replace('\n', ' '))
+        out.append(self.firstline(self.message(rev)))
          return self.truncate(" ".join(out).rstrip('\n'), max_chars)

  def line_log(rev, max_chars):

More information about the bazaar mailing list