recode text files in repo

Manuel Jacob me at manueljacob.de
Tue Aug 27 20:55:00 UTC 2019


On 2019-08-27 18:43, Marcin Kasperski wrote:
>> 
>> Does anybody know how to configure "hg convert" to put all text files
>> through "iconv -f KOI8-R -t UTF8" ?
> 
> Hmm, wouldn't evolve help (giving track of obsolete2current commits
> mapping as a bonus)?
> 
> Rough idea (don't try blindly):
> 
>   # install and enable evolve extension + use modern hg
> 
>   hg clone your-repo new-directory
>   cd new-directory    # Yes, try in new copy, just in case&
> 
>   # Unflag changesets from public
>   hg phase --force --draft 0
> 
>   for REV in `hg log -T '{node} '`; do
>       echo "Patching $REV"
>       hg update --clean $REV
>       # Fixup code by iconv or whatever
>       hg amend  --note "Recode"
>   done
> 
>   hg evolve --all
> 
> This is likely imperfect or bad as it will generate plenty of troubled
> changesets, so I suppose one should call hg evolve more often instead 
> of
> leaving it to single final command. I am also not sure which changeset
> order is best, from oldest or from newest.
> 
> Ah, and note that depending on the operation order it may happen that
> some files will get mixed encodings (if you fixup old revisions and
> evolve newer on top of them). In such case sth smarter than iconv may 
> be
> needed. If that's problematic, start conversion from newer commits.

I didn’t check whether it's sufficient, but the problem may be solved by 
running the following before the fixup code

- hg evolve --no-all -r $REV (to rebase the changeset if it's orphan)
- hg update --clean $REV (as already is in your script sketch)
- hg evolve --no-all (to update to the successor (that was created by 
the previous execution of evolve) of the orphan changeset)



More information about the Mercurial mailing list