mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
push: Fix missing directory creation for the case of a new dir inside a new dir.
This commit is contained in:
parent
235f4f8613
commit
5cb73e2d8d
25
push_cmd.py
25
push_cmd.py
@ -69,6 +69,24 @@ def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url, **opts):
|
||||
return 0
|
||||
|
||||
|
||||
def _findmissing(dirname, svn, branch_path):
|
||||
"""Find missing directories in svn. dirname *must* end in a /
|
||||
"""
|
||||
assert dirname[-1] == '/'
|
||||
missing = []
|
||||
keep_checking = True
|
||||
# check and see if the dir exists svn-side.
|
||||
path = dirname
|
||||
while keep_checking:
|
||||
try:
|
||||
assert svn.list_dir('%s/%s' % (branch_path, path))
|
||||
keep_checking = False
|
||||
except core.SubversionException, e:
|
||||
# dir must not exist
|
||||
missing.append(path[:-1])
|
||||
path = '/'.join(path.split('/')[:-2] + [''])
|
||||
return missing
|
||||
|
||||
def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision):
|
||||
"""Build and send a commit from Mercurial to Subversion.
|
||||
"""
|
||||
@ -99,12 +117,7 @@ def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision):
|
||||
dirname = '/'.join(file.split('/')[:-1] + [''])
|
||||
# check for new directories
|
||||
if not list(parent.walk(util.PrefixMatch(dirname))):
|
||||
# check and see if the dir exists svn-side.
|
||||
try:
|
||||
assert svn.list_dir('%s/%s' % (branch_path, dirname))
|
||||
except core.SubversionException, e:
|
||||
# dir must not exist
|
||||
added_dirs.append(dirname[:-1])
|
||||
added_dirs += _findmissing(dirname, svn, branch_path)
|
||||
else:
|
||||
base_data = parent.filectx(file).data()
|
||||
if ('x' in parent.filectx(file).flags()
|
||||
|
@ -328,6 +328,35 @@ class PushTests(unittest.TestCase):
|
||||
self.assertNotEqual(tip.node(), new_hash)
|
||||
self.assertEqual(tip['newdir/gamma'].data(), 'foo')
|
||||
|
||||
def test_push_with_new_subdir(self):
|
||||
self.test_push_to_default(commit=True)
|
||||
repo = self.repo
|
||||
def file_callback(repo, memctx, path):
|
||||
if path == 'newdir/subdir/gamma':
|
||||
return context.memfilectx(path=path,
|
||||
data='foo',
|
||||
islink=False,
|
||||
isexec=False,
|
||||
copied=False)
|
||||
raise IOError()
|
||||
ctx = context.memctx(repo,
|
||||
(repo['tip'].node(), node.nullid),
|
||||
'message',
|
||||
['newdir/subdir/gamma', ],
|
||||
file_callback,
|
||||
'author',
|
||||
'2008-10-29 21:26:00 -0500',
|
||||
{'branch': 'default', })
|
||||
new_hash = repo.commitctx(ctx)
|
||||
hg.update(repo, repo['tip'].node())
|
||||
push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
|
||||
hg_repo_path=self.wc_path,
|
||||
svn_url='file://' + self.repo_path)
|
||||
tip = self.repo['tip']
|
||||
self.assertNotEqual(tip.node(), new_hash)
|
||||
self.assertEqual(tip['newdir/subdir/gamma'].data(), 'foo')
|
||||
|
||||
|
||||
def test_push_existing_file_newly_symlink(self):
|
||||
self.test_push_existing_file_newly_execute(execute=False,
|
||||
link=True,
|
||||
|
Loading…
Reference in New Issue
Block a user