christianspecht / scm-backup

Makes offline backups of your cloud hosted source code repositories
https://scm-backup.org/
GNU General Public License v3.0
58 stars 20 forks source link

Mercurial was NOT found #56

Closed EnricoRav closed 4 years ago

EnricoRav commented 4 years ago

Hello, i read the guide and configured settings.yml as in this image:

image

I using TortoiseHg on my PC but for try to solve the problem i have installed also Mercurial from Setup but nothing change.

Hg is in the search path, if i open cmd and i digit "hg" it work.

The error are alwais the same as you can see in the log below:

image

Note: if i change settings.yml commenting out the scms section the error are always the same, but if i put a wrong path into the settings.yml as in the image below:

image

the errors becomes:

image

I wait for your help, thanks in advance. Enrico

christianspecht commented 4 years ago

Can you open cmd on your machine, enter hg version and show me the result?

That‘s what SCM Backup actually does when it tries to find Mercurial: It runs hg version and checks if the output contains the string „mercurial distributed scm“.

When I implemented this, this logic worked for all Mercurial versions I tested it with. But maybe the text was changed in one of the newer Mercurial versions.

PS: You know that Bitbucket will drop Mercurial support and delete all Mercurial repositories in about two weeks?

EnricoRav commented 4 years ago

Hello, below the result of version command of the two Hg installed in my PC. The first is the new one installed to try to solve the problem, the last official Setup. The second is the one installed with TortoiseHg (an old version).

The bug is the string who don't match the "Italian" translation, perhaps it's better separately test the existence of the strings "mercurial" and "scm".

I solved the bug deleting the folder Locale\it under Hg installation folder, without Mercurial localization file the returned string is the english version and SCM Backup works!

image

EnricoRav commented 4 years ago

I know that BitBucket will drop Mercurial support and delete the repos in the next 2 weeks, it is for that who i need a complete backup of all my repos. I have more of 100 repo's in 3 different workspace.

I tryied to use hggit to convert the repos into Git and continue to use BitBucket but i haven't found any version of "Mercurial + Python + Dulwich + Hggit" not buggy. I can't successfully converted no one repo ... :-( Can you suggest me a method to do a good conversion of the Mercurial repos to Git?

christianspecht commented 4 years ago

The bug is the string who don't match the "Italian" translation, perhaps it's better separately test the existence of the strings "mercurial" and "scm".

I solved the bug deleting the folder Locale\it under Hg installation folder, without Mercurial localization file the returned string is the english version and SCM Backup works!

OK, this is interesting. I wasn't aware that Mercurial is localized (and I'm in Germany and my machine has German settings :sunglasses: ).
Now I see that my current Mercurial installation (v5.0.2) is partly localized. The output of hg version is in English, but other commands output a mixture of English and German. So it seems they are in the process of localizing it.

I need to check if there's a language-agnostic way to get the information SCM Backup needs (it's not only "does hg exist on this machine" - it's also the version number that SCM Backup shows)

christianspecht commented 4 years ago

I tryied to use hggit to convert the repos into Git and continue to use BitBucket but i haven't found any version of "Mercurial + Python + Dulwich + Hggit" not buggy. I can't successfully converted no one repo ... :-( Can you suggest me a method to do a good conversion of the Mercurial repos to Git?

I converted about 40 HG repos to Git in the last few month (work and private).

I didn't use anything special, just the HgGit version that's bundled with TortoiseHG.
I'm 95% sure that the following is all you need (if not, ask again and I'll take a closer look):

  1. Open %userprofile%\mercurial.ini and add this:

    [extensions]
    hggit =
    
    [git]
    branch_bookmark_suffix=_bm

    The first one activates the hggit plugin (which comes with TortoiseHG, it just needs to be activated), and the second one is needed if your HG repo has named branches (you need to convert each branch that you want to keep into a bookmark, because hggit supports only bookmarks. Note: there are ways to automate this)

  2. Save this as a batch file and execute it for each repo that you want to convert:

    set basedir=C:\Code\
    set hgrepo=MyRepository
    set gitrepo=%hgrepo%-Git
    
    c:
    rd /s /q %basedir%%gitrepo%
    
    md %basedir%%gitrepo%
    cd %basedir%%gitrepo%
    git init
    
    cd %basedir%%hgrepo%
    hg bookmarks hg
    hg push ../%gitrepo%
    
    cd %basedir%%gitrepo%
    git checkout -b master hg
    
    pause

    This will convert the local Mercurial repo C:\Code\MyRepository to a new local Git repo in C:\Code\MyRepository-Git.

