Ticket #7242 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

[PATCH] Trac 0.12 compatibility + other improvements

Reported by: mrelbe Assigned to: rjollos
Priority: normal Component: ChangeLogMacro
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description (Last modified by rjollos)

I have modified the plugin and adapted it to Trac 0.12 and made it multi-repo aware. I also couldn't resist in implementing some other requested improvements. In short:

  • Multi-repo aware for Trac 0.12 (#7062)
  • Revision ranges can now be stated (#327)
  • Changelog are put in a definition list (#3919)

The log indents nicely when stated in a list:

Last changes:
 * Default repo:
   [[ChangeLog(/)]]
 * otherrepo:
   [[ChangeLog(otherrepo:/)]]

I hope you don't mind me providing this patch, it may look like the plugin is completely re-written, but it's not. I've done this by applying successive changes, before supplying this ticket, all in good faith.

Please be critical to the patch as I am not a very experienced Python coder. I wouldn't be surprised if the parameter decoding can be made simpler/smarter.

I have not tested this on Trac 0.11, the plugin should be broken using Trac 0.11 due to the multi-repo capability (I have not studied the Trac 0.11 code).

I also updated the documentation:

Write repository change log to output.

The !ChangeLog macro writes a log of the last changes of a repository at a
given path. Following variants are possible to use:
{{{
1. [[ChangeLog([reponame:]path)]]
2. [[ChangeLog([reponame:]path@rev)]]
3. [[ChangeLog([reponame:]path@rev, limit)]]
4. [[ChangeLog([reponame:]path@from-to)]]
5. [[ChangeLog([reponame:]path@rev, limit, rev)]]
}}}

 1. Default repository is used if reponame is left out. To show the last five changes of the default repository:
{{{
[[ChangeLog(/)]]
}}}
   To show the last five changes of the trunk folder in a named repo:
{{{
[[ChangeLog(otherrepo:/trunk)]]
}}}
 2. The ending revision can be set. To show the last five changes up to revision 99:
{{{
[[ChangeLog(otherrepo:/trunk@99)]]
}}}
 3. The limit can be set by an optional parameter. To show the last 10 changes, up to revision 99:
{{{
[[ChangeLog(otherrepo:/trunk@99, 10)]]
}}}
 4. A range of revisions can be logged.
{{{
[[ChangeLog(otherrepo:/trunk@90-99)]]
}}}
    To lists all changes:
{{{
[[ChangeLog(otherrepo:/trunk@1-HEAD)]]
}}}
    HEAD can be left out:
{{{
[[ChangeLog(otherrepo:/trunk@1-)]]
}}}
 5. For backwards compatibility, revision can be stated as a second parameter instead:
{{{
[[ChangeLog(otherrepo:/trunk, 10, 99)]]
}}}

limit and rev may be keyword arguments.
{{{
[[ChangeLog(otherrepo:/trunk, limit=10, rev=99)]]
}}}

Attachments

t7242_multirepo+others_r7928.patch (7.2 kB) - added by mrelbe on 06/12/10 13:57:56.
Patch for #7242 to apply on r7928
t7242_multirepo-and-others_r7928.patch (7.2 kB) - added by mrelbe on 06/15/10 09:32:17.
Replaces former patch
t7242_multirepo-and-others_r7928_2-tsvn.patch (6.2 kB) - added by mrelbe on 11/19/10 08:01:11.
Made with TSVN, replaces all former patches, apply on r7928

Change History

06/12/10 13:57:56 changed by mrelbe

  • attachment t7242_multirepo+others_r7928.patch added.

Patch for #7242 to apply on r7928

06/12/10 14:00:32 changed by mrelbe

I forgot to state that the datetime format is changed to ISO-format. (I cannot find out how to use locale settings. Someone have any clue?)

06/14/10 13:39:28 changed by mrelbe

Variant 5. in the documentation is badly stated: it should be:

5. [[ChangeLog([reponame:]path, limit, rev)]]

i.e. rev is not appended to path (path@rev) in this case, which makes more sense to the end-user for backwards compatibility.

(However, if rev is stated as both path@rev and as a third parameter at the same call, path@rev takes precedence. No need to document that, I think.)

06/15/10 09:28:19 changed by mrelbe

Unfortunately, I seem to have chosen a very bad file name for the provided patch -- it cannot be downloaded here. I will therefore replace it and give it a better name. Sorry for this.

06/15/10 09:32:17 changed by mrelbe

  • attachment t7242_multirepo-and-others_r7928.patch added.

Replaces former patch

06/18/10 09:22:30 changed by rjollos

  • owner changed from rjollos to anonymous.
  • status changed from new to assigned.

Thanks for doing this! I will get this into the repository this weekend.

06/21/10 08:22:57 changed by mrelbe

Thank you for accepting the patch -- makes me very happy :)

Unfortunately, there's a glitch in the documentation of variant 5.

The patch states on lines 56-57: "5. For backwards compatibility... second parameter...", but should say third parameter

Sorry for this.

07/08/10 00:33:23 changed by rjollos

Sorry that I haven't gotten to this yet. I'm referring the reporter of #7347 to this ticket, so hopefully we'll get another tester on the new version.

07/08/10 00:37:10 changed by anonymous

  • status changed from assigned to new.
  • owner changed from anonymous to rjollos.

(follow-up: ↓ 9 ) 08/28/10 04:29:23 changed by rjollos

Planning to add this over the weekend and backport features to 0.11 so that tickets can be closed. I added you to the list of contributors on the project's wiki page.

(in reply to: ↑ 8 ; follow-up: ↓ 10 ) 11/18/10 21:47:09 changed by stava@linadd.org

Replying to rjollos:

Planning to add this over the weekend and backport features to 0.11 so that tickets can be closed. I added you to the list of contributors on the project's wiki page.

The patch seems not to be working properly:

patching file changelog/ChangeLogMacro.py
Hunk #4 failed at 9.
Hunk #7 succeeded at 23 with fuzz 1.
Hunk #10 succeeded at 75 with fuzz 1.
Hunk #12 failed at 108.
2 out of 15 hunks failed -- saving rejects to file changelog/ChangeLogMacro.py.rej

In addition I get a traceback when using the macro:

2010-11-18 21:28:37,076 Trac[formatter] ERROR: Macro ChangeLog(/trunk, 3) failed: 
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/trac/wiki/formatter.py", line 717, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "/usr/lib64/python2.6/site-packages/trac/wiki/formatter.py", line 304, in process
    text = self.processor(text)
  File "/usr/lib64/python2.6/site-packages/trac/wiki/formatter.py", line 291, in _macro_processor
    text)
  File "build/bdist.linux-x86_64/egg/changelog/ChangeLogMacro.py", line 87, in expand_macro
    path = repo.normalize_path(path)
AttributeError: 'NoneType' object has no attribute 'normalize_path'

What's the story?

(in reply to: ↑ 9 ; follow-ups: ↓ 11 ↓ 12 ) 11/18/10 22:52:29 changed by mrelbe

Replying to stava@linadd.org:

The patch seems not to be working properly:

The patch was made with TortoiseSVN, if my memory doesn't fail me. Could that be the reason?

(in reply to: ↑ 10 ) 11/19/10 07:13:45 changed by anonymous

Replying to mrelbe:

Replying to stava@linadd.org:

The patch seems not to be working properly:

The patch was made with TortoiseSVN, if my memory doesn't fail me. Could that be the reason?

Shouldn't matter which svn client one uses. It's more likely a mismatch between trunk and the patch. Is there anyway somebody could regenerate a patch for Trac 0.12.1 against the current trunk? I really would love to see the ChangeLog? macro working on my site again.

(in reply to: ↑ 10 ) 11/19/10 07:55:54 changed by mrelbe

Replying to mrelbe:

The patch was made with TortoiseSVN, if my memory doesn't fail me. Could that be the reason?

My memory did fail me, the patch was made with TortoiseHg?... I will upload a new patch produced by TortoiseSVN instead.

11/19/10 08:01:11 changed by mrelbe

  • attachment t7242_multirepo-and-others_r7928_2-tsvn.patch added.

Made with TSVN, replaces all former patches, apply on r7928

11/19/10 19:17:32 changed by rjollos

(In [9462]) Applied patch in #7242 from mrelbe. Refs #7242.

11/19/10 19:18:33 changed by rjollos

  • status changed from new to assigned.
  • owner changed from rjollos to anonymous.

I feel bad that I have left this sit here for so long!

I went ahead and applied the patch to the trunk, but have not yet had time to test it out. If you guys have a chance to test, please let me know.

(follow-up: ↓ 16 ) 11/19/10 19:19:29 changed by rjollos

  • status changed from assigned to new.
  • owner changed from anonymous to rjollos.

(in reply to: ↑ 15 ) 11/20/10 15:30:41 changed by stava@linadd.org

Replying to rjollos:

Works fine now!

The patch applies cleanly now, and the macro works as expected.

Tnx! /L

03/18/11 01:22:47 changed by rjollos

  • description changed.

03/18/11 01:34:53 changed by rjollos

  • status changed from new to closed.
  • resolution set to fixed.

Add/Change #7242 ([PATCH] Trac 0.12 compatibility + other improvements)




Change Properties
Action