#7346 closed defect (worksforme)
Unsupported version control system "hg"
| Reported by: | Owned by: | Christian Boos | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | plugin/mercurial | Version: | 0.12dev |
| Severity: | normal | Keywords: | mercurial tracmercurial hg plugin |
| Cc: | sajith@… | Branch: | |
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description (last modified by )
The complete error message is:
Unsupported version control system "hg": Can't find an appropriate component, maybe the corresponding plugin was not enabled?
trac.log seems to indicate that that the plugin is found:
2008-06-17 11:17:10,217 Trac[loader] DEBUG: Adding plugin TracMercurial 0.11.0.3 from /Library/Python/2.5/site-packages/TracMercurial-0.11.0.3-py2.5.egg ... 2008-06-17 11:17:11,106 Trac[loader] DEBUG: Loading hg from /Library/Python/2.5/site-packages/TracMercurial-0.11.0.3-py2.5.egg
- OS X 10.5.3
- Python 2.5.1 installed via ports
- Trac 0.11rc2
- TracMercurial 0.11 from svn
Resolution
In any case, such an error (Unsupported version control system "hg") is an InstallationIssue.
For anyone getting that error and getting to this page, please read through all the comments, you'll see tips about common installation issues, and how to troubleshoot them.
Attachments (0)
Change History (26)
comment:1 by , 17 years ago
| Milestone: | 0.11 → not applicable |
|---|
comment:3 by , 17 years ago
| Cc: | added |
|---|
Same problem here. (Trac 0.10.3, TracMercurial 0.10.0.2.) Here's the log:
2008-06-19 00:10:41,613 Trac[__init__] ERROR: Unsupported version control system "hg"
Traceback (most recent call last):
File "/var/lib/python-support/python2.4/trac/web/main.py", line 387, in dispatch_request
dispatcher.dispatch(req)
File "/var/lib/python-support/python2.4/trac/web/main.py", line 191, in dispatch
chosen_handler = self._pre_process_request(req, chosen_handler)
File "/var/lib/python-support/python2.4/trac/web/main.py", line 263, in _pre_process_request
chosen_handler = f.pre_process_request(req, chosen_handler)
File "/var/lib/python-support/python2.4/trac/versioncontrol/api.py", line 73, in pre_process_request
self.get_repository(req.authname) # triggers a sync if applicable
File "/var/lib/python-support/python2.4/trac/versioncontrol/api.py", line 91, in get_repository
raise TracError('Unsupported version control system "%s"'
TracError: Unsupported version control system "hg"
comment:4 by , 17 years ago
sajith: from the same environment where you're running Trac from (e.g. using tracd), are you able to load the mercurial modules from the command line? Try to emulate the sequence of imports done by the hg/backend.py (relevant to your version), e.g. for 0.10 see sandbox/mercurial-plugin/tracvc/hg/backend.py@7218#L37.
jross: it's quite puzzling, as the error message you reported ("… maybe the corresponding plugin was not enabled?" - from the patches on #6796) corresponds to the case where the MercurialConnector is not active. Short of inserting more debug statements manually, I don't know what to suggest next…
Are you sure there's no typo in your backend.py and that the get_supported_types method returns "hg"?
comment:5 by , 17 years ago
I haven't modified the hg plugin. I checked it out from the head a couple of days ago. I'm not a python hacker, but here's my failed attempt to perform the test:
>>> import backend
>>> print backend.has_mercurial
False
>>> conn = backend.MercurialConnector()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.5/site-packages/Trac-0.11rc2-py2.5.egg/trac/core.py", line 147, in __new__
compmgr = args[0]
IndexError: tuple index out of range
And here's a snippet from backend.py:
def get_supported_types(self):
"""Support for `repository_type = hg`"""
global has_mercurial
if has_mercurial:
yield ("hg", 8)
comment:6 by , 17 years ago
All imports works except this:
>>> from mercurial.revlog import LookupError Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: cannot import name LookupError
Also:
>>> revlog.REVLOG_DEFAULT_VERSION 65537
This is mercurial 0.9.1-1+etch1, on Debian Etch (4.0, stable). I'll try a new package and update.
follow-up: 20 comment:7 by , 17 years ago
So I rebuilt mercurial 1.0.1 debian packages from testing/unstable and installed them. It works now. Thanks!
In case anyone is wondering, this is what I did:
dget -x http://ftp.debian.org/debian/pool/main/m/mercurial/mercurial_1.0.1-1.dsc cd mercurial-1.0.1; debuild; cd -; dpkg -i mercurial*.deb
comment:8 by , 17 years ago
Now there's a new problem: I changed repository_dir once to an incorrect directory. After which trac says: "Trac detected an internal error", with this traceback:
Traceback (most recent call last):
File "/var/lib/python-support/python2.4/trac/web/main.py", line 387, in dispatch_request
dispatcher.dispatch(req)
File "/var/lib/python-support/python2.4/trac/web/main.py", line 191, in dispatch
chosen_handler = self._pre_process_request(req, chosen_handler)
File "/var/lib/python-support/python2.4/trac/web/main.py", line 263, in _pre_process_request
chosen_handler = f.pre_process_request(req, chosen_handler)
File "/var/lib/python-support/python2.4/trac/versioncontrol/api.py", line 73, in pre_process_request
self.get_repository(req.authname) # triggers a sync if applicable
File "/var/lib/python-support/python2.4/trac/versioncontrol/api.py", line 101, in get_repository
repos = self._connector.get_repository(rtype, rdir, authname)
File "build/bdist.linux-i686/egg/tracvc/hg/backend.py", line 82, in get_repository
File "build/bdist.linux-i686/egg/tracvc/hg/backend.py", line 148, in __init__
File "/var/lib/python-support/python2.4/mercurial/hg.py", line 60, in repository
repo = _lookup(path).instance(ui, path, create)
File "/var/lib/python-support/python2.4/mercurial/localrepo.py", line 2135, in instance
return localrepository(ui, util.drop_scheme('file', path), create)
File "/var/lib/python-support/python2.4/mercurial/localrepo.py", line 46, in __init__
raise repo.RepoError(_("repository %s not found") % path)
RepoError: repository /home/scm/hg/ not found
I switched repository_type back to svn, updated repository_dir, and found the same error again. Did a resync, trac still shows the same taceback. Should I file a new bug or is this a known problem?
Thanks.
comment:9 by , 17 years ago
Ok, it's gone away now. Weird, I should have seen the update trac.ini/resync results sooner.
comment:10 by , 17 years ago
Christian,
Are there any scripts, or commands I can run to help diagnose this? You mentioned inserting some print statements. Please let me know what I can do to help.
thanks
comment:11 by , 17 years ago
Hi Jeremy,
You were on the right way with experimenting on the command line. Try the following:
$ PYTHONPATH=. python25
>>> from trac.test import EnvironmentStub
>>> env = EnvironmentStub()
>>> from tracext.hg.backend import MercurialConnector
>>> mc = MercurialConnector(env)
>>> list(mc.get_supported_types())
[('hg', 8)]
>>> from tracext.hg import backend
>>> backend.has_mercurial
True
(Note that you don't need the PYTHONPATH=. part if you have installed trac; I use it to run trac from the svn working copy)
comment:12 by , 17 years ago
Thanks for providing this info. Here are the results:
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from trac.test import EnvironmentStub >>> env = EnvironmentStub() >>> from tracext.hg.backend import MercurialConnector >>> mc = MercurialConnector(env) >>> list(mc.get_supported_types()) [] >>> from tracext.hg import backend >>> backend.has_mercurial False
comment:13 by , 17 years ago
OK - should have guessed it earlier. You only applied one of the patches on #6796, the one for Trac. This enables you to get more info about an load error in Subversion only. You should have applied the second one (attachment:ticket:6796:unsupported-vcs-hg-r7031.diff) to the Mercurial plugin as well and only then the actual import error can be reported (hopefully!).
It's probably something similar to what Sajith had. One of these days, someone should really update the compatibility matrix (Trac plugin versions vs. Mercurial versions) in TracMercurial …
comment:14 by , 17 years ago
I forgot to patch again after I did a fresh svn co to get the latest code. Here ya go:
>>> from trac.test import EnvironmentStub
>>> env = EnvironmentStub()
>>> from tracext.hg.backend import MercurialConnector
>>> mc = MercurialConnector(env)
>>> list(mc.get_supported_types())
[('hg', -1)]
>>> from tracext.hg import backend
>>> backend.has_mercurial
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'has_mercurial'
comment:15 by , 17 years ago
| Description: | modified (diff) |
|---|
We're getting closer :-)
In the above, replace
>>> backend.has_mercurial
by:
>>> backend.error
and you should see the actual error message, the one you should now also get in Trac itself.
comment:16 by , 17 years ago
>>> backend.error Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'error'
In Trac I now get: Warning: Can't synchronize with the repository (Unsupported version control system "hg": "No module named mercurial" ). Look in the Trac log for more information.
I don't see anything useful in the log.
comment:17 by , 17 years ago
"No module named mercurial"
That's the import error you get and its meaning is pretty clear: you don't have Mercurial installed, or at least, not in such a way the python interpreter you use for Trac can find it. Usually this kind of problem can happen with all-in-one installers, but as said earlier, I'm not familiar with the Mac and hg on mac (I know there's such an issue on Windows if you use some all-in-one installers - which is not the case for me).
Bottom line: download a recent mercurial tar ball, do a python setup.py install and you should be set…
comment:18 by , 17 years ago
Thanks, you helped me identify the problem:
/opt/local/bin jeremyross$ which python /opt/local/bin/python /opt/local/bin jeremyross$ /opt/local/bin/python --version Python 2.5.2 /opt/local/bin jeremyross$ python --version Python 2.5.1 /opt/local/bin jeremyross$
comment:19 by , 17 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
All solved. I have 2 python installations: 1 that comes with OS X and one installed via Mac Ports. Mercurial was installed in the Mac Ports installation, but all the Trac stuff installed into the default Python install.
Sorry for the confusion and thanks for the help!
Jeremy
comment:20 by , 17 years ago
Replying to Sajith T S <sajith@gmail.com>:
So I rebuilt mercurial 1.0.1 debian packages from testing/unstable and installed them. It works now. Thanks!
I took a different approach: just deleted all (1) the references to LookupError and reloaded. now it works. The plugin's page says the 0.10 version is compatible with hg 0.9 and even 0.8. That should be changed.
comment:21 by , 17 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → reopened |
| Version: | 0.11rc2 → 0.12dev |
Sorry to reopen that bug, but I spend some hours to resolving the subject issue. I got the same error message ("Warning: Can't synchronize with the repository (Unsupported version control system "hg": Can't find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.") in the browser and when I try to rsync.
In addition:
- started with the stable branches and updated python/trac/TracMercurial/Genshi to the latest dev versions (error didn't change)
- The command line test results in 'True' for backend.has_mercurial
- placed TracMercurial egg in <env>/plugins or site-packages (incl. adaption in trac.ini: repo type hg, enables tracext.hg.* in components.)
- There are no (zero) messages above DEBUG level in the log
- Restarted the machine with no effect
- OS is MS Vista 32bit
- I have multiple Pythons but afaik only one is used (python —version shows the correct version and I start tracd from the same shell)
I'm absolutely clueless.
comment:22 by , 17 years ago
(now it's readable - will do a preview first next time)
Sorry to reopen that bug, but I spend some hours to resolving the subject issue. I got the same error message ("Warning: Can't synchronize with the repository (Unsupported version control system "hg": Can't find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.") in the browser and when I try to rsync.
In addition:
- started with the stable branches and updated python/trac/TracMercurial/Genshi to the latest dev versions (error didn't change)
- The command line test results in 'True' for backend.has_mercurial - placed TracMercurial egg in <env>/plugins or site-packages (incl. adaption in trac.ini: repo type hg, enables tracext.hg.* in components.)
- There are no (zero) messages above DEBUG level in the log
- Restarted the machine with no effect
- OS is MS Vista 32bit
- I have multiple Pythons but afaik only one is used (python —version shows the correct version and I start tracd from the same shell)
I'm absolutely clueless.
comment:23 by , 17 years ago
FYI: I have had same problem, in CentOS, with mercurial and ver 0.11.3 trac. In that time, problem's reason is
- mercurial is installed by hand
- and apache owner didn't find mercurial script
so, I use mod_python's PythonPath environment, like
<Location "/examcodes">
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /var/trac/root
PythonOption TracUriRoot /examcodes
PythonPath "sys.path+['/usr/local/lib/python2.4/site-packages/']"
</Location>
comment:24 by , 17 years ago
| Description: | modified (diff) |
|---|---|
| Milestone: | not applicable |
| Resolution: | → worksforme |
| Status: | reopened → closed |
If your seeing this error and no advice here was helpful, then see the InstallationIssue page for the usual way to get additional help (i.e. anything but reopening the ticket ;-) ).
comment:25 by , 15 years ago
Hello,
Could someone please take a look at this and suggest what might be wrong?
2010-11-03 11:26:24,322 Trac[env] INFO: -------------------------------- environment startup [Trac 0.12.1] --------------------------------
2010-11-03 11:26:24,338 Trac[loader] ERROR: Skipping "TracMercurial 0.12.0.23dev-r9953": (version conflict "VersionConflict: (TracMercurial 0.12.0.23 (c:\python25), Requirement.parse('TracMercurial==0.12.0.23dev-r9953'))")
2010-11-03 11:26:24,352 Trac[loader] DEBUG: Loading hg from c:\python25
2010-11-03 11:26:24,368 Trac[loader] ERROR: Skipping "hg = tracext.hg.backend": (can't import "ImportError: No module named tracext.hg.backend")
comment:26 by , 10 years ago
I'm seeing the same issue as comment:25 with 1.0-stable and trunk, working with 1.0 branch of mercurial-plugin.
20:29:30 Trac[loader] ERROR: Skipping "hg = tracext.hg.backend":
Traceback (most recent call last):
File "build/bdist.macosx-10.11-x86_64/egg/trac/loader.py", line 68, in _load_eggs
entry.load(require=True)
File "/Users/rjollos/Documents/Workspace/trac-dev/pve/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2202, in load
return self.resolve()
File "/Users/rjollos/Documents/Workspace/trac-dev/pve/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2208, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named hg.backend
I've tried reinstalling a few times, using python setup.py install as well as pip install.



The trac.log output doesn't tell you whether the plugin is enabled or not. For that, you have to log in as an user with TRAC_ADMIN permission, and look in the Admin pages, General / Plugins. Do you see the entry for the TracMercurial plugin there? If yes, is the MercurialConnector component enabled?