comparison tests/test_fetch_mappings.py @ 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 27e9fea5d114
children 8e025a6f0db4
comparison
equal deleted inserted replaced
429:a5a475dced59 430:2851b81c65ce
6 from mercurial import commands 6 from mercurial import commands
7 from mercurial import ui 7 from mercurial import ui
8 from mercurial import node 8 from mercurial import node
9 9
10 import test_util 10 import test_util
11
12 from hgsubversion import maps
11 13
12 class MapTests(test_util.TestBase): 14 class MapTests(test_util.TestBase):
13 @property 15 @property
14 def authors(self): 16 def authors(self):
15 return os.path.join(self.tmpdir, 'authormap') 17 return os.path.join(self.tmpdir, 'authormap')
53 'Testy <test@test>') 55 'Testy <test@test>')
54 56
55 def test_author_map_closing_author_stupid(self): 57 def test_author_map_closing_author_stupid(self):
56 self.test_author_map_closing_author(True) 58 self.test_author_map_closing_author(True)
57 59
60 def test_author_map_no_overwrite(self):
61 cwd = os.path.dirname(__file__)
62 orig = os.path.join(cwd, 'fixtures', 'author-map-test.txt')
63 new = open(self.authors, 'w')
64 new.write(open(orig).read())
65 new.close()
66 test = maps.AuthorMap(ui.ui(), self.authors)
67 fromself = set(test)
68 test.load(orig)
69 all = set(test)
70 self.assertEqual(fromself.symmetric_difference(all), set())
71
58 def test_file_map(self, stupid=False): 72 def test_file_map(self, stupid=False):
59 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 73 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
60 filemap = open(self.filemap, 'w') 74 filemap = open(self.filemap, 'w')
61 filemap.write("include alpha\n") 75 filemap.write("include alpha\n")
62 filemap.close() 76 filemap.close()