import and hg 0.9.4

Bug #127181 reported by Horst Gutmann
4
Affects Status Importance Assigned to Milestone
Bazaar Hg Plugin
Fix Released
High
Robert Collins

Bug Description

Hi :)

With hg 0.9.4 there seems to be a new import override that causes bzr to die a painful death when importing bzr_hg:

 zerok@akira:~/.python/bin$ bzr help
 Unable to load plugin 'hg' from '/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/plugins'
 bzr: ERROR: exceptions.AttributeError: 'module' object has no attribute 'transactions'

 Traceback (most recent call last):
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/commands.py", line 729, in run_bzr_catch_errors
     return run_bzr(argv)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/commands.py", line 681, in run_bzr
     cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/commands.py", line 142, in get_cmd_object
     return _get_cmd_object(cmd_name, plugins_override)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/commands.py", line 157, in _get_cmd_object
     cmds = _get_cmd_dict(plugins_override=plugins_override)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/commands.py", line 123, in _get_cmd_dict
     d = _builtin_commands()
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/commands.py", line 102, in _builtin_commands
     import bzrlib.builtins
   File "/Users/zerok/.python/lib/python2.5/site-packages/mercurial/demandimport.py", line 83, in _demandimport
     return _origimport(name, globals, locals, fromlist)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/builtins.py", line 1216, in <module>
     class cmd_init(Command):
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/builtins.py", line 1247, in cmd_init
     registry=bzrdir.format_registry,
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/lazy_import.py", line 109, in __getattribute__
     return getattr(obj, attr)
   File "/Users/zerok/.python/lib/python2.5/site-packages/mercurial/demandimport.py", line 74, in __getattribute__
     self._load()
   File "/Users/zerok/.python/lib/python2.5/site-packages/mercurial/demandimport.py", line 46, in _load
     mod = _origimport(head, globals, locals)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/bzrdir.py", line 1431, in <module>
     class BzrDirFormat4(BzrDirFormat):
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/bzrdir.py", line 1444, in BzrDirFormat4
     _lock_class = lockable_files.TransportLock
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/lazy_import.py", line 109, in __getattribute__
     return getattr(obj, attr)
   File "/Users/zerok/.python/lib/python2.5/site-packages/mercurial/demandimport.py", line 74, in __getattribute__
     self._load()
   File "/Users/zerok/.python/lib/python2.5/site-packages/mercurial/demandimport.py", line 46, in _load
     mod = _origimport(head, globals, locals)
   File "/Users/zerok/.python/lib/python2.5/site-packages/bzrlib/lockable_files.py", line 30, in <module>
     import bzrlib.transactions as transactions
 AttributeError: 'module' object has no attribute 'transactions'

mwhudson pointed me to this bug: http://www.selenic.com/mercurial/bts/issue605

I then tried the following and it seems to work (have only tried pulling so far, though):

=== modified file '__init__.py'
--- __init__.py 2007-07-11 14:56:50 +0000
+++ __init__.py 2007-07-20 14:43:29 +0000
@@ -31,6 +31,9 @@
 import os
 import stat

+import mercurial.demandimport
+mercurial.demandimport.enable = lambda: None
+
 import mercurial.commands
 import mercurial.cmdutil
 import mercurial.hg

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I'm going to assign this to Tim Hatch, because he recently look in bzr-hg's direction, or something...

Changed in bzr-hg:
assignee: nobody → timhatch
Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 127181] Re: import and hg 0.9.4

  status triaged
  importance high

Renders bzr-hg unusable for people that have hg 0.9.4.

Changed in bzr-hg:
importance: Undecided → High
status: New → Triaged
Revision history for this message
Tim Hatch (timhatch) wrote :

Yep, we knew this was going to be an issue. I saw other demandimport related issues pop up in the TracMercurial plugin -- and just like in TracMercurial (see Trac rev 5796), we need to make sure that it still works for 0.9.3 users. I'm attaching a patch (applied to my branch at https://code.launchpad.net/~timhatch/bzr-hg/tim already) which should work around the issue for the time being for both 0.9.3 and 0.9.4.

Mercurial really would rather have this stuff enabled [some circular references mentioned in issue605?, in addition to the obvious speed considerations], so I'd like to eventually look for a better fix (after we get 0.9.3 working reliably).

Changed in bzr-hg:
assignee: timhatch → nobody
Revision history for this message
Robert Collins (lifeless) wrote :

I've merged Tim's import fix to the trunk.

Jelmer Vernooij (jelmer)
Changed in bzr-hg:
assignee: nobody → lifeless
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.