Opened 7 years ago

# Plugin does not work with not-integer revisons (Mercurial, Git and so on)

Reported by: Owned by: coxx@… Mikael Relbe normal TracTicketChangesetsPlugin blocker Jochen Ulrich, Ivanelson Nunes 0.12

### Description

The problem is that the plugin relies on integer IDs of revisions (like in SVN). But in reality the revision numbers can be strings like 6ec8cfe21421c253f1c68aa06cec613188f427d1.

### comment:1 follow-up:  2 Changed 7 years ago by Mikael Relbe

Status: new → assigned

I've never myself used Trac with Git or alike. So a revision reference is then stated as [6ec8cfe21421c253f1c68aa06cec613188f427d1] I presume? I'll make an effort in trying to make the plugin compatible with non-SVN repos. That will however take a while due to summer vacation, during which my family bans me from computers :)

### comment:2 in reply to:  1 Changed 7 years ago by pcw

I've never myself used Trac with Git or alike. So a revision reference is then stated as [6ec8cfe21421c253f1c68aa06cec613188f427d1] I presume? I'll make an effort in trying to make the plugin compatible with non-SVN repos. That will however take a while due to summer vacation, during which my family bans me from computers :)

Any updates on this feature? It would be very helpful if this plugin supports HG or Git.

### comment:3 Changed 7 years ago by Mikael Relbe

#7984 reported a problem using Mercurial and was closed as a duplicate of this ticket.

### comment:5 Changed 7 years ago by Mikael Relbe

Sorry but no update on this, yet. Reason: current work load. New Years promise will be to fix this ASAP. (Other reason: I'm switching computer gear right now...)

I will make a major effort taking care of both this ticket and all others as well. Please be patient.

### comment:6 follow-up:  7 Changed 7 years ago by anonymous

Sorry for re-asking, this plugin should be wonderful for me, but I user git almost exclusively. Do you have any kind of expected date for this?

### comment:7 in reply to:  6 Changed 7 years ago by Mikael Relbe

Sorry for re-asking /.../

Don't be sorry, this plugin should have been fixed a long time ago.

Do you have any kind of expected date for this?

Due to my current assignment I am overloaded with work (I'm currently working 50% more than normal). I've stated Feb-11 for other tasks at Trac as well, so I guess this goes for this plugin too.

I am sorry for this (but happy for the current and sudden R&D boom in the Swedish export industry, which I am deeply involved in...)

### comment:8 Changed 7 years ago by anonymous

We're using Mercurial. With the day passing by I seriously (re)consider assigning this task to a developer here :)

### comment:9 Changed 7 years ago by anonymous

Sorry, I meant "days"...

### comment:10 Changed 7 years ago by anonymous

Hei,

we are already in March, so Fabruary is gone... I don't want to hurry anybody, just that fixing this bug would be greatful..... :)

### Changed 7 years ago by ciibin@…

Patch for non-integer revisions

### comment:11 Changed 7 years ago by ciibin@…

Added a patch to fix the crash caused by non integer revisions. However this doesn't really work as it crashes in

Most recent call last:

File "build/bdist.macosx-10.5-i386/egg/trac/web/main.py", line 517, in _dispatch_request
dispatcher.dispatch(req)
File "build/bdist.macosx-10.5-i386/egg/trac/web/main.py", line 259, in dispatch
content_type)
File "build/bdist.macosx-10.5-i386/egg/trac/web/chrome.py", line 838, in render_template
stream |= self._filter_stream(req, method, filename, stream, data)
File "/Users/cibin/trac/virtual/lib/python2.6/site-packages/Genshi-0.6-py2.6.egg/genshi/core.py", line 132, in __or__
return Stream(_ensure(function(self)), serializer=self.serializer)
File "build/bdist.macosx-10.5-i386/egg/trac/web/chrome.py", line 989, in inner
data)
File "build/bdist.macosx-10.5-i386/egg/ticketchangesets/web_ui.py", line 93, in filter_stream
exists))
File "build/bdist.macosx-10.5-i386/egg/ticketchangesets/web_ui.py", line 101, in _render
tag.div(message, id='changelog'),
File "/Users/cibin/trac/virtual/lib/python2.6/site-packages/Genshi-0.6-py2.6.egg/genshi/builder.py", line 261, in __call__
Fragment.__call__(self, *args)
File "/Users/cibin/trac/virtual/lib/python2.6/site-packages/Genshi-0.6-py2.6.egg/genshi/builder.py", line 97, in __call__
self.append(arg)
File "/Users/cibin/trac/virtual/lib/python2.6/site-packages/Genshi-0.6-py2.6.egg/genshi/builder.py", line 129, in append
for child in node:
File "build/bdist.macosx-10.5-i386/egg/ticketchangesets/web_ui.py", line 147, in format
shorten=False),
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 1505, in format_to_oneliner
return InlineHtmlFormatter(env, context, wikidom).generate(shorten)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 1481, in generate
shorten)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 1342, in format
result = re.sub(self.wikiparser.rules, self.replace, result)
File "/Users/cibin/trac/virtual/lib/python2.6/re.py", line 151, in sub
return _compile(pattern, 0).sub(repl, string, count)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 1158, in replace
replacement = self.handle_match(fullmatch)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 1154, in handle_match
return internal_handler(match, fullmatch)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 540, in _lhref_formatter
return self._make_lhref_link(match, fullmatch, rel, ns, target, label)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 581, in _make_lhref_link
fullmatch)
File "build/bdist.macosx-10.5-i386/egg/trac/wiki/formatter.py", line 590, in _make_link
fullmatch)
File "build/bdist.macosx-10.5-i386/egg/trac/versioncontrol/web_ui/log.py", line 373, in _format_link
revranges = self._normalize_ranges(repos, path, revs)
File "build/bdist.macosx-10.5-i386/egg/trac/versioncontrol/web_ui/log.py", line 416, in _normalize_ranges
return Ranges(ranges)
File "build/bdist.macosx-10.5-i386/egg/trac/util/__init__.py", line 709, in __init__
self.appendrange(r)
File "build/bdist.macosx-10.5-i386/egg/trac/util/__init__.py", line 727, in appendrange
a, b = int(x), int(x)


