Rev 3080: (Lukáš Lalinský) 'log --short/--line' fall back to e-mail if there is no username in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Dec 5 19:29:50 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3080
revision-id:pqm at pqm.ubuntu.com-20071205192943-bii0mqi650ulw5y2
parent: pqm at pqm.ubuntu.com-20071205060118-l1gg524ng5twr0uw
parent: john at arbash-meinel.com-20071205184751-58fi7xoj8ddox6ch
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-12-05 19:29:43 +0000
message:
  (Lukáš Lalinský) 'log --short/--line' fall back to e-mail if there is no username
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
  bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
  bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
    ------------------------------------------------------------
    revno: 3063.3.4
    revision-id:john at arbash-meinel.com-20071205184751-58fi7xoj8ddox6ch
    parent: lalinsky at gmail.com-20071205160451-2crql4siyd3h1psb
    parent: pqm at pqm.ubuntu.com-20071205060118-l1gg524ng5twr0uw
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: jam-integration
    timestamp: Wed 2007-12-05 12:47:51 -0600
    message:
      [merge] bzr.dev 3079
    removed:
      index.txt                      index.txt-20071121073725-0corxykv5irjal00-1
    added:
      doc/en/quick-reference/quick-start-summary.png quickstartsummary.pn-20071203142852-hsiybkmh37q5owwe-1
    modified:
      Makefile                       Makefile-20050805140406-d96e3498bb61c5bb
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/bugtracker.py           bugtracker.py-20070410073305-vu1vu1qosjurg8kb-1
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
      bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
      bzrlib/help_topics.py          help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
      bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
      bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
      bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
      bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
      bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
      bzrlib/tests/test_bugtracker.py test_bugtracker.py-20070410073305-vu1vu1qosjurg8kb-2
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
      bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
      bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
      bzrlib/transport/ssh.py        ssh.py-20060824042150-0s9787kng6zv1nwq-1
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
      bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
      doc/en/quick-reference/quick-start-summary.svg quickstartsummary.sv-20070813143223-5i7bgw7w8s7l3ae2-3
      doc/en/user-guide/bug_trackers.txt bug_trackers.txt-20070713223459-khxdlcudraii95uv-1
      doc/en/user-guide/core_concepts.txt core_concepts.txt-20071114035000-q36a9h57ps06uvnl-2
      doc/en/user-guide/introducing_bazaar.txt introducing_bazaar.t-20071114035000-q36a9h57ps06uvnl-5
      doc/en/user-guide/merging_changes.txt merging_changes.txt-20071122141511-0knao2lklsdsvb1q-3
      doc/en/user-guide/resolving_conflicts.txt resolving_conflicts.-20071122141511-0knao2lklsdsvb1q-5
      doc/en/user-guide/reusing_a_checkout.txt reusing_a_checkout.t-20071123055134-k5x4ekduci2lbn36-3
      doc/en/user-guide/undoing_mistakes.txt undoing_mistakes.txt-20071121092300-8fyacngt1w98e5mp-1
      doc/en/user-guide/working_offline_central.txt working_offline_cent-20071123055134-k5x4ekduci2lbn36-5
      doc/index.txt                  index.txt-20070813101924-07gd9i9d2jt124bf-1
    ------------------------------------------------------------
    revno: 3063.3.3
    revision-id:lalinsky at gmail.com-20071205160451-2crql4siyd3h1psb
    parent: lalinsky at gmail.com-20071202185928-00cgoqzowl3s87hi
    committer: Lukáš Lalinský <lalinsky at gmail.com>
    branch nick: short-log-email
    timestamp: Wed 2007-12-05 17:04:51 +0100
    message:
      Add one more test for config.parse_username().
    modified:
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
    ------------------------------------------------------------
    revno: 3063.3.2
    revision-id:lalinsky at gmail.com-20071202185928-00cgoqzowl3s87hi
    parent: lalinsky at gmail.com-20071201110645-l42xh5ayoambqosl
    committer: Lukáš Lalinský <lalinsky at gmail.com>
    branch nick: short-log-email
    timestamp: Sun 2007-12-02 19:59:28 +0100
    message:
      Move the name and e-mail address extraction logic to config.parse_username.
    modified:
      bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
    ------------------------------------------------------------
    revno: 3063.3.1
    revision-id:lalinsky at gmail.com-20071201110645-l42xh5ayoambqosl
    parent: pqm at pqm.ubuntu.com-20071201001053-zi6k6s2817c1p97s
    committer: Lukáš Lalinský <lalinsky at gmail.com>
    branch nick: short-log-email
    timestamp: Sat 2007-12-01 12:06:45 +0100
    message:
      Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
