changeset 1235:6b15eeb78c1a

editor: fix replay handling for copied + modified symlinks We strip the 'link ' prefix from symlinks when we store it in Mercurial. We reapply it when we start editing the file via open_file, but not via add_file. this means that modified symlniks would replay correctly, but not copied and modified symlinks. This corrects that ommission.
author David Schleimer <dschleimer@fb.com>
date Mon, 07 Apr 2014 18:44:46 -0700
parents d3c79072bc6a
children f367a4462191
files hgsubversion/editor.py tests/test_fetch_renames.py
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/editor.py
+++ b/hgsubversion/editor.py
@@ -380,7 +380,10 @@ class HgEditor(svnwrap.Editor):
 
         fctx = ctx.filectx(from_file)
         flags = fctx.flags()
-        self.current.set(path, fctx.data(), 'x' in flags, 'l' in flags)
+        base = fctx.data()
+        if 'l' in flags:
+            base = 'link ' + base
+        self.current.set(path, base, 'x' in flags, 'l' in flags)
         copypath = None
         if from_branch == branch:
             parentid = self.meta.get_parent_revision(
@@ -389,7 +392,7 @@ class HgEditor(svnwrap.Editor):
                 parentctx = self._getctx(parentid)
                 if util.issamefile(parentctx, ctx, from_file):
                     copypath = from_file
-        return self._openfile(path, fctx.data(), 'x' in flags, 'l' in flags,
+        return self._openfile(path, base, 'x' in flags, 'l' in flags,
                 copypath, create=True)
 
     @svnwrap.ieditor
--- a/tests/test_fetch_renames.py
+++ b/tests/test_fetch_renames.py
@@ -18,6 +18,10 @@ class TestFetchRenames(test_util.TestBas
     def test_rename(self):
         config = {
             'hgsubversion.filestoresize': '0',
+            # we set this because we expect all of the copies to be
+            # handled via replay, and we want to notice if that
+            # changes.
+            'hgsubversion.failonmissing': 'yes',
             }
         repo = self._load_fixture_and_fetch('renames.svndump', config=config)
         self._run_assertions(repo)
@@ -25,6 +29,7 @@ class TestFetchRenames(test_util.TestBas
     def test_rename_with_prefix(self):
         config = {
             'hgsubversion.filestoresize': '0',
+            'hgsubversion.failonmissing': 'yes',
             }
         repo = self._load_fixture_and_fetch('renames_with_prefix.svndump',
                                             subdir='prefix',