This is trac 0.12.2 and trunk version of the plugin. I am not sure how to fix the new issue.

### comment:12 Changed 7 years ago by dapetcu21@…

Anyone willing to fix this? I would really appreciate.... It's been 4 months

### comment:13 follow-up:  14 Changed 7 years ago by Mikael Relbe

PatchWelcome, I have myself never used Trac with Mercial et.al. But if someone provides a rock-solid patch I will commit it without delay.

### comment:14 in reply to:  13 Changed 7 years ago by Mikael Relbe

/../ Mercial /../

See, I can't even spell it correctly ;)

### comment:15 follow-up:  16 Changed 6 years ago by Mathieu Pillard

I have a working patch, but it's far from being rock-solid :) I'm attaching it. A few remarks:

• I only tested it with Mercurial. I have no idea whether it works with git or even svn any more :)
• I switched the code to resync the commit messages to use repos.get_changesets instead of the infinite loop it used, because just walking from a changeset to the next didn't yield the entire changesets in my repos. As a side effect, it uses changeset.rev to get the current rev, I'm not sure it's in the standard trac API, since it appears to be undocumented.
• I used the changeset hash everywhere even though Mercurial exposes an integer if we really want it. This causes 2 problems:
1. Compact mode doesn't work. I don't know if it's fixable.
2. The "(Revision log)" link use log:@rev,rev syntax that doesn't seem to play nice with hashes. In order to work around that, I introduced a new setting, showrevlog, to de-activate that link.

To clarify: with my patch, you need showrevlog = false and compact = false in your settings to make mercurial support work.

This is very rough, but I don't have more time to work on this at the moment. If anyone wants to pick it up and improve it, feel free.

### Changed 6 years ago by Mathieu Pillard

Patch to make Mercurial (possibly Git) work

### comment:16 in reply to:  15 ; follow-up:  19 Changed 6 years ago by Mikael Relbe

I have a working patch, but it's far from being rock-solid :) I'm attaching it.

Thanks!

I did promise to apply patches, so I therefore created a branch for this ticket:

The patch was applied in [10743]. Anyone: feel free to pick this up since I'm not able (currently) to work on this (since I've never used Mercurial with Trac and have no time to figure out how to set this up -- sorry).

### comment:17 Changed 6 years ago by Mathieu Pillard

Well, I lied, I had more time to improve it :-)

I was having with the get_changesets method in admin.py : the date of the "youngest" revision is not always reliable, since 1) it comes from the clients 2) it could be in too far in the past if the latest revision is in a different branch.

I'm attaching a patch to fix this issue. Sadly, at least in mercurial, dates are timezone-aware, so I need pytz to get a reliable tzinfo for UTC to compare to. I hope it works with other version control systems, hopefully I'll have some time to test the branch and this patch with git and svn soon.

### comment:18 Changed 6 years ago by anonymous

Hi, do you have an update for this?

Thank you very much.

### comment:19 in reply to:  16 ; follow-up:  20 Changed 5 years ago by Jochen Ulrich

