Creating files and renaming in custom convert plugins

Boris Feld boris.feld at octobus.net
Thu Aug 17 07:21:37 UTC 2017


On Thu, 2017-08-17 at 00:23 +0200, Svein Seldal wrote:
> Yes, --filemap can rename and delete files, but it cannot change 
> contents nor can it create new files.
> 
> One possible solution could be to use the --filemap to rename 
> fileobject, and then let the convert source plugin change the
> contents. 
> Since I'm doing a lot of processing, I'm looking for a method to do
> this 
> all at once from a source plugin.

I'm not sure exactly how you could create files but for changing
content, you can override the putcommit method in the sink class, we
did it for the obfuscate extension (https://bitbucket.org/octobus/hg-ob
fuscate/overview):

https://bitbucket.org/octobus/hg-obfuscate/src/97c517ba56d56fcc11a1a310
700d50f267282f24/hgext3rd/obfuscate.py?at=default&fileviewer=file-view-
default#obfuscate.py-352:389

For creating files, you might need to customize the getchanges method
in your source class.

Cheers,
Boris

> 
> Best regards,
> Svein
> 
> 
> On 16. aug. 2017 10:56, Boris Feld wrote:
> > You can check if the --filemap option on hg --convert could do the
> > job.
> > 
> > On Sun, 2017-08-13 at 21:51 +0200, Svein Seldal wrote:
> > > Looking at the customization section in
> > > 
> > > https://www.mercurial-scm.org/wiki/ConvertExtension
> > > 
> > > Using this boiler plate framework, how can I create a new file
> > > and
> > > how
> > > can I rename a filename to something else?
> > > 
> > > 
> > > Best regards,
> > > Svein
> > > _______________________________________________
> > > Mercurial mailing list
> > > Mercurial at mercurial-scm.org
> > > https://www.mercurial-scm.org/mailman/listinfo/mercurial



More information about the Mercurial mailing list