[PATCH] Use the first line of commit message in "log --line"

Matthieu Moy Matthieu.Moy at imag.fr
Mon Jun 5 14:59:14 BST 2006


My --line patch doesn't seem to have been merged yet, so here's a
reminder (I believe I've fixed/removed all the parts on which people
didn't agree). Additionnaly, I've added an entry in the NEWS file.

Thanks,

=== modified file 'NEWS'
--- NEWS        
+++ NEWS        
@@ -38,7 +38,9 @@
      ftp support has been improved, including support for supplying a
      non-standard port. (John Arbash Meinel).
 
-   * ``log --line`` shows the revision number.  (#5162, Alexander Belchenko)
+   * 'bzr log --line' shows the revision number, and uses only the
+     first line of the log message (#5162, Alexander Belchenko;
+     Matthieu Moy)
 
   BUG FIXES:
 

=== modified file 'bzrlib/log.py'
--- bzrlib/log.py       
+++ bzrlib/log.py       
@@ -461,7 +461,7 @@
             out.append("%d:" % revno)
         out.append(self.truncate(self.short_committer(rev), 20))
         out.append(self.date_string(rev))
-        out.append(self.message(rev).replace('\n', ' '))
+        out.append(rev.get_summary())
         return self.truncate(" ".join(out).rstrip('\n'), max_chars)
 
 

=== modified file 'bzrlib/revision.py'
--- bzrlib/revision.py  
+++ bzrlib/revision.py  
@@ -101,6 +101,11 @@
         reversed_result.reverse()
         return reversed_result
 
+    def get_summary(self):
+        """Get the first line of the log message for this revision.
+        """
+        return self.message.split('\n', 1)[0]
+
 
 def is_ancestor(revision_id, candidate_id, branch):
     """Return true if candidate_id is an ancestor of revision_id.

=== modified file 'bzrlib/tests/blackbox/test_too_much.py'
--- bzrlib/tests/blackbox/test_too_much.py      
+++ bzrlib/tests/blackbox/test_too_much.py      
@@ -823,7 +823,8 @@
         max_width = terminal_width() - 1
         for line in log_out.splitlines():
             self.assert_(len(line) <= max_width, len(line))
-        self.assert_("this is my new commit and" in log_out)
+        self.assert_("this is my new commit and" not in log_out)
+        self.assert_("this is my new commit" in log_out)
 
         progress("file with spaces in name")
         mkdir('sub directory')




-- 
Matthieu




More information about the bazaar mailing list