Issue #402 resolved

Getting "abort: No module named hgsubversion!" when pulling

artem_astafyev
created an issue

There is also thread on stackoverflow. Provided solution to revert to c6e9889dba27 works for me.

Comments (31)

  1. Greg Ward

    I get the same error. Here's the traceback:

    $ HGRCPATH='' hg --config extensions.hgsubversion=~/src/hgsubversion/hgsubversion pull --traceback
    pulling from svn+ssh://svn@svn.example.com/.../trunk
    Traceback (most recent call last):
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 97, in _runcatch
        return _dispatch(req)
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 778, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 549, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 869, in _runcommand
        return checkargs()
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 840, in checkargs
        return cmdfunc()
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 775, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/local/mercurial-2.6/mercurial/util.py", line 506, in check
        return func(*args, **kwargs)
      File "/usr/local/mercurial-2.6/mercurial/extensions.py", line 143, in wrap
        util.checksignature(origfn), *args, **kwargs)
      File "/usr/local/mercurial-2.6/mercurial/util.py", line 506, in check
        return func(*args, **kwargs)
      File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 625, in generic
        return orig(ui, repo, *args, **opts)
      File "/usr/local/mercurial-2.6/mercurial/util.py", line 506, in check
        return func(*args, **kwargs)
      File "/usr/local/mercurial-2.6/mercurial/commands.py", line 4559, in pull
        modheads = repo.pull(other, heads=revs, force=opts.get('force'))
      File "/home/gward/src/hgsubversion/hgsubversion/svnrepo.py", line 81, in wrapper
        return fn(self, *args, **opts)
      File "/home/gward/src/hgsubversion/hgsubversion/svnrepo.py", line 104, in pull
        return wrappers.pull(self, remote, heads, force)
      File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 352, in pull
        meta = repo.svnmeta(svn.uuid, svn.subdir)
      File "/home/gward/src/hgsubversion/hgsubversion/svnrepo.py", line 111, in svnmeta
        return svnmeta.SVNMeta(self, uuid, subdir)
      File "/home/gward/src/hgsubversion/hgsubversion/svnmeta.py", line 50, in __init__
        self._layout = layouts.detect.layout_from_file(self.meta_data_dir,
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 86, in __getattribute__
        self._load()
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 58, in _load
        mod = _origimport(head, globals, locals)
      File "/home/gward/src/hgsubversion/hgsubversion/layouts/__init__.py", line 30, in <module>
        "standard": standard.StandardLayout,
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 86, in __getattribute__
        self._load()
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 58, in _load
        mod = _origimport(head, globals, locals)
      File "/home/gward/src/hgsubversion/hgsubversion/layouts/standard.py", line 5, in <module>
        import hgsubversion.util as util
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 86, in __getattribute__
        self._load()
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 58, in _load
        mod = _origimport(head, globals, locals)
    ImportError: No module named hgsubversion
    abort: No module named hgsubversion!
    

    I get a similar error when cloning that repo as well:

    $ HGRCPATH='' hg --traceback --config extensions.hgsubversion=~/src/hgsubversion/hgsubversion clone svn+ssh://svn@svn.example.com/.../trunk
    Traceback (most recent call last):
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 97, in _runcatch
        return _dispatch(req)
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 778, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 549, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 869, in _runcommand
        return checkargs()
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 840, in checkargs
        return cmdfunc()
      File "/usr/local/mercurial-2.6/mercurial/dispatch.py", line 775, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/local/mercurial-2.6/mercurial/util.py", line 506, in check
        return func(*args, **kwargs)
      File "/usr/local/mercurial-2.6/mercurial/extensions.py", line 143, in wrap
        util.checksignature(origfn), *args, **kwargs)
      File "/usr/local/mercurial-2.6/mercurial/util.py", line 506, in check
        return func(*args, **kwargs)
      File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 582, in clone
        orig(ui, source, dest, **opts)
      File "/usr/local/mercurial-2.6/mercurial/util.py", line 506, in check
        return func(*args, **kwargs)
      File "/usr/local/mercurial-2.6/mercurial/commands.py", line 1264, in clone
        branch=opts.get('branch'))
      File "/usr/local/mercurial-2.6/mercurial/extensions.py", line 188, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 571, in hgclonewrapper
        data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
      File "/usr/local/mercurial-2.6/mercurial/hg.py", line 372, in clone
        destpeer.local().clone(srcpeer, heads=revs, stream=stream)
      File "/usr/local/mercurial-2.6/mercurial/localrepo.py", line 2558, in clone
        return self.pull(remote, heads)
      File "/home/gward/src/hgsubversion/hgsubversion/svnrepo.py", line 81, in wrapper
        return fn(self, *args, **opts)
      File "/home/gward/src/hgsubversion/hgsubversion/svnrepo.py", line 104, in pull
        return wrappers.pull(self, remote, heads, force)
      File "/home/gward/src/hgsubversion/hgsubversion/wrappers.py", line 352, in pull
        meta = repo.svnmeta(svn.uuid, svn.subdir)
      File "/home/gward/src/hgsubversion/hgsubversion/svnrepo.py", line 111, in svnmeta
        return svnmeta.SVNMeta(self, uuid, subdir)
      File "/home/gward/src/hgsubversion/hgsubversion/svnmeta.py", line 50, in __init__
        self._layout = layouts.detect.layout_from_file(self.meta_data_dir,
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 86, in __getattribute__
        self._load()
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 58, in _load
        mod = _origimport(head, globals, locals)
      File "/home/gward/src/hgsubversion/hgsubversion/layouts/__init__.py", line 30, in <module>
        "standard": standard.StandardLayout,
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 86, in __getattribute__
        self._load()
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 58, in _load
        mod = _origimport(head, globals, locals)
      File "/home/gward/src/hgsubversion/hgsubversion/layouts/standard.py", line 5, in <module>
        import hgsubversion.util as util
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 86, in __getattribute__
        self._load()
      File "/usr/local/mercurial-2.6/mercurial/demandimport.py", line 58, in _load
        mod = _origimport(head, globals, locals)
    ImportError: No module named hgsubversion
    abort: No module named hgsubversion!
    

    It appears that hgsubversion assumes it's in sys.path, which isn't necessarily so. Workaround: put it there, e.g.

    $ PYTHONPATH=~/src/hgsubversion HGRCPATH='' hg --traceback --config extensions.hgsubversion= clone svn+ssh://svn@svn.example.com/.../trunk
    

    Of course I have to set PYTHONPATH for every hg command that tickles hgsubversion. Grumble.

  2. Greg Ward

    Bisection reveals this changeset as the culprit:

    The first bad revision is:
    changeset:   1022:1c9b1d0e0ba3
    user:        Vladimir Zakharov <zakharov.vv@gmail.com>
    date:        Thu Jun 20 15:07:19 2013 +0400
    summary:     layouts: fix failure for nonexistent SVN paths
    

    Note that appears to be a fix for an earlier regression. ;-( I tried backing out 1c9b1d0e0ba3 and the problem does NOT go away. Hmmmmm.

    I'm using f67f9d28b0ac, the first parent of 1c9b1d0e0ba3, and hgsubversion seems OK. Clone and pull both work, at any rate.

  3. Augie Fackler repo owner

    I bet this has to do with not installing hgsubversion. Perhaps 'python setup.py develop' would be your friend here?

    Given the way we want to organize code, I'm not sure we can do any better than the status quo. I'm open to ideas.

  4. artem_astafyev reporter

    Updated to tip:

    hgsubversion>hg sum
    parent: 1037:2316f2623dd4 tip
     Fix for missing mercurial.utils deque
    branch: default
    commit: 19 unknown (clean)
    update: (current)
    

    Trying to pull:

    >hg pull
    pulling from svn+https://mysvnrepository.com/svn/WFP/trunk
    abort: No module named hgsubversion!
    

    Reverting hgsubversion to 1.5:

    hgsubversion>hg sum
    parent: 971:77b22e5b4ea6 1.5
     svn_swig_wrapper: Ensure subversion config files
    branch: default
    commit: 19 unknown (clean)
    update: 66 new changesets (update)
    

    Trying to pull from SVN again, all works fine. So it doesn't look like problem with hgsubversion installation.

  5. Ewen Wallace

    Confirm Greg Ward's method.

    I'm using f67f9d28b0ac, the first parent of 1c9b1d0e0ba3, and hgsubversion seems OK. Clone and pull both work, at any rate.
    
  6. Greg Ward

    [from Augie on Aug 2]

    I bet this has to do with not installing hgsubversion. Perhaps 'python setup.py develop' would be your friend here?

    1) No other hg extension that I'm aware of requires installation -- it's enough just to edit .hg/hgrc to point to the extension

    2) It worked fine before rev 1c9b1d0e0ba3

    3) Use relative imports? The patch below should work with Python 2.5 or later.

    --- a/hgsubversion/layouts/detect.py
    +++ b/hgsubversion/layouts/detect.py
    @@ -6,11 +6,13 @@
    
     """
    
    +from __future__ import absolute_import
    +
     import os.path
    
     from mercurial import util as hgutil
    
    -from hgsubversion import svnwrap
    +from .. import svnwrap
    
     def layout_from_subversion(svn, revision=None, ui=None):
         """ Guess what layout to use based on directories under the svn root.
    

    Quick and dirty manual testing indicates that that works for me on one box running Python 2.7. Not sure what to do for 2.4 compatibility.

  7. Ewen Wallace

    Confirm Greg Ward's patch seems to work on my installation (...until the Corporate Productivity Firewall blocks SVN but that's a local issue.)

    As for "setup", perhaps installation documentation would be your friend here? </snark>

  8. Augie Fackler repo owner

    The snark isn't really helpful.

    I'm trying to find a solution that makes as many people as possible happy. I'm caught between:

    1) Making the code less well organized 2) Supporting python 2.4 3) Using relative imports

    I'm most inclined towards 3, but I don't have any sense of how many users I'm screwing in the process.

    Then again, I've wanted to ditch 2.4 in hg proper for a while. Maybe hgsubversion could be a carrot to get users to migrate.

    AF

  9. Ewen Wallace

    no, it wasn't - I was responding to your "perhaps" comment which, probably unintentionally, read as snark. But you are right - it is not my place to point this out, particularly in light of the great work you have done here. I am Sorry.

    You wouldn't be the first to ditch v2.4 of Googling "python 2.4 deprecated" is any indication. Personally, I generally support the current + two previous versions of things I work on/with. In any case the decision is yours.

    I (obviously) don't speak for other users but I use this with TortoiseHg and whatever version of Python it bundles.

    If it helps any, my installation folder is cloned to "D:\CodezOnD\3rdParty\hg-svn", if it happens to be a naming issue.

  10. Matt Oswald

    Actually, I take that back.

    Since TortoiseHg comes with its own version of Python, this will only work for the command-line. TortoiseHg crashes instead.

  11. yyjdelete
    Ewen Wallace
    Tried Greg's patch (4 posts ago) on another computer with a real connection to the Internet and it didn't work - I got the original error trying to get incoming and also pulling from svn+https://svn.code.sf.net/p/objectlistview/code/cs/trunk which is a public read-only repo. Reverting to f67f9d28b0ac works.
    

    It looks that after 66395f232b7c , hgsubversion/layouts/standard.py also need to apply patch besides hgsubversion/layouts/detect.py

  12. Eugene Baranov

    I'm trying to use hg svn rebuildmeta but still having problems using 691078c and the latest v 2.10 x64-bit release of TortoiseHg (with Mercurial 2.8):

    Traceback (most recent call last):
      File "mercurial\dispatch.pyo", line 133, in _runcatch
      File "mercurial\dispatch.pyo", line 806, in _dispatch
      File "mercurial\dispatch.pyo", line 585, in runcommand
      File "mercurial\extensions.pyo", line 196, in wrap
      File "hgext\color.pyo", line 419, in colorcmd
      File "mercurial\dispatch.pyo", line 897, in _runcommand
      File "mercurial\dispatch.pyo", line 868, in checkargs
      File "mercurial\dispatch.pyo", line 803, in <lambda>
      File "mercurial\util.pyo", line 512, in check
      File "mercurial\extensions.pyo", line 151, in wrap
      File "mercurial\util.pyo", line 512, in check
      File "hgext\mq.pyo", line 3376, in mqcommand
      File "mercurial\util.pyo", line 512, in check
      File "C:\Program Files\TortoiseHg\extensions\hgsubversion\hgsubversion\svncommands.py", line 504, in svn
      File "C:\Program Files\TortoiseHg\extensions\hgsubversion\hgsubversion\svncommands.py", line 40, in rebuildmeta
      File "C:\Program Files\TortoiseHg\extensions\hgsubversion\hgsubversion\svncommands.py", line 213, in _buildmeta
      File "mercurial\demandimport.pyo", line 102, in __getattribute__
      File "mercurial\demandimport.pyo", line 74, in _load
      File "mercurial\demandimport.pyo", line 43, in _hgextimport
      File "C:\Program Files\TortoiseHg\extensions\hgsubversion\hgsubversion\layouts\__init__.py", line 32, in <module>
      File "mercurial\demandimport.pyo", line 102, in __getattribute__
      File "mercurial\demandimport.pyo", line 74, in _load
      File "mercurial\demandimport.pyo", line 43, in _hgextimport
      File "C:\Program Files\TortoiseHg\extensions\hgsubversion\hgsubversion\layouts\standard.py", line 5, in <module>
      File "mercurial\demandimport.pyo", line 102, in __getattribute__
      File "mercurial\demandimport.pyo", line 74, in _load
      File "mercurial\demandimport.pyo", line 43, in _hgextimport
    ImportError: No module named hgsubversion
    abort: No module named hgsubversion!
    
  13. Katsunori FUJIWARA

    With Mercurial 2.8 bundled in TortoiseHg 2.10 on Win x64 and hgsubversion (691078c03ed9, current tip of default), I can execute "hg svn buildmeta" without any failures before/after successful "hg pull" from SVN repo (even though "file:" scheme is used).

    But Eugene Baranov should also execute Mercurial 2.8, because "_hgextimport()" in the traceback attached by him is the specific function for Mercurial 2.8 (added by my patch for Mercurial).

    Are there any possible reasons causing unexpected importing behavior ?

  14. sbs_routeur

    Just found that updating to changeset f67f9d28b0ac) Merge with stable then grafting all changset except for changeset 1c9b1d0e0ba3) layouts: fix failure for nonexistent SVN paths fixes the issue.

    I do not know if there is a better way of updating while ignoring a changeset or updating and rollbacking a single changset.

  15. Greg Ward

    There's a better fix, which relies on a little-known implementation detail of Mercurial's extension mechanism. The patch says it all:

    diff --git a/hgsubversion/layouts/detect.py b/hgsubversion/layouts/detect.py
    --- a/hgsubversion/layouts/detect.py
    +++ b/hgsubversion/layouts/detect.py
    @@ -10,7 +10,7 @@
    
     from mercurial import util as hgutil
    
    -from hgsubversion import svnwrap
    +from hgext_hgsubversion import svnwrap
    
     import __init__ as layouts
    
    diff --git a/hgsubversion/layouts/standard.py b/hgsubversion/layouts/standard.py
    --- a/hgsubversion/layouts/standard.py
    +++ b/hgsubversion/layouts/standard.py
    @@ -2,7 +2,7 @@
     import pickle
    
     import base
    -import hgsubversion.util as util
    +import hgext_hgsubversion.util as util
    
     class StandardLayout(base.BaseLayout):
         """The standard trunk, branches, tags layout"""
    

    Tested successfully with Mercurial 1.9, 2.0, ..., 2.7, 2.8 all under Python 2.7. Unfortunately, this breaks hgsubversion's test suite -- sigh. Better fix coming in a pull request, I hope...

  16. Phil Pemberton

    This seems to be broken again...

    philpem@wolf:~/www$ hg version --svn
    Mercurial Distributed SCM (version 3.0.1)
    (see http://mercurial.selenic.com for more information)
    
    Copyright (C) 2005-2014 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    hgsubversion: 1.1+13-1290ab9def8f
    Subversion: 1.7.5
    bindings: Subvertpy 0.9.1
    
    $ hg --traceback clone svn://svn.code.sf.net/p/freertos/code freertos-code && tar -zcf freertos-code.tgz freertos-code
    
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 138, in _runcatch
        return _dispatch(req)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 819, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 599, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 196, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/hgext/pager.py", line 138, in pagecmd
        return orig(ui, options, cmd, cmdfunc)
      File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 196, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/hgext/color.py", line 431, in colorcmd
        return orig(ui_, opts, cmd, cmdfunc)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 910, in _runcommand
        return checkargs()
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 881, in checkargs
        return cmdfunc()
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 816, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 518, in check
        return func(*args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 151, in wrap
        util.checksignature(origfn), *args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 518, in check
        return func(*args, **kwargs)
      File "/home/philpem/.hgfiles/hgsubversion/hgsubversion/wrappers.py", line 603, in clone
        orig(ui, source, dest, **opts)
      File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 518, in check
        return func(*args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 1299, in clone
        branch=opts.get('branch'))
      File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 196, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/home/philpem/.hgfiles/hgsubversion/hgsubversion/wrappers.py", line 592, in hgclonewrapper
        data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
      File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 400, in clone
        destpeer.local().clone(srcpeer, heads=revs, stream=stream)
      File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1860, in clone
        return self.pull(remote, heads)
      File "/home/philpem/.hgfiles/hgsubversion/hgsubversion/svnrepo.py", line 77, in wrapper
        return fn(self, *args, **opts)
      File "/home/philpem/.hgfiles/hgsubversion/hgsubversion/svnrepo.py", line 105, in pull
        return wrappers.pull(self, remote, heads, force)
      File "/home/philpem/.hgfiles/hgsubversion/hgsubversion/wrappers.py", line 381, in pull
        repo.ui)
      File "/home/philpem/.hgfiles/hgsubversion/hgsubversion/layouts/detect.py", line 31, in layout_from_subversion
        from hgsubversion import svnwrap
      File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 111, in _demandimport
        return _hgextimport(_import, name, globals, locals, fromlist, level)
      File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 43, in _hgextimport
        return importfunc(name, globals, *args)
    ImportError: No module named hgsubversion
    abort: No module named hgsubversion!
    
  17. Log in to comment