Ticket #7301 (assigned defect)

Opened 3 years ago

Last modified 10 months ago

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

Reported by: coxx@imarto.net Assigned to: mrelbe (accepted)
Priority: normal Component: TracTicketChangesetsPlugin
Severity: blocker Keywords:
Cc: julrich Trac Release: 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.

Attachments

7301.patch (1.3 kB) - added by ciibin@gmail.com on 03/28/11 09:22:16.
Patch for non-integer revisions
patch (4.9 kB) - added by mat on 10/05/11 19:18:59.
Patch to make Mercurial (possibly Git) work
fix-t7301-youngest-rev-handling.diff (1.1 kB) - added by mat on 10/07/11 19:41:10.
fix-t7301-changeset-ticket-displaying.diff (4.0 kB) - added by julrich on 07/24/12 12:55:02.
Patch to correctly display the changesets affecting a ticket.

Change History

(follow-up: ↓ 2 ) 07/02/10 01:56:28 changed by mrelbe

  • status changed from new to 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 :)

(in reply to: ↑ 1 ) 10/19/10 02:36:22 changed by pcw

Replying to mrelbe:

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.

11/03/10 21:19:18 changed by mrelbe

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

11/30/10 19:03:26 changed by anonymous

Any update about this ?

11/30/10 22:50:34 changed by mrelbe

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.

(follow-up: ↓ 7 ) 01/19/11 16:47:46 changed 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?

(in reply to: ↑ 6 ) 01/20/11 09:12:32 changed by mrelbe

Replying to anonymous:

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...)

02/14/11 11:27:19 changed by anonymous

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

02/14/11 11:27:42 changed by anonymous

Sorry, I meant "days"...

03/09/11 12:15:50 changed 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..... :)

03/28/11 09:22:16 changed by ciibin@gmail.com

  • attachment 7301.patch added.

Patch for non-integer revisions

03/28/11 09:26:36 changed by ciibin [at] gmail.com

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.

06/06/11 08:05:28 changed by dapetcu21@gmail.com

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

(follow-up: ↓ 14 ) 06/06/11 23:39:41 changed by mrelbe

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.

(in reply to: ↑ 13 ) 06/06/11 23:40:46 changed by mrelbe

Replying to mrelbe:

/../ Mercial /../

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

(follow-up: ↓ 16 ) 10/05/11 19:18:24 changed by mat

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.

10/05/11 19:18:59 changed by mat

  • attachment patch added.

Patch to make Mercurial (possibly Git) work

(in reply to: ↑ 15 ; follow-up: ↓ 19 ) 10/06/11 21:31:57 changed by mrelbe

Replying to mat:

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:

source:tracticketchangesetsplugin/t7301-mercurial

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).

10/07/11 19:40:52 changed by mat

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.

10/07/11 19:41:10 changed by mat

  • attachment fix-t7301-youngest-rev-handling.diff added.

04/04/12 21:13:00 changed by anonymous

Hi, do you have an update for this?

Thank you very much.

(in reply to: ↑ 16 ; follow-up: ↓ 20 ) 06/25/12 12:15:58 changed by julrich

Replying to mat:

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.

Replying to mrelbe:

The patch was applied in [10743].

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

07/24/12 12:55:02 changed by julrich

  • attachment fix-t7301-changeset-ticket-displaying.diff added.

Patch to correctly display the changesets affecting a ticket.

(in reply to: ↑ 19 ) 07/24/12 13:12:18 changed by julrich

  • cc set to julrich.

Replying to julrich:

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).

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




Change Properties
Action