EnricoRav commented 4 years ago

In Windows the most agnostic way is reading the version info directly from the file hg.exe, but i don't know how to do that in Linux and if is possible to do.

image

EnricoRav commented 4 years ago

I tryied your suggestion to make a Mercurial to Git repo conversion but without success. Below the log of cmd and some other informations.

C:\Work>set basedir=C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\

C:\Work>set hgrepo=HarcUnicode

C:\Work>set gitrepo=HarcUnicode-Git

C:\Work>c:

C:\Work>rd /s /q "C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git" Impossibile trovare il file specificato.

C:\Work>md "C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git"

C:\Work>cd "C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git"

C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git>git init Initialized empty Git repository in C:/Work/Progetti Rio 10.3/LU-VE GROUP/LU-VE/Harc/HarcUnicode-Git/.git/

C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git>cd "C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode"

C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode>hg bookmarks hg

C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode>hg push ../HarcUnicode-Git pushing to ../HarcUnicode-Git searching for changes unknown exception encountered, please report by visiting https://mercurial-scm.org/wiki/BugTracker Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] Mercurial Distributed SCM (version 4.5.2) ** Extensions loaded: strip, hggit Traceback (most recent call last): File "hg", line 61, in File "mercurial\dispatch.pyo", line 88, in run File "mercurial\dispatch.pyo", line 183, in dispatch File "mercurial\dispatch.pyo", line 324, in _runcatch File "mercurial\dispatch.pyo", line 332, in _callcatch File "mercurial\scmutil.pyo", line 154, in callcatch File "mercurial\dispatch.pyo", line 314, in _runcatchfunc File "mercurial\dispatch.pyo", line 918, in _dispatch File "mercurial\dispatch.pyo", line 673, in runcommand File "mercurial\dispatch.pyo", line 926, in _runcommand File "mercurial\dispatch.pyo", line 915, in File "mercurial\util.pyo", line 1195, in check File "mercurial\commands.pyo", line 4194, in push File "hggit\util.pyo", line 60, in inner File "hggit__init__.pyo", line 421, in exchangepush File "hggit\git_handler.pyo", line 405, in push File "hggit\git_handler.pyo", line 1118, in upload_pack File "dulwich\client.pyo", line 701, in send_pack File "hggit\git_handler.pyo", line 1084, in genpack File "dulwich\object_store.pyo", line 183, in find_missing_objects File "dulwich\object_store.pyo", line 1057, in init File "dulwich\object_store.pyo", line 1011, in _split_commits_and_tags File "dulwich\object_store.pyo", line 118, in getitem File "dulwich\object_store.pyo", line 423, in get_raw KeyError: 'f410aff2c65b2156cd902e54531b98d214003bfb'

C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode>cd "C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git"

C:\Work\Progetti Rio 10.3\LU-VE GROUP\LU-VE\Harc\HarcUnicode-Git>git checkout -b master hg fatal: 'hg' is not a commit and a branch 'master' cannot be created from it

The TortoiseHg version is: image

a little bit older because i readed who is the most recent where the hggit extension it is not buggy, but perhaps also this version is buggy ...

christianspecht commented 4 years ago

I never tried 4.5.2, I can just tell you that I did all my repo conversions with 5.0.2, which worked without bugs.

Maybe you should try a fresh installation (or another machine). In one of your first posts, you wrote that you have multiple HG versions installed. I have no idea where HG stores its extensions, but when you tried to convert the repo, maybe the HG installation that was actually used somehow found the wrong hggit version?

christianspecht commented 4 years ago

This issue is now auto-closed because I just merged the commit into master where I fixed the actual problem (Mercurial was not found).

Feel free to continue asking about converting HG repos to Git!

EnricoRav commented 4 years ago

Hello Christian, i removed all versions of TortoiseHg, SourceSafe, Mercurial and Git from my PC. Then i done a fresh installation of TortoiseHg 5.0.2 and Git 2.27.0, and with this configuration the hggit extension works fine. Only some trouble to understand how to convert all the active branchs. I discovered that i must set a bookmark for every active branch on the hg repo before doing the push to the new git repo. Another trick is that the bookmarks name can't contains any spacing characters or any characters don't allowed into the git's branchs name. If a don't allowed character is presents into the branch name the hggit crash and the conversion fail. With this tricks i modified your example (.bat) and i converted successfully a complex repo with 5 active branchs. In your example the "default" branch is converted as "hg" in git, after conversion i added a deletion of "hg" branch into git repo to clean the conversion of branch "default" to "master". Thank you very much for your help!!