churn: support spaces in aliases (issue2222)
authorAlexander Solovyov <piranha@piranha.org.ua>
Wed, 02 Jun 2010 14:28:45 +0200
changeset 11264 30c620e48d1c
parent 11263 1dd69d159e5c
child 11265 ffd85ab578be
churn: support spaces in aliases (issue2222)
hgext/churn.py
tests/test-churn
tests/test-churn.out
--- a/hgext/churn.py	Tue Jun 01 10:55:11 2010 -0500
+++ b/hgext/churn.py	Wed Jun 02 14:28:45 2010 +0200
@@ -115,7 +115,7 @@
     It is possible to map alternate email addresses to a main address
     by providing a file using the following format::
 
-      <alias email> <actual email>
+      <alias email> = <actual email>
 
     Such a file may be specified with the --aliases option, otherwise
     a .hgchurn file will be looked for in the working directory root.
@@ -129,9 +129,8 @@
         aliases = repo.wjoin('.hgchurn')
     if aliases:
         for l in open(aliases, "r"):
-            l = l.strip()
-            alias, actual = l.split()
-            amap[alias] = actual
+            alias, actual = l.split('=' in l and '=' or None, 1)
+            amap[alias.strip()] = actual.strip()
 
     rate = countrate(ui, repo, amap, *pats, **opts).items()
     if not rate:
--- a/tests/test-churn	Tue Jun 01 10:55:11 2010 -0500
+++ b/tests/test-churn	Wed Jun 02 14:28:45 2010 +0200
@@ -59,6 +59,12 @@
 echo % changeset number churn
 hg churn -c
 
+echo 'with space = no-space' >> ../aliases
+echo a >> a
+hg commit -m a -u 'with space' -d 15:00
+echo % churn with space in alias
+hg churn --aliases ../aliases -r tip
+
 cd ..
 
 # issue 833: ZeroDivisionError
--- a/tests/test-churn.out	Tue Jun 01 10:55:11 2010 -0500
+++ b/tests/test-churn.out	Wed Jun 02 14:28:45 2010 +0200
@@ -40,5 +40,7 @@
 user1      4 ***************************************************************
 user3      3 ***********************************************
 user2      2 ********************************
+% churn with space in alias
+no-space      1 ************************************************************
 adding foo
 test      0