# HG changeset patch # User Peter Arrenbrecht # Date 1285242617 -7200 # Node ID efb87d5bb311c7aee4eeee4d86d2c04e5a38c7dd # Parent 467b95348e6aa1bdef7d2ede035a3458263fd61f subvertpy: fix bug with pushing changes to stuff in subdirs Seems one needs to call direditor.open_file(path) with a full path, not one that is relative to the direditor's directory. diff --git a/hgsubversion/svnwrap/subvertpy_wrapper.py b/hgsubversion/svnwrap/subvertpy_wrapper.py --- a/hgsubversion/svnwrap/subvertpy_wrapper.py +++ b/hgsubversion/svnwrap/subvertpy_wrapper.py @@ -360,21 +360,20 @@ class SubversionRepo(object): if directory and not path.startswith(directory + '/'): return pathidx - dirent = path[len(directory):].lstrip('/') pathidx += 1 if path in file_data: # visiting a file base_text, new_text, action = file_data[path] if action == 'modify': - fileeditor = editor.open_file(dirent, base_revision) + fileeditor = editor.open_file(path, base_revision) elif action == 'add': frompath, fromrev = copies.get(path, (None, -1)) if frompath: frompath = self.path2url(frompath) - fileeditor = editor.add_file(dirent, frompath, fromrev) + fileeditor = editor.add_file(path, frompath, fromrev) elif action == 'delete': - editor.delete_entry(dirent, base_revision) + editor.delete_entry(path, base_revision) continue else: assert False, 'invalid action \'%s\'' % action @@ -393,9 +392,9 @@ class SubversionRepo(object): else: # visiting a directory if path in addeddirs: - direditor = editor.add_directory(dirent) + direditor = editor.add_directory(path) elif path in deleteddirs: - direditor = editor.delete_entry(dirent, base_revision) + direditor = editor.delete_entry(path, base_revision) continue else: direditor = editor.open_directory(path) @@ -404,8 +403,7 @@ class SubversionRepo(object): for p, v in props[path].iteritems(): direditor.change_prop(p, v) - pathidx = visitdir(direditor, '/'.join((directory, dirent)), - paths, pathidx) + pathidx = visitdir(direditor, path, paths, pathidx) direditor.close() return pathidx diff --git a/tests/test_push_dirs.py b/tests/test_push_dirs.py --- a/tests/test_push_dirs.py +++ b/tests/test_push_dirs.py @@ -2,6 +2,10 @@ import test_util import unittest +from mercurial import context +from mercurial import hg +from mercurial import node + class TestPushDirectories(test_util.TestBase): def test_push_dirs(self): self._load_fixture_and_fetch('emptyrepo.svndump') @@ -79,6 +83,30 @@ class TestPushDirectories(test_util.Test self.pushrevisions() self.assertEqual(self.svnls('project/trunk'), ['a' ,]) + def test_push_single_dir_change_in_subdir(self): + # Tests simple pushing from default branch to a single dir repo + # Changes a file in a subdir (regression). + repo = self._load_fixture_and_fetch('branch_from_tag.svndump', + stupid=False, + layout='single', + subdir='tags') + def file_callback(repo, memctx, path): + return context.memfilectx(path=path, + data='foo', + islink=False, + isexec=False, + copied=False) + ctx = context.memctx(repo, + (repo['tip'].node(), node.nullid), + 'automated test', + ['tag_r3/alpha', 'tag_r3/new', 'new_dir/new'], + file_callback, + 'an_author', + '2009-10-19 18:49:30 -0500', + {'branch': 'default',}) + repo.commitctx(ctx) + hg.update(repo, repo['tip'].node()) + self.pushrevisions() def suite(): all = [unittest.TestLoader().loadTestsFromTestCase(TestPushDirectories),