Mercurial > hg
comparison hgext/churn.py @ 19464:68f7129af6a8
churn: split email aliases from the right
This splits churn email aliases from the right, to enable incorrectly-specified
addresses that include equal signs to be mapped to correct addresses. This
will enable aliasing of bad addresses (typically typos) such as:
sername=myusername
that appear in the churn output through a churn alias such as:
sername=myusername = myusername
whereas previously splitting from the left would not enable this behavior.
author | Matthew Turk <matthewturk@gmail.com> |
---|---|
date | Wed, 17 Jul 2013 10:40:40 -0400 |
parents | 2150e70c0ee1 |
children | 9ef92384415c |
comparison
equal
deleted
inserted
replaced
19463:f3393d458bf5 | 19464:68f7129af6a8 |
---|---|
119 | 119 |
120 <alias email> = <actual email> | 120 <alias email> = <actual email> |
121 | 121 |
122 Such a file may be specified with the --aliases option, otherwise | 122 Such a file may be specified with the --aliases option, otherwise |
123 a .hgchurn file will be looked for in the working directory root. | 123 a .hgchurn file will be looked for in the working directory root. |
124 Aliases will be split from the rightmost "=". | |
124 ''' | 125 ''' |
125 def pad(s, l): | 126 def pad(s, l): |
126 return (s + " " * l)[:l] | 127 return (s + " " * l)[:l] |
127 | 128 |
128 amap = {} | 129 amap = {} |
130 if not aliases and os.path.exists(repo.wjoin('.hgchurn')): | 131 if not aliases and os.path.exists(repo.wjoin('.hgchurn')): |
131 aliases = repo.wjoin('.hgchurn') | 132 aliases = repo.wjoin('.hgchurn') |
132 if aliases: | 133 if aliases: |
133 for l in open(aliases, "r"): | 134 for l in open(aliases, "r"): |
134 try: | 135 try: |
135 alias, actual = l.split('=' in l and '=' or None, 1) | 136 alias, actual = l.rsplit('=' in l and '=' or None, 1) |
136 amap[alias.strip()] = actual.strip() | 137 amap[alias.strip()] = actual.strip() |
137 except ValueError: | 138 except ValueError: |
138 l = l.strip() | 139 l = l.strip() |
139 if l: | 140 if l: |
140 ui.warn(_("skipping malformed alias: %s\n") % l) | 141 ui.warn(_("skipping malformed alias: %s\n") % l) |