Commits

Patrick Mézard committed d99ed94

wrappers: do not change encoding when pushing

This causes problems on platforms where the encoding is actually different,
if the manifest contains a path which no longer matches the checkout, a
following bailifchanged() actually fails.

This happens on Windows with a repository containing UTF-8 encoded filenames
checked out on a cp1252 environment.

  • Participants
  • Parent commits 3271fa8

Comments (0)

Files changed (2)

hgsubversion/wrappers.py

                         return
                     extra['branch'] = ctx.branch()
                 # TODO: can we avoid calling our own rebase wrapper here?
-                rebase(hgrebase.rebase, ui, repo, svn=True, svnextrafn=extrafn,
-                       svnsourcerev=needs_transplant)
+                # Tweaking the encoding is fine for internal
+                # manipulations, but it can lead to various breakage
+                # when starting to operate with the working directory
+                # and the dirstate.
+                util.swap_out_encoding(old_encoding)
+                try:
+                    rebase(hgrebase.rebase, ui, repo, svn=True,
+                           svnextrafn=extrafn, svnsourcerev=needs_transplant)
+                finally:
+                    util.swap_out_encoding()
                 # Reload the repo after the rebase. Do not reuse
                 # contexts across this.
                 newtip = newtipctx.node()

tests/test_push_command.py

             self.assertEqual([], os.listdir(
                 os.path.join(self.tmpdir, 'testrepo-1', 'db', 'transactions')))
 
+    def test_push_encoding(self):
+        self.test_push_two_revs()
+        # Writing then rebasing UTF-8 filenames in a cp1252 windows console
+        # used to fail because hg internal encoding was being changed during
+        # the interactions with subversion, *and during the rebase*, which
+        # confused the dirstate and made it believe the file was deleted.
+        fn = 'pi\xc3\xa8ce/test'
+        changes = [(fn, fn, 'a')]
+        par = self.repo['tip'].rev()
+        self.commitchanges(changes, parent=par)
+        self.pushrevisions()
+
 def suite():
     test_classes = [PushTests, ]
     all_tests = []