changeset 430:2851b81c65ce

maps: make sure AuthorMaps don't overwrite themselves, fix overriding Author maps for the Python repo got truncated because of the author map stupidly writing upon itself. This patch implements a better and faster scenario, where entries will only be written to the saved author map if they're not coming from that file. They're also now streamed into the file directly, instead of having to re-open the file on every entry, and formatting is preserved.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 15 Jun 2009 16:09:27 +0200
parents a5a475dced59
children 612b8d753549
files hgsubversion/maps.py tests/fixtures/author-map-test.txt tests/test_fetch_mappings.py
diffstat 3 files changed, 424 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/maps.py
+++ b/hgsubversion/maps.py
@@ -34,10 +34,18 @@ class AuthorMap(dict):
         ''' Load mappings from a file at the specified path. '''
         if not os.path.exists(path):
             return
+
+        writing = False
+        if path != self.path:
+            writing = open(self.path, 'a')
+
         self.ui.note('reading authormap from %s\n' % path)
         f = open(path, 'r')
         for number, line in enumerate(f):
 
+            if writing:
+                writing.write(line)
+
             line = line.split('#')[0]
             if not line.strip():
                 continue
@@ -51,23 +59,16 @@ 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.warn(msg % (self[src], dst, src))
-            else:
-                self[src] = dst
-
-        f.close()
+            self[src] = dst
 
-    def __setitem__(self, key, value):
-        ''' Similar to dict.__setitem__, but also updates the new mapping in the
-        backing store. '''
-        self.super.__setitem__(key, value)
-        self.ui.debug('adding author %s to author map\n' % self.path)
-        f = open(self.path, 'w+')
-        for k, v in self.iteritems():
-            f.write("%s=%s\n" % (k, v))
         f.close()