=== modified file 'NEWS'
--- a/NEWS	2007-12-05 05:19:20 +0000
+++ b/NEWS	2007-12-05 18:47:51 +0000
@@ -46,6 +46,9 @@
    * Check for missing basis texts when fetching from packs to packs.
      (John Arbash Meinel, #165290)
 
+   * Fall back to showing e-mail in ``log --short/--line`` if the committer/author has
+     only e-mail. (Lukáš Lalinský, #157026)
+
   API BREAKS:
 
    * Deprecate not passing a ``location`` argument to commit reporters'

=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2007-11-19 20:20:29 +0000
+++ b/bzrlib/config.py	2007-12-02 18:59:28 +0000
@@ -862,20 +862,29 @@
     return realname, (username + '@' + socket.gethostname())
 
 
+def parse_username(username):
+    """Parse e-mail username and return a (name, address) tuple."""
+    match = re.match(r'(.*?)\s*<?([\w+.-]+@[\w+.-]+)>?', username)
+    if match is None:
+        return (username, '')
+    else:
+        return (match.group(1), match.group(2))
+
+
 def extract_email_address(e):
     """Return just the address part of an email string.
-    
+
     That is just the user at domain part, nothing else. 
     This part is required to contain only ascii characters.
     If it can't be extracted, raises an error.
-    
+
     >>> extract_email_address('Jane Tester <jane at test.com>')
     "jane at test.com"
     """
-    m = re.search(r'[\w+.-]+@[\w+.-]+', e)
-    if not m:
+    name, email = parse_username(e)
+    if not email:
         raise errors.NoEmailInUsername(e)
-    return m.group(0)
+    return email
 
 
 class TreeConfig(IniBasedConfig):

=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py	2007-12-03 16:57:01 +0000
+++ b/bzrlib/log.py	2007-12-05 18:47:51 +0000
@@ -60,6 +60,8 @@
     )
 
 from bzrlib import (
+    config,
+    lazy_regex,
     registry,
     symbol_versioning,
     )
@@ -619,10 +621,16 @@
         raise NotImplementedError('not implemented in abstract base')
 
     def short_committer(self, rev):
-        return re.sub('<.*@.*>', '', rev.committer).strip(' ')
+        name, address = config.parse_username(rev.committer)
+        if name:
+            return name
+        return address
 
     def short_author(self, rev):
-        return re.sub('<.*@.*>', '', rev.get_apparent_author()).strip(' ')
+        name, address = config.parse_username(rev.get_apparent_author())
+        if name:
+            return name
+        return address
 
 
 class LongLogFormatter(LogFormatter):

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2007-11-23 16:10:09 +0000
+++ b/bzrlib/tests/test_config.py	2007-12-05 16:04:51 +0000
@@ -1083,6 +1083,17 @@
         self.assertRaises(errors.NoEmailInUsername,
                           config.extract_email_address, 'Jane Tester')
 
+    def test_parse_username(self):
+        self.assertEqual(('', 'jdoe at example.com'),
+                         config.parse_username('jdoe at example.com'))
+        self.assertEqual(('', 'jdoe at example.com'),
+                         config.parse_username('<jdoe at example.com>'))
+        self.assertEqual(('John Doe', 'jdoe at example.com'),
+                         config.parse_username('John Doe <jdoe at example.com>'))
+        self.assertEqual(('John Doe', ''),
+                         config.parse_username('John Doe'))
+        self.assertEqual(('John Doe', 'jdoe at example.com'),
+                         config.parse_username('John Doe jdoe at example.com'))
 
 class TestTreeConfig(tests.TestCaseWithTransport):
 

=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py	2007-11-17 09:37:33 +0000
+++ b/bzrlib/tests/test_log.py	2007-12-05 18:47:51 +0000
@@ -902,6 +902,16 @@
         rev.committer = 'John Doe <jdoe at example.com>'
         lf = LogFormatter(None)
         self.assertEqual('John Doe', lf.short_committer(rev))
+        rev.committer = 'John Smith <jsmith at example.com>'
+        self.assertEqual('John Smith', lf.short_committer(rev))
+        rev.committer = 'John Smith'
+        self.assertEqual('John Smith', lf.short_committer(rev))
+        rev.committer = 'jsmith at example.com'
+        self.assertEqual('jsmith at example.com', lf.short_committer(rev))
+        rev.committer = '<jsmith at example.com>'
+        self.assertEqual('jsmith at example.com', lf.short_committer(rev))
+        rev.committer = 'John Smith jsmith at example.com'
+        self.assertEqual('John Smith', lf.short_committer(rev))
 
     def test_short_author(self):
         rev = Revision('a-id')
@@ -910,3 +920,11 @@
         self.assertEqual('John Doe', lf.short_author(rev))
         rev.properties['author'] = 'John Smith <jsmith at example.com>'
         self.assertEqual('John Smith', lf.short_author(rev))
+        rev.properties['author'] = 'John Smith'
+        self.assertEqual('John Smith', lf.short_author(rev))
+        rev.properties['author'] = 'jsmith at example.com'
+        self.assertEqual('jsmith at example.com', lf.short_author(rev))
+        rev.properties['author'] = '<jsmith at example.com>'
+        self.assertEqual('jsmith at example.com', lf.short_author(rev))
+        rev.properties['author'] = 'John Smith jsmith at example.com'
+        self.assertEqual('John Smith', lf.short_author(rev))




More information about the bazaar-commits mailing list