2019-08-31

victor_sudakov: (Default)
2019-08-31 11:29 pm

Перекодировка текстов в репозитории mercurial

Изначально мои репозитории с текстами создавались ещё в CVS и в кодировке KOI8-R. Потом были экспортированы в SVN и Mercurial, но кодировка текстов осталась KOI8-R.

Появилось желание перекодировать тексты в Unicode, вместе с их историей, как будто они изначально были в Unicode. В рассылке mercurial@mercurial-scm.org Steve Fink дал мне расширение к расширению convert, которое это позволяет.
No promises, but you could give this a try: https://hg.sr.ht/~sfink/cmdconvert

Clone it to somewhere like ~/lib/hg. Add

    [extensions]
    cmdconvert = ~/lib/hg/cmdconvert

to your ~/.hgrc (or hgrc.ini or whatever it is on Windows.)

Then try running

    hg convert --command 'iconv -f KOI8-R -t UTF-8' your_repo new_repo

Odds of it working on the first try are somewhat low (I don't really know what
I'm doing.)

If you want to restrict by file extension, do something like

    hg convert --ext .txt --ext .html --command 'iconv -f KOI8-R -t UTF-8' your_repo
new_repo

It's not going to be fast, either.

Сработало прекрасно.