# HG changeset patch # User maugustin # Date 1311467630 18000 # Node ID 09f7c1c092071815845f5dac9e87a8787be9d134 # Parent e30ff6d5feff1867ef9928930f6697c799c6aacd authormap: only append new or changed authors Previously, specifying an extra authormap with the hgsubversion.authormap configuration variable would cause the entirety of the other authormap to be appended to the one in '.hg/svn/authors' on each subversion access (e.g. hg in/out/pull/push). This also changes the authormap to preserve comments and the like in the authormap file. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -45,12 +45,9 @@ class AuthorMap(dict): self.ui.note('reading authormap from %s\n' % path) f = open(path, 'r') - for number, line in enumerate(f): + for number, line_org in enumerate(f): - if writing: - writing.write(line) - - line = line.split('#')[0] + line = line_org.split('#')[0] if not line.strip(): continue @@ -63,10 +60,15 @@ class AuthorMap(dict): src = src.strip() dst = dst.strip() - self.ui.debug('adding author %s to author map\n' % src) - if src in self and dst != self[src]: - msg = 'overriding author: "%s" to "%s" (%s)\n' - self.ui.status(msg % (self[src], dst, src)) + + if writing: + if not src in self: + self.ui.debug('adding author %s to author map\n' % src) + elif dst != self[src]: + msg = 'overriding author: "%s" to "%s" (%s)\n' + self.ui.status(msg % (self[src], dst, src)) + writing.write(line_org) + self[src] = dst f.close()