Comments
Patch
@@ -217,6 +217,7 @@ class p4client(object):
self.keep = ui.configbool('perfarce', 'keep', True)
self.lowercasepaths = ui.configbool('perfarce', 'lowercasepaths', False)
self.ignorecase = ui.configbool('perfarce', 'ignorecase', False)
+ self.authormap = self.readauthormap()
# caches
self.clientspec = {}
@@ -276,6 +277,42 @@ class p4client(object):
if self.root.endswith('/'):
self.root = self.root[:-1]
+ def readauthormap(self):
+ authorfile = self.ui.configpath('perfarce', 'authormap')
+ authormap = {}
+
+ if not authorfile or not os.path.isfile(authorfile):
+ return authormap
+
+ afile = open(authorfile, 'r')
+ for line in afile:
+
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+
+ try:
+ srcauthor, dstauthor = line.split('=', 1)
+ except ValueError:
+ msg = _('ignoring bad line in author map file %s: %s\n')
+ self.ui.warn(msg % (authorfile, line.rstrip()))
+ continue
+
+ srcauthor = srcauthor.strip()
+ dstauthor = dstauthor.strip()
+ if authormap.get(srcauthor) in (None, dstauthor):
+ msg = _('mapping author %s to %s\n')
+ self.ui.debug(msg % (srcauthor, dstauthor))
+ authormap[srcauthor] = dstauthor
+ continue
+
+ m = _('overriding mapping for author %s, was %s, will be %s\n')
+ self.ui.status(m % (srcauthor, authormap[srcauthor], dstauthor))
+
+ afile.close()
+
+ return authormap
+
@propertycache
def filemapper(self):
if self.ui.config('perfarce', 'filemap'):
@@ -613,15 +650,19 @@ class p4client(object):
finally:
os.chdir(old)
- else:
- d = self.runone('user -o %s' % util.shellquote(user), abort=False)
- if 'Update' in d:
- try:
- r = '%s <%s>' % (d['FullName'], d['Email'])
- self.usercache[(user, None)] = r
- return r
- except Exception:
- pass
+ d = self.runone('user -o %s' % util.shellquote(user), abort=False)
+ if 'Update' in d:
+ try:
+ r = '%s <%s>' % (d['FullName'], d['Email'])
+ self.usercache[(user, None)] = r
+ return r
+ except Exception:
+ pass
+
+ r = self.authormap.get(user)
+ if r:
+ self.usercache[(user, None)] = r
+ return r
return user