# HG changeset patch # User Patrick Mezard # Date 1347195283 -7200 # Node ID d99ed94f476040aea5f2406a7278f675f06a0457 # Parent 3271fa883f3410746e74df8bf38104aa465bdc68 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. diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -249,8 +249,16 @@ def push(repo, dest, force, revs): 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() diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -491,6 +491,18 @@ class PushTests(test_util.TestBase): 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 = []