Mercurial > hgsubversion
changeset 1229:46523cdfd3b0 stable 1.6.3
pushmod: prepend "link " to base text for links
http://svn.apache.org/viewvc?view=revision&revision=1223036 exposes
what is arguably a bug in hgsubversion push code. Specifically, when
we are receiving text from the server in an editor, we prepend a "link
" to the text of symlinks when opening a file and strip it when
closing a file. We don't, however, prepend "link " to the base we use
when sending text changes to the server.
This was working before because prior to that revision, the first
thing subversion did was to check whether the entirety of the before
text or the entirety of the after text was less than 64 bytes. In
that case, it just sent the entirety of the after text as a single
insert operation. I'd expect most, but not all symlinks to fit under
the 64 byte limit, including the leading "link " text on the
subversion end.
After the change, the first thing subversion does is check for a
leading match that is more than 4 bytes long, or that is the full
length of the after text. In this case, it sends a copy operation for
the leading match, and then goes into the if < 64 bytes remaining send
the whole thing behavior. It also looks for trailing matches of more
than 4 bytes even in the <64 byte case, but that's not what breaks the
tests.
Incidentally, changing the destination of long symlinks was broken
even before this subversion change. This diff includes test additions
that cover that breakage.
author | David Schleimer <dschleimer@gmail.com> |
---|---|
date | Thu, 07 Aug 2014 19:30:26 -0700 |
parents | 9819b4d6451e |
children | 807c443928d4 |
files | hgsubversion/pushmod.py tests/test_push_command.py |
diffstat | 2 files changed, 63 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/pushmod.py +++ b/hgsubversion/pushmod.py @@ -133,6 +133,8 @@ def commit(ui, repo, rev_ctx, meta, base # this kind of renames: a -> b, b -> c copies[file] = renamed[0] base_data = parent[renamed[0]].data() + if 'l' in parent[renamed[0]].flags(): + base_data = 'link ' + base_data else: autoprops = svn.autoprops_config.properties(file) if autoprops: @@ -145,9 +147,10 @@ def commit(ui, repo, rev_ctx, meta, base if ('x' in parent.filectx(file).flags() and 'x' not in rev_ctx.filectx(file).flags()): props.setdefault(file, {})['svn:executable'] = None - if ('l' in parent.filectx(file).flags() - and 'l' not in rev_ctx.filectx(file).flags()): - props.setdefault(file, {})['svn:special'] = None + if 'l' in parent.filectx(file).flags(): + base_data = 'link ' + base_data + if 'l' not in rev_ctx.filectx(file).flags(): + props.setdefault(file, {})['svn:special'] = None if hgutil.binary(base_data) and not isbinary: props.setdefault(file, {})['svn:mime-type'] = None action = 'modify'
--- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -445,13 +445,69 @@ class PushTests(test_util.TestBase): new_hash = repo.commitctx(ctx) hg.update(repo, repo['tip'].node()) self.pushrevisions() - tip = self.repo['tip'] + # grab a new repo instance (self.repo is an @property functions) + repo = self.repo + tip = repo['tip'] self.assertNotEqual(tip.node(), new_hash) self.assertEqual(tip['gamma'].flags(), 'l') self.assertEqual(tip['gamma'].data(), 'foo') self.assertEqual([x for x in tip.manifest().keys() if 'l' not in tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) + def file_callback2(repo, memctx, path): + if path == 'gamma': + return compathacks.makememfilectx(repo, + path=path, + data='a' * 129, + islink=True, + isexec=False, + copied=False) + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) + + ctx = context.memctx(repo, + (repo['tip'].node(), node.nullid), + 'message', + ['gamma', ], + file_callback2, + 'author', + '2014-08-08 20:11:41 -0700', + {'branch': 'default', }) + repo.commitctx(ctx) + hg.update(repo, repo['tip'].node()) + self.pushrevisions() + # grab a new repo instance (self.repo is an @property functions) + repo = self.repo + tip = repo['tip'] + self.assertEqual(tip['gamma'].flags(), 'l') + self.assertEqual(tip['gamma'].data(), 'a'*129) + + def file_callback3(repo, memctx, path): + if path == 'gamma': + return compathacks.makememfilectx(repo, + path=path, + data='a' * 64 + 'b' * 65, + islink=True, + isexec=False, + copied=False) + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) + + ctx = context.memctx(repo, + (repo['tip'].node(), node.nullid), + 'message', + ['gamma', ], + file_callback3, + 'author', + '2014-08-08 20:16:25 -0700', + {'branch': 'default', }) + repo.commitctx(ctx) + hg.update(repo, repo['tip'].node()) + self.pushrevisions() + repo = self.repo + tip = repo['tip'] + self.assertEqual(tip['gamma'].flags(), 'l') + self.assertEqual(tip['gamma'].data(), 'a' * 64 + 'b' * 65) + + def test_push_existing_file_newly_symlink(self): self.test_push_existing_file_newly_execute(execute=False, link=True,