Where does self.message get set on the Revision object?

John Arbash Meinel john at arbash-meinel.com
Tue Jun 2 17:50:25 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Szakmeister wrote:
> On Fri, May 29, 2009 at 9:35 AM, John Szakmeister <john at szakmeister.net> wrote:
> [snip]
>> Is it acceptable that Revision.message is None?  FWIW, 'bzr log' shows
>> "(no message)" on the same revision that kills qlog, so it appears
>> that the command line tool can at least handle the fact that the
>> message is None (although it doesn't appear call get_summary() by
>> default, so it doesn't trigger that code path).  It would probably be
>> a good idea to document what attributes need to get added, and their
>> constraints (if any).
> 
> Ping.  It appears that at least portions of the code base allow for
> Revision.message to be None, so I think get_summary() should get a
> little smarter and make sure .message is not None before accessing it.
>  I just want verification of that before I create a patch.
> 
>> I'm also asking so I know where to submit a patch... either bzrlib or
>> bzr-svn. :-)
> 
> ...or qbzr.
> 
> -John
> 
> 

Looking at the code, in xml8.py it does:

  rev.message = elt.findtext('message')

If there was no 'message' property on the value, then this would return
None.

I would also mention that you should try "bzr log --line" which uses
get_summary() as well.

The log formatters seem to be doing:
        if not revision.rev.message:
            to_file.write(indent + '  (no message)\n')
        else:
Though I notice that the "LineLogFormatter" doesn't do such a check.

Note that "if not revision.rev.message:" will also handle the case where
the commit message is the empty string. (So both None and '' are handled.)

Now, I don't *know* what we want to display for when there is no
revision message. I can say that:

  bzr log --line

Will show nothing for a revision with no message.

Digging a bit deeper, I don't think that a properly formatted Revision
that is serialized down to disk, and then back up will have None for
message. I poked around, and doing msg = SubElement(root, 'message'),
will *always* create an element in the final string, and when you do
findtext('message') you get back the empty string (''), rather than None.


So I don't really care if you add:

    def get_summary(self):
        """Get the first line of the log message for this revision.
        """
	if self.message is None:
	    return ''
        return self.message.lstrip().split('\n', 1)[0]

But I'll comment that this Revision object has probably not been
serialized to disk. And my bet is that it is generated from something
like bzr-svn.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkolWFEACgkQJdeBCYSNAAMWOACfa1xesjFtjCSSH5yOq3t98H0f
tXAAnR5bESaR0ldKv6AHz5/OCGPd0Rk4
=SEiB
-----END PGP SIGNATURE-----



More information about the bazaar mailing list