Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#8861 closed enhancement (fixed)

[PATCH] RFC: Allow trac-admin to replace recent version of wiki pages on import

Reported by: mrenzmann@… Owned by: Remy Blank
Priority: low Milestone: 0.12
Component: admin/console Version: 0.11.6
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When using wiki import or wiki load in trac-admin to import content from files into existing wiki pages, a new version of these pages will be generated if something has changed. If one imports a large amount of wiki pages this way, the timeline will be flooded with events for the wiki page "edits".

The attached patch adds an optional switch which changes the behaviour of wiki import and wiki load such that the current version of an existing wiki page is modified in place, to prevent the timeline flood. It has been tested while preparing the migration of trac-hacks.org to Trac 0.11.

Not sure if this is interesting enough to be included in Trac. Comments welcome.

Attachments (3)

t8861-trac_admin_wiki_replace-r8865.diff (4.8 KB ) - added by mrenzmann@… 12 years ago.
8861-wiki-replace-r8952.patch (8.7 KB ) - added by Remy Blank 12 years ago.
Add trac-admin $ENV wiki replace and enhance wiki load on trunk.
8861-wiki-replace-r8952.2.patch (7.8 KB ) - added by Remy Blank 12 years ago.
Don't deprecate wiki import, and only import from files with wiki load.

Download all attachments as: .zip

Change History (13)

by mrenzmann@…, 12 years ago

comment:1 by Christian Boos, 12 years ago

Milestone: 0.12
Owner: set to mrenzmann@…

The patch looks good, however:

  • it would be even nicer to have a corresponding unit-test
  • I don't like so much the idea of having an optional flag keyword after an argument, I find that confusing; do we do that elsewhere already? If not, better not start doing it. Alternatives could be:
    • use of a flag argument --replace, which can be specified before or after the directory
    • use of a different sub-command (wiki replace)

in reply to:  1 ; comment:2 by Remy Blank, 12 years ago

Replying to cboos:

  • use of a different sub-command (wiki replace)

Yes, please use a different command. --option style options are not really supported on trunk either, where the trac-admin infrastructure has been revamped.

in reply to:  2 comment:3 by mrenzmann@…, 12 years ago

Component: generaladmin/console

Replying to rblank:

Yes, please use a different command. --option style options are not really supported on trunk either, where the trac-admin infrastructure has been revamped.

No problem, will adjust it accordingly. Any suggestions for the actual command name? We'd need two, one for "import+replace" and one for "load+replace".

comment:4 by Christian Boos, 12 years ago

Ah, yes, we have two commands for doing essentially the same thing…

wiki replace <path> would be enough, and it would do either an import or a load according to the type of <path> (file or directory).

Note that we could also deprecate wiki import and have wiki load [path] to support directory, file or nothing (stdin).

by Remy Blank, 12 years ago

Add trac-admin $ENV wiki replace and enhance wiki load on trunk.

comment:5 by Remy Blank, 12 years ago

The patch above enhances trac-admin $ENV load as suggested in comment:4, and adds trac-admin $ENV replace. It also (finally) adds the advertised import from stdin, which was never actually implemented.

The patch is against trunk, so I'm afraid it won't help much for the migration of trac-hacks.org.

In its current state, the patch deprecates wiki import, as wiki load replaces it completely. However, this could be confusing, as it requires being able to specify the name of the page to be imported (in the case of a single page). Maybe it would be better to keep wiki import for importing single pages, and to have wiki_load always load from files and pick up the page name from the file name.

Thoughts?

by Remy Blank, 12 years ago

Don't deprecate wiki import, and only import from files with wiki load.

comment:6 by Remy Blank, 12 years ago

Owner: changed from mrenzmann@… to Remy Blank

I have changed my mind. The patch above doesn't deprecate wiki import, and allows multiple paths (files and directories) in wiki load. Both commands have different purposes: import/export allow importing and exporting single pages from/to files with arbitrary names or stdin/stdout. load/dump allow importing and exporting multiple pages from/to files, and the page names are taken from the file names. So I think it's better to keep both variants.

The only open question is what to do if a page to be replaced doesn't exist already. The current patch prints a message, but doesn't create the page. The alternative would be to create the page if it doesn't exist, and to replace the latest version if it does.

Thoughts?

in reply to:  6 ; comment:7 by Christian Boos, 12 years ago

Replying to rblank:

… So I think it's better to keep both variants.

OK

The only open question is what to do if a page to be replaced doesn't exist already. The current patch prints a message, but doesn't create the page. The alternative would be to create the page if it doesn't exist, and to replace the latest version if it does.

I find the latter behavior to be more useful: if you have a bunch of pages that have to replace an existing set of pages and among them you have pages that don't exist yet, I think you certainly want to add them nevertheless.

Btw, wiki replace, that's risky business - maybe adding a caveat + advice to do a backup first with wiki dump would be useful.

in reply to:  7 comment:8 by Remy Blank, 12 years ago

Replying to cboos:

I find the latter behavior to be more useful: if you have a bunch of pages that have to replace an existing set of pages and among them you have pages that don't exist yet, I think you certainly want to add them nevertheless.

Ok, I'll do that.

Btw, wiki replace, that's risky business - maybe adding a caveat + advice to do a backup first with wiki dump would be useful.

Good idea.

comment:9 by Remy Blank, 12 years ago

Resolution: fixed
Status: newclosed

Patch applied in [8956], including the suggestions from comment:7.

comment:10 by mrenzmann@…, 12 years ago

Cool, thanks!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.