I have a working patch, but it's far from being rock-solid :) I'm attaching it.

At least for git, the displaying of the changesets on the ticket is not working correctly. It shows something like

<generator object format at 0x9a4b3c>


I'm attaching a patch to fix this.

The patch was applied in [10743].

Would be nice if you could apply my patch to the branch as well.

### Changed 5 years ago by Jochen Ulrich

Patch to correctly display the changesets affecting a ticket.

### comment:20 in reply to:  19 Changed 5 years ago by Jochen Ulrich

Cc: Jochen Ulrich added; anonymous removed

Forgot to mention, that the patch changes some other things as well:

• Revisions in the "Repository Changesets" section are formatted according to the version control plugin options (e.g. the revisions are abbreviated when the shortrev_len option is set).
• The "Revision Log" link needed to be changed because Trac 0.12 cannot handle log links with multiple non-integer revisions. I changed the link to point to the revision log starting from the last revision in the list (this is not a solution but a workaround since a real solution would require to change the Trac sources).

### comment:21 follow-up:  22 Changed 5 years ago by Ivanelson Nunes

Cc: Ivanelson Nunes added

I applied the patch, but the error continues. I'm using git. :(

2013-06-08 13:44:20,909 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 497, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 233, in dispatch
content_type)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrom
e.py", line 968, in render_template
stream |= self._filter_stream(req, method, filename, stream, data)
File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 132, in __or__
return Stream(_ensure(function(self)), serializer=self.serializer)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrom
e.py", line 1147, in inner
data)
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/web_ui.py", line 93, in filter_stream
exists))
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/web_ui.py", line 101, in _render
message.append(changeset)
File "/usr/lib/python2.7/dist-packages/genshi/builder.py", line 261, in __call
__
Fragment.__call__(self, *args)
File "/usr/lib/python2.7/dist-packages/genshi/builder.py", line 97, in __call_
_
self.append(arg)
File "/usr/lib/python2.7/dist-packages/genshi/builder.py", line 129, in append
for child in node:
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/web_ui.py", line 143, in format
yield tag.h3(_("Default Repository"), class_='change')
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/api.py", line 164, in wiki_revs
r = self.revs
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/api.py", line 129, in get_compact
i = 1
IndexError: list index out of range


### comment:22 in reply to:  21 ; follow-up:  23 Changed 5 years ago by Ivanelson Nunes

I applied the patch, but the error continues. I'm using git. :(

2013-06-08 13:44:20,909 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 497, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 233, in dispatch
content_type)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrom
e.py", line 968, in render_template
stream |= self._filter_stream(req, method, filename, stream, data)
File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 132, in __or__
return Stream(_ensure(function(self)), serializer=self.serializer)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrom
e.py", line 1147, in inner
data)
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/web_ui.py", line 93, in filter_stream
exists))
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/web_ui.py", line 101, in _render
message.append(changeset)
File "/usr/lib/python2.7/dist-packages/genshi/builder.py", line 261, in __call
__
Fragment.__call__(self, *args)
File "/usr/lib/python2.7/dist-packages/genshi/builder.py", line 97, in __call_
_
self.append(arg)
File "/usr/lib/python2.7/dist-packages/genshi/builder.py", line 129, in append
for child in node:
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/web_ui.py", line 143, in format
yield tag.h3(_("Default Repository"), class_='change')
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/api.py", line 164, in wiki_revs
r = self.revs
File "/usr/local/lib/python2.7/dist-packages/TracTicketChangesets-1.0dev_r0-py
2.7.egg/ticketchangesets/api.py", line 129, in get_compact
i = 1
IndexError: list index out of range


Disregard the above error. I applied the wrong patch. I installed again the branch 7301 and now the error is:

<generator object format at 0x7fbb438dfb40>


### comment:23 in reply to:  22 ; follow-up:  24 Changed 5 years ago by Jochen Ulrich

I installed again the branch 7301 and now the error is:

<generator object format at 0x7fbb438dfb40>


Did you also apply the patch attachment:fix-t7301-changeset-ticket-displaying.diff​ since the error sounds similar to my comment:19?

### comment:24 in reply to:  23 Changed 5 years ago by Ivanelson Nunes

I installed again the branch 7301 and now the error is:

<generator object format at 0x7fbb438dfb40>


Did you also apply the patch attachment:fix-t7301-changeset-ticket-displaying.diff​ since the error sounds similar to my comment:19?

It's bad because this error is not getting in trac.log.

### comment:25 Changed 4 years ago by anonymous

I also got this error. A long time. In git1.7

### Modify Ticket

Change Properties