Opened 13 years ago
Closed 12 years ago
#10247 closed defect (fixed)
TracMercurial dies with Mercurial 1.9
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | high | Milestone: | plugin - mercurial |
Component: | plugin/mercurial | Version: | |
Severity: | major | Keywords: | apichanges |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
TracMercurial with Mercurial 1.9 dies here (using http://svn.edgewall.com/repos/trac/plugins/0.12/mercurial-plugin@10734):
File "/usr/lib64/python2.7/site-packages/trac/web/main.py", line 511, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib64/python2.7/site-packages/trac/web/main.py", line 237, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib64/python2.7/site-packages/trac/versioncontrol/web_ui/changeset.py", line 295, in process_request prev = repos.get_node(new_path, new).get_previous() File "/usr/lib64/python2.7/site-packages/trac/versioncontrol/api.py", line 999, in get_previous for p in self.get_history(2): File "/usr/lib64/python2.7/site-packages/TracMercurial-0.12.0.28dev_r10731-py2.7.egg/tracext/hg/backend.py", line 1047, in _get_history_1_4 matcher = match(repo, pats, opts) File "/usr/lib64/python2.7/site-packages/mercurial/scmutil.py", line 569, in match m = ctx.match(pats, opts.get('include'), opts.get('exclude'), AttributeError: 'mqrepo' object has no attribute 'match'
This should help:
Index: tracext/hg/backend.py =================================================================== --- tracext/hg/backend.py (revision 10734) +++ tracext/hg/backend.py (working copy) @@ -97,6 +97,7 @@ try: match = cmdutil.match + match = lambda c, p, o: match(c._repo, p, o) except AttributeError: from mercurial.scmutil import match @@ -1044,7 +1045,7 @@ return self._get_history_1_3(repo, pats, opts, limit) def _get_history_1_4(self, repo, pats, opts, limit): - matcher = match(repo, pats, opts) + matcher = match(repo[None], pats, opts) if self.isfile: fncache = {} def prep(ctx, fns):
Bit of a hack; seems to work, though.
Attachments (0)
Change History (10)
follow-up: 4 comment:1 by , 13 years ago
Milestone: | → plugin - mercurial |
---|---|
Priority: | normal → high |
comment:2 by , 13 years ago
Any repository is a MQ repository when you have the mq extension disabled. I'm pretty sure it would happen on any repository. See also this bit from the hg api changes document:
scmutil.match (formerly cmdutil.match) now requires a context argument (35c2cc322ba8), typically "repo[None]"
comment:4 by , 13 years ago
Replying to rblank:
Replying to djc <dirkjan@…>:
Bit of a hack; seems to work, though.
Accessing a "private" member? Quite a hack, yes :)
As this _repo
member was always present for the changectx
, and we're only using that for the "legacy" versions (pre-scmutil), I'd say it's fine to use it there.
And anyway, isn't the whole Mercurial Python API supposed to be private? ;-)
follow-up: 6 comment:5 by , 13 years ago
It's not so much private, it's just not guaranteed to be stable across major (1.x) releases. So will either of you commit this patch? :)
comment:6 by , 13 years ago
Owner: | set to |
---|
Replying to djc <dirkjan@…>:
So will either of you commit this patch? :)
Sure. As Christian seems to be mostly off-line these days, I'll take care of it.
comment:7 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Slightly modified patch applied in [10748] (the patch broke the revision log for Mercurial pre-1.8).
comment:8 by , 13 years ago
Owner: | changed from | to
---|
comment:9 by , 13 years ago
Description: | modified (diff) |
---|---|
Keywords: | apichanges added |
Resolution: | fixed |
Status: | closed → reopened |
It fails here with Mercurial 1.8.3+294-899feff0f5c2 (admittedly a bit old and an intermediate version even) and TracMercurial 0.13.0.5dev-r10900:
Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 478, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 198, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-x86_64/egg/trac/versioncontrol/web_ui/changeset.py", line 298, in process_request prev = repos.get_node(new_path, new).get_previous() File "build/bdist.linux-x86_64/egg/trac/versioncontrol/api.py", line 1020, in get_previous for p in self.get_history(2): File "build/bdist.linux-x86_64/egg/tracext/hg/backend.py", line 1058, in _get_history_1_4 matcher = match(repo[None], pats, opts) File "usr/local/lib/python2.5/site-packages/mercurial/scmutil.py", line 566, in match m = matchmod.match(repo.root, repo.getcwd(), pats, AttributeError: 'workingctx' object has no attribute 'root'
So it's not clear cut that scmutil.match
uses the new convention.
Indeed the switch was made in hg:19197fa4c41c, the parent of hg:35c2cc322ba8.
A simple getargspec
should do the trick:
-
tracext/hg/backend.py
15 15 16 16 from bisect import bisect 17 17 from datetime import datetime 18 from inspect import getargspec 18 19 import os 19 20 import time 20 21 import posixpath … … 99 100 100 101 # API compatibility (watch http://mercurial.selenic.com/wiki/ApiChanges) 101 102 103 def get_compatible_match(mod): 104 """match() used to take a repository argument (35c2cc322ba8)""" 105 def match(ctx, *args, **kwargs): 106 return mod.match(ctx._repo, *args, **kwargs) 107 return match 108 102 109 if hasattr(cmdutil, 'match'): 103 def match(ctx, *args, **kwargs): 104 return cmdutil.match(ctx._repo, *args, **kwargs) 110 match = get_compatible_match(cmdutil) 105 111 else: 106 112 from mercurial.scmutil import match 113 if getargspec(match)[0][0] == 'repo': 114 from mercurial import scmutil 115 match = get_compatible_match(scmutil) 107 116 108 117 109 118 except ImportError, e:
(and having getargspec
around will certainly prove to be useful again!)
Patch currently tested here.
comment:10 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Replying to djc <dirkjan@…>:
Accessing a "private" member? Quite a hack, yes :)
Does this happen with all repositories, or only when viewing an MQ repository?