Mercurial > hgsubversion
view tests/test_fetch_mappings.py @ 469:5567af673f83
Revive svn+http(s) URLs support (issue94)
Telling svn from mercurial repository automatically is not always possible, or
at least not seamlessly. Let 'http://repo.com/svn' be an svn repository,
protected with basic authentication. Trying to clone it directly does something
like:
1- Open it like a mercurial repository:
* send between command, ask for credentials, fail
* fallback to static-http, ask for crendentials two times, fail
2- Open it like an svn repository
Mercurial [auth] facility is helpful here, but few people know about it, and it
may seem weird to store svn credentials in mercurial configuration. An svn-like
password manager would not help either because all connections attempts in [1]
fail and it's unlikely we would store credentials in this situation. Instead,
we can clone 'svn+http://repo.com/svn', which will skip step [1].
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 18 Jul 2009 20:44:33 -0500 |
parents | 2851b81c65ce |
children | 8e025a6f0db4 |
line wrap: on
line source
"""Tests for author maps and file maps. """ import os import unittest from mercurial import commands from mercurial import ui from mercurial import node import test_util from hgsubversion import maps class MapTests(test_util.TestBase): @property def authors(self): return os.path.join(self.tmpdir, 'authormap') @property def filemap(self): return os.path.join(self.tmpdir, 'filemap') def test_author_map(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') authormap = open(self.authors, 'w') authormap.write('Augie=Augie Fackler <durin42@gmail.com> # stuffy\n') authormap.write("Augie Fackler <durin42@gmail.com>\n") authormap.close() _ui = ui.ui() _ui.setconfig('hgsubversion', 'stupid', str(stupid)) _ui.setconfig('hgsubversion', 'authormap', self.authors) commands.clone(_ui, test_util.fileurl(self.repo_path), self.wc_path, authors=self.authors) self.assertEqual(self.repo[0].user(), 'Augie Fackler <durin42@gmail.com>') self.assertEqual(self.repo['tip'].user(), 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') def test_author_map_stupid(self): self.test_author_map(True) def test_author_map_closing_author(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') authormap = open(self.authors, 'w') authormap.write("evil=Testy <test@test>") authormap.close() _ui = ui.ui() _ui.setconfig('hgsubversion', 'stupid', str(stupid)) _ui.setconfig('hgsubversion', 'authormap', self.authors) commands.clone(_ui, test_util.fileurl(self.repo_path), self.wc_path, authors=self.authors) self.assertEqual(self.repo[0].user(), 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') self.assertEqual(self.repo['tip'].user(), 'Testy <test@test>') 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') filemap.write("include alpha\n") filemap.close() _ui = ui.ui() _ui.setconfig('hgsubversion', 'stupid', str(stupid)) _ui.setconfig('hgsubversion', 'filemap', self.filemap) commands.clone(_ui, test_util.fileurl(self.repo_path), self.wc_path, filemap=self.filemap) self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') def test_file_map_stupid(self): self.test_file_map(True) def test_file_map_exclude(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') filemap = open(self.filemap, 'w') filemap.write("exclude alpha\n") filemap.close() _ui = ui.ui() _ui.setconfig('hgsubversion', 'stupid', str(stupid)) _ui.setconfig('hgsubversion', 'filemap', self.filemap) commands.clone(_ui, test_util.fileurl(self.repo_path), self.wc_path, filemap=self.filemap) self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') def test_file_map_exclude_stupid(self): self.test_file_map_exclude(True) def suite(): return unittest.TestLoader().loadTestsFromTestCase(MapTests)