[MERGE][#157026] Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail

Aaron Bentley aaron.bentley at utoronto.ca
Sun Dec 2 14:16:22 GMT 2007


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

Lukáš Lalinský wrote:
> If the author user-id is in format "<email at example.com>", short or line
> log will show empty name. It should use the e-mail instead. This fixes
> https://bugs.launchpad.net/bzr/+bug/157026

bb:resubmit

Re-reviewing here...

@@ -602,11 +603,23 @@
     def show(self, revno, rev, delta):
         raise NotImplementedError('not implemented in abstract base')

+    _short_name_re = lazy_regex.lazy_compile(r'(.*?)\s*<(.*@.*)>')
+
     def short_committer(self, rev):
- -        return re.sub('<.*@.*>', '', rev.committer).strip(' ')
+        name = rev.committer
+        match = self._short_name_re.match(name)
+        if match is None:
+            return name
+        else:
+            return match.group(1) or match.group(2)

I think this can be factored out into a function that parses an email-id
and returns a (name, address) tuple.  That could become the
implementation of config.extract_email_address.

I think it's clearer to avoid precompiling the pattern, unless it can be
shown to be a performance win.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHUr420F+nu1YWqI0RAlIbAJ9cAzR7pBtB4UIVjGdzp4RlPRszHwCeKgUZ
PH8+lL6MESx3T59ShDAu2hY=
=jul9
-----END PGP SIGNATURE-----



More information about the bazaar mailing list