Problems with encoding against crew hg

Issue #67 wontfix
Anonymous created an issue

I'm assuming you want to do something with better compatibility here, though:

{{{

!diff

diff --git a/fetch_command.py b/fetch_command.py --- a/fetch_command.py +++ b/fetch_command.py @@ -7,6 +7,8 @@ from mercurial import context from mercurial import revlog from mercurial import util as merc_util +from mercurial import encoding + from svn import core from svn import delta

@@ -29,8 +31,8 @@ """pull new revisions from Subversion """ svn_url = util.normalize_url(svn_url) - old_encoding = merc_util._encoding - merc_util._encoding = 'UTF-8' + old_encoding = encoding.encoding + encoding.encoding = 'UTF-8' skipto_rev=int(skipto_rev) have_replay = not stupid if have_replay and not callable( @@ -107,7 +109,7 @@ ui.status('Got a 502, retrying (%s)\n' % tries) else: raise - merc_util._encoding = old_encoding + encoding.encoding = old_encoding fetch_revisions = util.register_subcommand('pull')(fetch_revisions)

}}}

Comments (17)

  1. Anonymous

    This fix breaks compatibility with mercurial 1.2 from debian testing package (1.2-1 as of 2009-04-08).

    Two questions:

    - Is it ok if I use revision 222:f2c65dd3d5c0 from default?

    - Do you think this fix is compatible with mercurial 1.2.1 from 2009-03-20?

    It seems you work on mercurial tip of default.

    It may perhaps be useful to work against a released version of mercurial (e.g. 1.2 or 1.2.1). This may help attracting developers using (and testing) hgsubversion.

    Grégoire

  2. Luke Opperman

    Grégoire -

    Could you include any output/traceback you get with 1.2.1? This fix (330f0) was actually intended to explicitly maintain compatibility with 1.2.1, I've just rechecked that tests & "hg svn pull" work on both 1.2.1 & mercurial-crew tip for me.

    Luke

  3. Daniel T

    This isn't on my dev box, so I haven't paid too much attention to it. With 1.2.1:

    $ hg svnclone --traceback http://soc.googlecode.com/svn/ melange-hg
    Traceback (most recent call last):
      File "/usr/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 41, in _runcatch
        return _dispatch(ui, args)
      File "/usr/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 372, in _dispatch
        return runcommand(lui, repo, cmd, fullargs, ui, options, d)
      File "/usr/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 247, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 417, in _runcommand
        return checkargs()
      File "/usr/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 377, in checkargs
        return cmdfunc()
      File "/usr/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 371, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/local/lib/python2.5/site-packages/mercurial/util.py", line 718, in check
        return func(*args, **kwargs)
      File "/home/dytang/code/hgsubversion/__init__.py", line 89, in svn_fetch
        res = svncommands.pull(ui, svn_url, hg_repo_path, **opts)
      File "/home/dytang/code/hgsubversion/svncommands.py", line 27, in pull
        old_encoding = util.swap_out_encoding()
      File "/home/dytang/code/hgsubversion/util.py", line 150, in swap_out_encoding
        old = encoding.encoding
      File "/usr/local/lib/python2.5/site-packages/mercurial/demandimport.py", line 75, in __getattribute__
        self._load()
      File "/usr/local/lib/python2.5/site-packages/mercurial/demandimport.py", line 47, in _load
        mod = _origimport(head, globals, locals)
    ImportError: No module named encoding
    abort: could not import module encoding!
    
    
  4. Daniel T

    Apparently it was also happening on my dev box, so I was more inclined to look at it sooner. The problem is (obviously) from demandimport. If demandimport is enabled, the try/except around encoding is in the wrong location. Patch is in my queue at http://bitbucket.org/saiyr/hgsubversion-mq/ and on the mailing list, though I'm not sure if my method is preferred over forcing the import at the top or not.

  5. Anonymous

    See "my" traceback below. Please be aware that debian testing uses mercurial 1.2 and not 1.2.1 (in the version "1.2-1" the "-1" is added by debian saying its the first patch of mercurial 1.2)

    $ hg --traceback svnclone https://scm/svn/cross-project/regression-testing/example-project gaga Traceback (most recent call last): File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 41, in _runcatch return _dispatch(ui, args) File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 372, in _dispatch return runcommand(lui, repo, cmd, fullargs, ui, options, d) File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 247, in runcommand ret = _runcommand(ui, options, cmd, d) File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 417, in _runcommand return checkargs() File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 377, in checkargs return cmdfunc() File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 371, in <lambda> d = lambda: util.checksignature(func)(ui, *args, cmdoptions) File "/var/lib/python-support/python2.5/mercurial/util.py", line 718, in check return func(*args, kwargs) File "/home/weber/mercurial-extensions/hgsubversion-default-232:c0063328587f/init.py", line 61, in svn_fetch res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, opts) File "/home/weber/mercurial-extensions/hgsubversion-default-c0063328587f/fetch_command.py", line 32, in fetch_revisions File "/home/weber/mercurial-extensions/hgsubversion-default-c0063328587f/util.py", line 150, in swap_out_encoding File "/var/lib/python-support/python2.5/mercurial/demandimport.py", line 75, in getattribute self._load() File "/var/lib/python-support/python2.5/mercurial/demandimport.py", line 47, in _load mod = _origimport(head, globals, locals) ImportError: No module named encoding Pleabort: could not import module encoding!

  6. Chia-Huan Wu

    This issue broke everything against Mercurial 1.2.1...

    $ hg svnclone http://python-nose.googlecode.com/svn/
    Assuming destination svn-hg
    abort: could not import module encoding!
    
    $ cd /my/proj/which/worked/fine/with/hgsubversion/before
    $ hg svn pull
    abort: could not import module encoding!
    
  7. Anonymous

    saiyr's fix looks correct, confirmed that it works on crew & 1.2.1, with & without demandimport enabled.

  8. Luke Opperman

    Anonymous was me, but after going back to hgsvn tip after trying out the fix I still can't reproduce the problem. Added

    from mercurial import demandimport; demandimport.enable()

    To try to trigger it, but with 1.2.1 I can't get this to fail with tip so now I'm stumped.

  9. Augie Fackler repo owner
    • changed status to open

    I can't confirm that saiyr's fix works, because I don't see the problem (for whatever reason). Can someone that's experiencing the problem try that patch and report back here?

  10. Log in to comment