Mercurial > hgsubversion
changeset 223:330f0b15d417
issue67: mercurial 1.3 util incompatibility with encoding swap
author | Luke Opperman <luke@loppear.com> |
---|---|
date | Tue, 07 Apr 2009 13:30:05 -0500 |
parents | f2c65dd3d5c0 |
children | f71af18c4379 |
files | fetch_command.py push_cmd.py util.py |
diffstat | 3 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/fetch_command.py +++ b/fetch_command.py @@ -29,8 +29,7 @@ def fetch_revisions(ui, svn_url, hg_repo """pull new revisions from Subversion """ svn_url = util.normalize_url(svn_url) - old_encoding = merc_util._encoding - merc_util._encoding = 'UTF-8' + old_encoding = util.swap_out_encoding() skipto_rev=int(skipto_rev) have_replay = not stupid if have_replay and not callable( @@ -107,7 +106,8 @@ def fetch_revisions(ui, svn_url, hg_repo ui.status('Got a 502, retrying (%s)\n' % tries) else: raise - merc_util._encoding = old_encoding + util.swap_out_encoding(old_encoding) + fetch_revisions = util.register_subcommand('pull')(fetch_revisions)
--- a/push_cmd.py +++ b/push_cmd.py @@ -24,8 +24,7 @@ def push_revisions_to_subversion(ui, rep stupid=False, **opts): """push revisions starting at a specified head back to Subversion. """ - oldencoding = merc_util._encoding - merc_util._encoding = 'UTF-8' + old_encoding = util.swap_out_encoding() hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), @@ -101,7 +100,7 @@ def push_revisions_to_subversion(ui, rep rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid))) hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) - merc_util._encoding = oldencoding + util.swap_out_encoding(old_encoding) return 0 push_revisions_to_subversion = util.register_subcommand('push')(push_revisions_to_subversion) # for git expats
--- a/util.py +++ b/util.py @@ -4,6 +4,10 @@ import shutil from mercurial import hg from mercurial import node from mercurial import util +try: + from mercurial import encoding +except ImportError: + encoding = None svn_subcommands = { } def register_subcommand(name): @@ -135,3 +139,14 @@ def describe_revision(ui, r): def describe_commit(ui, h, b): ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h))) + + +def swap_out_encoding(new_encoding="UTF-8"): + """ Utility for mercurial incompatibility changes, can be removed after 1.3""" + if encoding is None: + old = util._encoding + util._encoding = new_encoding + else: + old = encoding.encoding + encoding.encoding = new_encoding + return old