def test_push_single_dir_renamed_branch(self, stupid=False): # Tests pulling and pushing with a renamed branch # Based on test_push_single_dir test_util.load_svndump_fixture(self.repo_path, 'branch_from_tag.svndump') cmd = ['clone', '--layout=single', '--branch=flaf'] if stupid: cmd.append('--stupid') cmd += [test_util.fileurl(self.repo_path), self.wc_path] dispatch.dispatch(cmd) def file_callback(repo, memctx, path): if path == 'adding_file': return context.memfilectx(path=path, data='foo', islink=False, isexec=False, copied=False) raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(self.repo, (self.repo['tip'].node(), node.nullid), 'automated test', ['adding_file'], file_callback, 'an_author', '2009-10-19 18:49:30 -0500', {'branch': 'default',}) self.repo.commitctx(ctx) hg.update(self.repo, self.repo['tip'].node()) self.pushrevisions() self.assertTrue('adding_file' in self.svnls('')) self.assertEquals(set(['flaf']), set(self.repo[i].branch() for i in self.repo))
def internal_push_over_svnserve(self, subdir='', commit=True): test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'), 'w').write('[general]\nanon-access=write\n[sasl]\n') self.port = random.randint(socket.IPPORT_USERRESERVED, 65535) self.host = 'localhost' args = ['svnserve', '--daemon', '--foreground', '--listen-port=%d' % self.port, '--listen-host=%s' % self.host, '--root=%s' % self.repo_path] svnserve = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.svnserve_pid = svnserve.pid try: time.sleep(2) import shutil shutil.rmtree(self.wc_path) commands.clone(self.ui(), 'svn://%s:%d/%s' % (self.host, self.port, subdir), self.wc_path, noupdate=True) repo = self.repo old_tip = repo['tip'].node() expected_parent = repo['default'].node() def file_callback(repo, memctx, path): if path == 'adding_file': return context.memfilectx(path=path, data='foo', islink=False, isexec=False, copied=False) raise IOError(errno.EINVAL, 'Invalid operation: ' + path) ctx = context.memctx(repo, parents=(repo['default'].node(), node.nullid), text='automated test', files=['adding_file'], filectxfn=file_callback, user='******', date='2008-10-07 20:59:48 -0500', extra={'branch': 'default',}) new_hash = repo.commitctx(ctx) if not commit: return # some tests use this test as an extended setup. hg.update(repo, repo['tip'].node()) oldauthor = repo['tip'].user() commands.push(repo.ui, repo) tip = self.repo['tip'] self.assertNotEqual(oldauthor, tip.user()) self.assertNotEqual(tip.node(), old_tip) self.assertEqual(tip.parents()[0].node(), expected_parent) self.assertEqual(tip['adding_file'].data(), 'foo') self.assertEqual(tip.branch(), 'default') # unintended behaviour: self.assertNotEqual('an_author', tip.user()) self.assertEqual('(no author)', tip.user().rsplit('@', 1)[0]) finally: # TODO: use svnserve.kill() in Python >2.5 test_util.kill_process(svnserve)
def test_list_authors_map(self): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') author_path = os.path.join(self.repo_path, 'authors') svncommands.listauthors(self.ui(), args=[test_util.fileurl(self.repo_path)], authors=author_path) self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n')
def test_list_authors(self): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') u = self.ui() u.pushbuffer() svncommands.listauthors(u, args=[test_util.fileurl(self.repo_path)], authors=None) actual = u.popbuffer() self.assertEqual(actual, 'Augie\nevil\n')
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 = self.ui(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_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 = self.ui(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_quoting(self): ui = self.ui() test_util.load_svndump_fixture(self.repo_path, 'non_ascii_path_1.svndump') repo_url = test_util.fileurl(self.repo_path) subdir = '/b\xC3\xB8b' quoted_subdir = urllib.quote(subdir) repo1 = svnrepo.svnremoterepo(ui, repo_url + subdir) repo2 = svnrepo.svnremoterepo(ui, repo_url + quoted_subdir) self.assertEqual(repo1.svnurl, repo2.svnurl)
def test_branchmap_empty_commit(self, stupid=False): '''test mapping an empty commit on a renamed branch''' test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("the-branch = bob\n") branchmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'branchmap', self.branchmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, branchmap=self.branchmap) branches = set(self.repo[i].branch() for i in self.repo) self.assertEquals(sorted(branches), ['bob', 'default'])
def test_branchmap_tagging(self, stupid=False): '''test tagging a renamed branch, which used to raise an exception''' test_util.load_svndump_fixture(self.repo_path, 'commit-to-tag.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("magic = art\n") branchmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'branchmap', self.branchmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, branchmap=self.branchmap) branches = set(self.repo[i].branch() for i in self.repo) self.assertEquals(sorted(branches), ['art', 'closeme'])
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 = self.ui(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_branchmap_no_replacement(self): ''' test that empty mappings are rejected Empty mappings are lines like 'this ='. The most sensible thing to do is to not convert the 'this' branches. Until we can do that, we settle with aborting. ''' test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("closeme =\n") branchmap.close() self.assertRaises(hgutil.Abort, maps.BranchMap, self.ui(), self.branchmap)
def test_tagren_changed(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'commit-to-tag.svndump') tagmap = open(self.tagmap, 'w') tagmap.write("edit-at-create = edit-past\n") tagmap.write("also-edit = \n") tagmap.write("will-edit = edit-future\n") tagmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'tagmap', self.tagmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, tagmap=self.tagmap) tags = self.repo.tags()
def test_branchmap(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("badname = good-name # stuffy\n") branchmap.write("feature = default\n") branchmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'branchmap', self.branchmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, branchmap=self.branchmap) branches = set(self.repo[i].branch() for i in self.repo) self.assert_('badname' not in branches) self.assert_('good-name' in branches) self.assertEquals(self.repo[2].branch(), 'default')
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 <*****@*****.**> # stuffy\n') authormap.write("Augie Fackler <*****@*****.**>\n") authormap.close() ui = self.ui(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 <*****@*****.**>') self.assertEqual(self.repo['tip'].user(), 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
def test_branchmap_verify(self, stupid=False): '''test verify on a branchmapped clone''' test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("badname = dit\n") branchmap.write("feature = dah\n") branchmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'branchmap', self.branchmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, branchmap=self.branchmap) repo = self.repo for r in repo: self.assertEquals(svncommands.verify(ui, repo, rev=r), 0)
def test_tagmap(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'basic_tag_tests.svndump') tagmap = open(self.tagmap, 'w') tagmap.write("tag_r3 = 3.x # stuffy\n") tagmap.write("copied_tag = \n") tagmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'tagmap', self.tagmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, tagmap=self.tagmap) tags = self.repo.tags() assert 'tag_r3' not in tags assert '3.x' in tags assert 'copied_tag' not in tags
def test_file_map_rule_order(self): test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') filemap = open(self.filemap, 'w') filemap.write("exclude alpha\n") filemap.write("include .\n") filemap.write("exclude gamma\n") filemap.close() ui = self.ui(False) ui.setconfig('hgsubversion', 'filemap', self.filemap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, filemap=self.filemap) # The exclusion of alpha is overridden by the later rule to # include all of '.', whereas gamma should remain excluded # because it's excluded after the root directory. self.assertEqual(self.repo[0].manifest().keys(), ['alpha', 'beta']) self.assertEqual(self.repo['default'].manifest().keys(), ['alpha', 'beta'])
def test_truncated_history(self, stupid=False): # Test repository does not follow the usual layout test_util.load_svndump_fixture(self.repo_path, 'truncatedhistory.svndump') svn_url = test_util.fileurl(self.repo_path + '/project2') commands.clone(self.ui(stupid), svn_url, self.wc_path, noupdate=True) repo = hg.repository(self.ui(stupid), self.wc_path) # We are converting /project2/trunk coming from: # # Changed paths: # D /project1 # A /project2/trunk (from /project1:2) # # Here a full fetch should be performed since we are starting # the conversion on an already filled branch. tip = repo['tip'] files = tip.manifest().keys() files.sort() self.assertEqual(files, ['a', 'b']) self.assertEqual(repo['tip']['a'].data(), 'a\n')
def test_branchmap_combine(self, stupid=False): '''test combining two branches, but retaining heads''' test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("badname = default\n") branchmap.write("feature = default\n") branchmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'branchmap', self.branchmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, branchmap=self.branchmap) branches = set(self.repo[i].branch() for i in self.repo) self.assertEquals(sorted(branches), ['default']) self.assertEquals(len(self.repo.heads()), 2) self.assertEquals(len(self.repo.branchheads('default')), 2) # test that the mapping does not affect branch info branches = self.repo.svnmeta().branches self.assertEquals(sorted(branches.keys()), [None, 'badname', 'feature'])
def test_path_quoting(self, stupid=False): test_util.load_svndump_fixture(self.repo_path, 'non_ascii_path_1.svndump') subdir = '/b\xC3\xB8b' quoted_subdir = urllib.quote(subdir) repo_url = test_util.fileurl(self.repo_path) wc_path = self.wc_path wc2_path = wc_path + '-2' ui = self.ui(stupid=stupid) commands.clone(ui, repo_url + subdir, wc_path) commands.clone(ui, repo_url + quoted_subdir, wc2_path) repo = hg.repository(ui, wc_path) repo2 = hg.repository(ui, wc2_path) self.assertEqual(repo['tip'].extra()['convert_revision'], repo2['tip'].extra()['convert_revision']) self.assertEqual(len(repo), len(repo2)) for r in repo: self.assertEqual(repo[r].hex(), repo2[r].hex())
def test_branchmap_rebuildmeta(self, stupid=False): '''test rebuildmeta on a branchmapped clone''' test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') branchmap = open(self.branchmap, 'w') branchmap.write("badname = dit\n") branchmap.write("feature = dah\n") branchmap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'branchmap', self.branchmap) commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path, branchmap=self.branchmap) originfo = self.repo.svnmeta().branches # clone & rebuild ui = self.ui(stupid) src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone', update=False) svncommands.rebuildmeta(ui, dest, args=[test_util.fileurl(self.repo_path)]) # just check the keys; assume the contents are unaffected by the branch # map and thus properly tested by other tests self.assertEquals(sorted(src.svnmeta().branches), sorted(dest.svnmeta().branches))
def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor): test_util.load_svndump_fixture(self.repo_path, fixture_name) source = '%s#%s' % (test_util.fileurl(self.repo_path), anchor) repo = hg.clone(self.ui(), source=source, dest=self.wc_path) return hg.repository(self.ui(), self.wc_path)