+        if writing:
+            writing.flush()
+            writing.close()
 
     def __getitem__(self, author):
         ''' Similar to dict.__getitem__, except in case of an unknown author.
new file mode 100644
--- /dev/null
+++ b/tests/fixtures/author-map-test.txt
@@ -0,0 +1,397 @@
+alpha01 = Alpha <alpha@alpha.com>
+alpha02 = Alpha <alpha@alpha.com>
+alpha03 = Alpha <alpha@alpha.com>
+alpha04 = Alpha <alpha@alpha.com>
+alpha05 = Alpha <alpha@alpha.com>
+alpha06 = Alpha <alpha@alpha.com>
+alpha07 = Alpha <alpha@alpha.com>
+alpha08 = Alpha <alpha@alpha.com>
+alpha09 = Alpha <alpha@alpha.com>
+alpha10 = Alpha <alpha@alpha.com>
+alpha11 = Alpha <alpha@alpha.com>
+alpha12 = Alpha <alpha@alpha.com>
+alpha13 = Alpha <alpha@alpha.com>
+alpha14 = Alpha <alpha@alpha.com>
+alpha15 = Alpha <alpha@alpha.com>
+alpha16 = Alpha <alpha@alpha.com>
+alpha17 = Alpha <alpha@alpha.com>
+alpha18 = Alpha <alpha@alpha.com>
+alpha19 = Alpha <alpha@alpha.com>
+alpha20 = Alpha <alpha@alpha.com>
+alpha21 = Alpha <alpha@alpha.com>
+alpha22 = Alph5 <alpha@alpha.com>
+alpha23 = Alpha <alpha@alpha.com>
+alpha24 = Alpha <alpha@alpha.com>
+alpha25 = Alpha <alpha@alpha.com>
+alpha26 = Alpha <alpha@alpha.com>
+alpha27 = Alpha <alpha@alpha.com>
+alpha28 = Alpha <alpha@alpha.com>
+alpha29 = Alpha <alpha@alpha.com>
+alpha30 = Alpha <alpha@alpha.com>
+alpha31 = Alpha <alpha@alpha.com>
+alpha32 = Alpha <alpha@alpha.com>
+alpha33 = Alpha <alpha@alpha.com>
+alpha34 = Alpha <alpha@alpha.com>
+alpha35 = Alpha <alpha@alpha.com>
+alpha36 = Alpha <alpha@alpha.com>
+alpha37 = Alph6 <alpha@alpha.com>
+alpha38 = Alpha <alpha@alpha.com>
+alpha39 = Alpha <alpha@alpha.com>
+alpha40 = Alpha <alpha@alpha.com>
+alpha41 = Alpha <alpha@alpha.com>
+alpha42 = Alpha <alpha@alpha.com>
+alpha43 = Alpha <alpha@alpha.com>
+alpha44 = Alph8 <alpha@alpha.com>
+alpha45 = Alpha <alpha@alpha.com>
+alpha46 = Alpha <alpha@alpha.com>
+alpha47 = Alpha <alpha@alpha.com>
+alpha48 = Alpha <alpha@alpha.com>
+alpha49 = Alpha <alpha@alpha.com>
+alpha50 = Alpha <alpha@alpha.com>
+alpha51 = Alpha <alpha@alpha.com>
+alpha52 = Alpha <alpha@alpha.com>
+alpha53 = Alpha <alpha@alpha.com>
+alpha54 = Alpha <alpha@alpha.com>
+alpha55 = Alpha <alpha@alpha.com>
+alpha56 = Alpha <alpha@alpha.com>
+alpha57 = Alph6 <alpha@alpha.com>
+alpha58 = Alpha <alpha@alpha.com>
+alpha59 = Alpha <alpha@alpha.com>
+alpha60 = Alpha <alpha@alpha.com>
+alpha61 = Alpha <alpha@alpha.com>
+alpha62 = Alpha <alpha@alpha.com>
+alpha63 = Alpha <alpha@alpha.com>
+alpha64 = Alpha <alpha@alpha.com>
+alpha65 = Alpha <alpha@alpha.com>
+alpha66 = Alpha <alpha@alpha.com>
+alpha67 = Alph6 <alpha@alpha.com>
+alpha68 = Alpha <alpha@alpha.com>
+alpha69 = Alpha <alpha@alpha.com>
+alpha70 = Alpha <alpha@alpha.com>
+alpha71 = Alpha <alpha@alpha.com>
+alpha72 = Alpha <alpha@alpha.com>
+alpha73 = Alpha <alpha@alpha.com>
+alpha74 = Alpha <alpha@alpha.com>
+alpha75 = Alpha <alpha@alpha.com>
+alpha76 = Alpha <alpha@alpha.com>
+alpha77 = Alph6 <alpha@alpha.com>
+alpha78 = Alpha <alpha@alpha.com>
+alpha79 = Alpha <alpha@alpha.com>
+alpha80 = Alpha <alpha@alpha.com>
+alpha81 = Alpha <alpha@alpha.com>
+alpha82 = Alpha <alpha@alpha.com>
+alpha83 = Alpha <alpha@alpha.com>
+alpha84 = Alpha <alpha@alpha.com>
+alpha85 = Alpha <alpha@alpha.com>
+alpha86 = Alpha <alpha@alpha.com>
+alpha87 = Alpha <alpha@alpha.com>
+alpha88 = Alpha <alpha@alpha.com>
+alpha89 = Alpha <alpha@alpha.com>
+alpha90 = Alpha <alpha@alpha.com>
+alpha91 = Alpha <alpha@alpha.com>
+alpha92 = Alpha <alpha@alpha.com>
+alpha93 = Alpha <alpha@alpha.com>
+alpha94 = Alpha <alpha@alpha.com>
+alpha95 = Alpha <alpha@alpha.com>
+alpha96 = Alpha <alpha@alpha.com>
+alpha97 = Alpha <alpha@alpha.com>
+alpha98 = Alpha <alpha@alpha.com>
+alpha99 = Alpha <alpha@alpha.com>
+alpha101 = Alpha <alpha@alpha.com>
+alpha102 = Alpha <alpha@alpha.com>
+alpha103 = Alpha <alpha@alpha.com>
+alpha104 = Alpha <alpha@alpha.com>
+alpha105 = Alpha <alpha@alpha.com>
+alpha106 = Alpha <alpha@alpha.com>
+alpha107 = Alpha <alpha@alpha.com>
+alpha108 = Alpha <alpha@alpha.com>
+alpha109 = Alpha <alpha@alpha.com>
+alpha110 = Alpha <alpha@alpha.com>
+alpha111 = Alpha <alpha@alpha.com>
+alpha112 = Alpha <alpha@alpha.com>
+alpha113 = Alpha <alpha@alpha.com>
+alpha114 = Alpha <alpha@alpha.com>
+alpha115 = Alpha <alpha@alpha.com>
+alpha116 = Alpha <alpha@alpha.com>
+alpha117 = Alpha <alpha@alpha.com>
+alpha118 = Alpha <alpha@alpha.com>
+alpha119 = Alpha <alpha@alpha.com>
+alpha120 = Alpha <alpha@alpha.com>
+alpha121 = Alpha <alpha@alpha.com>
+alpha122 = Alph5 <alpha@alpha.com>
+alpha123 = Alpha <alpha@alpha.com>
+alpha124 = Alpha <alpha@alpha.com>
+alpha125 = Alpha <alpha@alpha.com>
+alpha126 = Alpha <alpha@alpha.com>
+alpha127 = Alpha <alpha@alpha.com>
+alpha128 = Alpha <alpha@alpha.com>
+alpha129 = Alpha <alpha@alpha.com>
+alpha130 = Alpha <alpha@alpha.com>
+alpha131 = Alpha <alpha@alpha.com>
+alpha132 = Alpha <alpha@alpha.com>
+alpha133 = Alpha <alpha@alpha.com>
+alpha134 = Alpha <alpha@alpha.com>
+alpha135 = Alpha <alpha@alpha.com>
+alpha136 = Alpha <alpha@alpha.com>
+alpha137 = Alph6 <alpha@alpha.com>
+alpha138 = Alpha <alpha@alpha.com>
+alpha139 = Alpha <alpha@alpha.com>
+alpha140 = Alpha <alpha@alpha.com>
+alpha141 = Alpha <alpha@alpha.com>
+alpha142 = Alpha <alpha@alpha.com>
+alpha143 = Alpha <alpha@alpha.com>
+alpha144 = Alph8 <alpha@alpha.com>
+alpha145 = Alpha <alpha@alpha.com>
+alpha146 = Alpha <alpha@alpha.com>
+alpha147 = Alpha <alpha@alpha.com>
+alpha148 = Alpha <alpha@alpha.com>
+alpha149 = Alpha <alpha@alpha.com>
+alpha150 = Alpha <alpha@alpha.com>
+alpha151 = Alpha <alpha@alpha.com>
+alpha152 = Alpha <alpha@alpha.com>
+alpha153 = Alpha <alpha@alpha.com>
+alpha154 = Alpha <alpha@alpha.com>
+alpha155 = Alpha <alpha@alpha.com>
+alpha156 = Alpha <alpha@alpha.com>
+alpha157 = Alph6 <alpha@alpha.com>
+alpha158 = Alpha <alpha@alpha.com>
+alpha159 = Alpha <alpha@alpha.com>
+alpha160 = Alpha <alpha@alpha.com>
+alpha161 = Alpha <alpha@alpha.com>
+alpha162 = Alpha <alpha@alpha.com>
+alpha163 = Alpha <alpha@alpha.com>
+alpha164 = Alpha <alpha@alpha.com>
+alpha165 = Alpha <alpha@alpha.com>
+alpha166 = Alpha <alpha@alpha.com>
+alpha167 = Alph6 <alpha@alpha.com>
+alpha168 = Alpha <alpha@alpha.com>
+alpha169 = Alpha <alpha@alpha.com>
+alpha170 = Alpha <alpha@alpha.com>
+alpha171 = Alpha <alpha@alpha.com>
+alpha172 = Alpha <alpha@alpha.com>
+alpha173 = Alpha <alpha@alpha.com>
+alpha174 = Alpha <alpha@alpha.com>
+alpha175 = Alpha <alpha@alpha.com>
+alpha176 = Alpha <alpha@alpha.com>
+alpha177 = Alph6 <alpha@alpha.com>
+alpha178 = Alpha <alpha@alpha.com>
+alpha179 = Alpha <alpha@alpha.com>
+alpha180 = Alpha <alpha@alpha.com>
+alpha181 = Alpha <alpha@alpha.com>
+alpha182 = Alpha <alpha@alpha.com>
+alpha183 = Alpha <alpha@alpha.com>
+alpha184 = Alpha <alpha@alpha.com>
+alpha185 = Alpha <alpha@alpha.com>
+alpha186 = Alpha <alpha@alpha.com>
+alpha187 = Alpha <alpha@alpha.com>
+alpha188 = Alpha <alpha@alpha.com>
+alpha189 = Alpha <alpha@alpha.com>
+alpha190 = Alpha <alpha@alpha.com>
+alpha191 = Alpha <alpha@alpha.com>
+alpha192 = Alpha <alpha@alpha.com>
+alpha193 = Alpha <alpha@alpha.com>
+alpha194 = Alpha <alpha@alpha.com>
+alpha195 = Alpha <alpha@alpha.com>
+alpha196 = Alpha <alpha@alpha.com>
+alpha197 = Alpha <alpha@alpha.com>
+alpha198 = Alpha <alpha@alpha.com>
+alpha199 = Alpha <alpha@alpha.com>
+alpha201 = Alpha <alpha@alpha.com>
+alpha202 = Alpha <alpha@alpha.com>
+alpha203 = Alpha <alpha@alpha.com>
+alpha204 = Alpha <alpha@alpha.com>
+alpha205 = Alpha <alpha@alpha.com>
+alpha206 = Alpha <alpha@alpha.com>
+alpha207 = Alpha <alpha@alpha.com>
+alpha208 = Alpha <alpha@alpha.com>
+alpha209 = Alpha <alpha@alpha.com>
+alpha210 = Alpha <alpha@alpha.com>
+alpha211 = Alpha <alpha@alpha.com>
+alpha212 = Alpha <alpha@alpha.com>
+alpha213 = Alpha <alpha@alpha.com>
+alpha214 = Alpha <alpha@alpha.com>
+alpha215 = Alpha <alpha@alpha.com>
+alpha216 = Alpha <alpha@alpha.com>
+alpha217 = Alpha <alpha@alpha.com>
+alpha218 = Alpha <alpha@alpha.com>
+alpha219 = Alpha <alpha@alpha.com>
+alpha220 = Alpha <alpha@alpha.com>
+alpha221 = Alpha <alpha@alpha.com>
+alpha222 = Alph5 <alpha@alpha.com>
+alpha223 = Alpha <alpha@alpha.com>
+alpha224 = Alpha <alpha@alpha.com>
+alpha225 = Alpha <alpha@alpha.com>
+alpha226 = Alpha <alpha@alpha.com>
+alpha227 = Alpha <alpha@alpha.com>
+alpha228 = Alpha <alpha@alpha.com>
+alpha229 = Alpha <alpha@alpha.com>
+alpha230 = Alpha <alpha@alpha.com>
+alpha231 = Alpha <alpha@alpha.com>
+alpha232 = Alpha <alpha@alpha.com>
+alpha233 = Alpha <alpha@alpha.com>
+alpha234 = Alpha <alpha@alpha.com>
+alpha235 = Alpha <alpha@alpha.com>
+alpha236 = Alpha <alpha@alpha.com>
+alpha237 = Alph6 <alpha@alpha.com>
+alpha238 = Alpha <alpha@alpha.com>
+alpha239 = Alpha <alpha@alpha.com>
+alpha240 = Alpha <alpha@alpha.com>
+alpha241 = Alpha <alpha@alpha.com>
+alpha242 = Alpha <alpha@alpha.com>
+alpha243 = Alpha <alpha@alpha.com>
+alpha244 = Alph8 <alpha@alpha.com>
+alpha245 = Alpha <alpha@alpha.com>
+alpha246 = Alpha <alpha@alpha.com>
+alpha247 = Alpha <alpha@alpha.com>
+alpha248 = Alpha <alpha@alpha.com>
+alpha249 = Alpha <alpha@alpha.com>
+alpha250 = Alpha <alpha@alpha.com>
+alpha251 = Alpha <alpha@alpha.com>
+alpha252 = Alpha <alpha@alpha.com>
+alpha253 = Alpha <alpha@alpha.com>
+alpha254 = Alpha <alpha@alpha.com>
+alpha255 = Alpha <alpha@alpha.com>
+alpha256 = Alpha <alpha@alpha.com>
+alpha257 = Alph6 <alpha@alpha.com>
+alpha258 = Alpha <alpha@alpha.com>
+alpha259 = Alpha <alpha@alpha.com>
+alpha260 = Alpha <alpha@alpha.com>
+alpha261 = Alpha <alpha@alpha.com>
+alpha262 = Alpha <alpha@alpha.com>
+alpha263 = Alpha <alpha@alpha.com>
+alpha264 = Alpha <alpha@alpha.com>
+alpha265 = Alpha <alpha@alpha.com>
+alpha266 = Alpha <alpha@alpha.com>
+alpha267 = Alph6 <alpha@alpha.com>
+alpha268 = Alpha <alpha@alpha.com>
+alpha269 = Alpha <alpha@alpha.com>
+alpha270 = Alpha <alpha@alpha.com>
+alpha271 = Alpha <alpha@alpha.com>
+alpha272 = Alpha <alpha@alpha.com>
+alpha273 = Alpha <alpha@alpha.com>
+alpha274 = Alpha <alpha@alpha.com>
+alpha275 = Alpha <alpha@alpha.com>
+alpha276 = Alpha <alpha@alpha.com>
+alpha277 = Alph6 <alpha@alpha.com>
+alpha278 = Alpha <alpha@alpha.com>
+alpha279 = Alpha <alpha@alpha.com>
+alpha280 = Alpha <alpha@alpha.com>
+alpha281 = Alpha <alpha@alpha.com>
+alpha282 = Alpha <alpha@alpha.com>
+alpha283 = Alpha <alpha@alpha.com>
+alpha284 = Alpha <alpha@alpha.com>
+alpha285 = Alpha <alpha@alpha.com>
+alpha286 = Alpha <alpha@alpha.com>
+alpha287 = Alpha <alpha@alpha.com>
+alpha288 = Alpha <alpha@alpha.com>
+alpha289 = Alpha <alpha@alpha.com>
+alpha290 = Alpha <alpha@alpha.com>
+alpha291 = Alpha <alpha@alpha.com>
+alpha292 = Alpha <alpha@alpha.com>
+alpha293 = Alpha <alpha@alpha.com>
+alpha294 = Alpha <alpha@alpha.com>
+alpha295 = Alpha <alpha@alpha.com>
+alpha296 = Alpha <alpha@alpha.com>
+alpha297 = Alpha <alpha@alpha.com>
+alpha298 = Alpha <alpha@alpha.com>
+alpha299 = Alpha <alpha@alpha.com>
+alpha301 = Alpha <alpha@alpha.com>
+alpha302 = Alpha <alpha@alpha.com>
+alpha303 = Alpha <alpha@alpha.com>
+alpha304 = Alpha <alpha@alpha.com>
+alpha305 = Alpha <alpha@alpha.com>
+alpha306 = Alpha <alpha@alpha.com>
+alpha307 = Alpha <alpha@alpha.com>
+alpha308 = Alpha <alpha@alpha.com>
+alpha309 = Alpha <alpha@alpha.com>
+alpha310 = Alpha <alpha@alpha.com>
+alpha311 = Alpha <alpha@alpha.com>
+alpha312 = Alpha <alpha@alpha.com>
+alpha313 = Alpha <alpha@alpha.com>
+alpha314 = Alpha <alpha@alpha.com>
+alpha315 = Alpha <alpha@alpha.com>
+alpha316 = Alpha <alpha@alpha.com>
+alpha317 = Alpha <alpha@alpha.com>
+alpha318 = Alpha <alpha@alpha.com>
+alpha319 = Alpha <alpha@alpha.com>
+alpha320 = Alpha <alpha@alpha.com>
+alpha321 = Alpha <alpha@alpha.com>
+alpha322 = Alph5 <alpha@alpha.com>
+alpha323 = Alpha <alpha@alpha.com>
+alpha324 = Alpha <alpha@alpha.com>
+alpha325 = Alpha <alpha@alpha.com>
+alpha326 = Alpha <alpha@alpha.com>
+alpha327 = Alpha <alpha@alpha.com>
+alpha328 = Alpha <alpha@alpha.com>
+alpha329 = Alpha <alpha@alpha.com>
+alpha330 = Alpha <alpha@alpha.com>
+alpha331 = Alpha <alpha@alpha.com>
+alpha332 = Alpha <alpha@alpha.com>
+alpha333 = Alpha <alpha@alpha.com>
+alpha334 = Alpha <alpha@alpha.com>
+alpha335 = Alpha <alpha@alpha.com>
+alpha336 = Alpha <alpha@alpha.com>
+alpha337 = Alph6 <alpha@alpha.com>
+alpha338 = Alpha <alpha@alpha.com>
+alpha339 = Alpha <alpha@alpha.com>
+alpha340 = Alpha <alpha@alpha.com>
+alpha341 = Alpha <alpha@alpha.com>
+alpha342 = Alpha <alpha@alpha.com>
+alpha343 = Alpha <alpha@alpha.com>
+alpha344 = Alph8 <alpha@alpha.com>
+alpha345 = Alpha <alpha@alpha.com>
+alpha346 = Alpha <alpha@alpha.com>
+alpha347 = Alpha <alpha@alpha.com>
+alpha348 = Alpha <alpha@alpha.com>
+alpha349 = Alpha <alpha@alpha.com>
+alpha350 = Alpha <alpha@alpha.com>
+alpha351 = Alpha <alpha@alpha.com>
+alpha352 = Alpha <alpha@alpha.com>
+alpha353 = Alpha <alpha@alpha.com>
+alpha354 = Alpha <alpha@alpha.com>
+alpha355 = Alpha <alpha@alpha.com>
+alpha356 = Alpha <alpha@alpha.com>
+alpha357 = Alph6 <alpha@alpha.com>
+alpha358 = Alpha <alpha@alpha.com>
+alpha359 = Alpha <alpha@alpha.com>
+alpha360 = Alpha <alpha@alpha.com>
+alpha361 = Alpha <alpha@alpha.com>
+alpha362 = Alpha <alpha@alpha.com>
+alpha363 = Alpha <alpha@alpha.com>
+alpha364 = Alpha <alpha@alpha.com>
+alpha365 = Alpha <alpha@alpha.com>
+alpha366 = Alpha <alpha@alpha.com>
+alpha367 = Alph6 <alpha@alpha.com>
+alpha368 = Alpha <alpha@alpha.com>
+alpha639 = Alpha <alpha@alpha.com>
+alpha370 = Alpha <alpha@alpha.com>
+alpha371 = Alpha <alpha@alpha.com>
+alpha372 = Alpha <alpha@alpha.com>
+alpha373 = Alpha <alpha@alpha.com>
+alpha374 = Alpha <alpha@alpha.com>
+alpha375 = Alpha <alpha@alpha.com>
+alpha376 = Alpha <alpha@alpha.com>
+alpha377 = Alph6 <alpha@alpha.com>
+alpha738 = Alpha <alpha@alpha.com>
+alpha379 = Alpha <alpha@alpha.com>
+alpha380 = Alpha <alpha@alpha.com>
+alpha381 = Alpha <alpha@alpha.com>
+alpha382 = Alpha <alpha@alpha.com>
+alpha383 = Alpha <alpha@alpha.com>
+alpha384 = Alpha <alpha@alpha.com>
+alpha385 = Alpha <alpha@alpha.com>
+alpha386 = Alpha <alpha@alpha.com>
+alpha387 = Alpha <alpha@alpha.com>
+alpha388 = Alpha <alpha@alpha.com>
+alpha389 = Alpha <alpha@alpha.com>
+alpha390 = Alpha <alpha@alpha.com>
+alpha91 = Alpha <alpha@alpha.com>
+alph3a92 = Alpha <alpha@alpha.com>
+alph3a93 = Alpha <alpha@alpha.com>
+alph3a94 = Alpha <alpha@alpha.com>
+alph3a95 = Alpha <alpha@alpha.com>
+alph3a96 = Alpha <alpha@alpha.com>
+alph3a97 = Alpha <alpha@alpha.com>
+alph3a98 = Alpha <alpha@alpha.com>
+alpha99 = Alpha <alpha@alpha.com>
+dsadsakdoa = dksadosakfa <fallo@eample.org>
--- a/tests/test_fetch_mappings.py
+++ b/tests/test_fetch_mappings.py
@@ -9,6 +9,8 @@ from mercurial import node
 
 import test_util
 
+from hgsubversion import maps
+
 class MapTests(test_util.TestBase):
     @property
     def authors(self):
@@ -55,6 +57,18 @@ class MapTests(test_util.TestBase):
     def test_author_map_closing_author_stupid(self):
         self.test_author_map_closing_author(True)
 
+    def test_author_map_no_overwrite(self):
+        cwd = os.path.dirname(__file__)
+        orig = os.path.join(cwd, 'fixtures', 'author-map-test.txt')
+        new = open(self.authors, 'w')
+        new.write(open(orig).read())
+        new.close()
+        test = maps.AuthorMap(ui.ui(), self.authors)
+        fromself = set(test)
+        test.load(orig)
+        all = set(test)
+        self.assertEqual(fromself.symmetric_difference(all), set())
+
     def test_file_map(self, stupid=False):
         test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
         filemap = open(self.filemap, 'w')