Reputation: 15239
I have a project having mercurial HG code source management,and try to migrate it on a VSTS/Git platform.
I read that there is a tool for doing that, "fast-export"... So I tried but not did't achieve to do it working in Windows...
Say I have D:\MyProject
containing the .hg
directory and the project code files, I
fast-export
files in the "D:\fast-export-master" folder, D:\MyProject-git
D:\MyProject-git
the git init
command (a new .git
directory appeared then);D:\MyProject-git
i did..\fast-export-master\hg-fast-export.sh -r "D:\MyProject"
now strange things starts happening, a command line window appeared and disappeared so quickly I didn't understood what happened, so I relaunched the previous command in a hope to see the message... I should try tens of times until able to capture in the printscreen the command-line message, that says strange things:
which: no D:\fast-export-master\hg-fast-export.sh in (/c/Users/xxx/bin:mingw64/bin:/user/local/bin:/usr/bin:/bin/mingw64/bin:/usr/bin:/c/Users/xxx/bin:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32 [...etc...etc...])
I wonder what is the problem and how to solve it...
EDIT:
Following the @max630 suggestion bellow, I reinstalled Python and update the PATH, so it's recognized in the command
> python
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
opened the "GIT Bash" from the start menu then
cd "/D/MyProject-git"
../fast-export-master/hg-fast-export.sh -r "D:\MyProject" --force
that gave:
../fast-export-master/hg-fast-export.sh: line 175: python: command not found
C:\Program Files\Git\mingw64\libexec\git-core\git-fast-import.exe statistics:
---------------------------------------------------------------------
Objects allocated: 5000
...
Upvotes: 6
Views: 6751
Reputation: 318
I spent hours and hours trying many of the above solutions, and nothing worked well for me. I tried the fast-export and the hggit in tortoisehg in numerous variations.
In the end I used the GitHub Importer to import all of my mercurial repository into GitHub.
I just needed to provide the URL of the repository (mine was in BitBucket), and it was a very smooth and easy process. Much smoother than trying to get python working in git bash, path variables, etc!
I also had some significant local changes that I could not push to bitbucket because they're not allowing pushes. So I had to copy those files manually into the git repository.
I also could not get teamcity to detect the changes when switching from VCS roots from bitbucket to github. So I created a new project in team city.
I hope this helps anybody who is facing these challenges.
Upvotes: 1
Reputation: 11
In case it helps anyone, it took me a while to get hg-fast-export to work, but I eventually got there. Here are some issues I ran into:
Upvotes: 1
Reputation: 1327084
Following the @max630 suggestion bellow, I reinstalled Python and update the PATH
Starting with Git 2.24 (Q4 2019), you will have to install Python 3, since the hg-to-git
script (in contrib/
) has been updated to work with Python 3.
See commit d17ae00 (18 Sep 2019) by Hervé Beraud (4383
).
(Merged by Junio C Hamano -- gitster
-- in commit 8f53fe1, 07 Oct 2019)
hg-to-git:
make it compatible with both python3 and python2Python 2 is EOL at the end of 2019, many distros and systems now come with python 3 as their default version.
Rewrite features used in
hg-to-git
that are no longer supported in Python 3, in such a way that an updated code can still be usable with Python 2:
print()
function instead.dict.has_key(key)
is no more; use "key in dict
" instead.
Upvotes: 1
Reputation: 38116
Since you already installed TortoiseHg, there has an easier way to migrate hg to git.
First, enable hggit in TortoiseHg:
TortoiseHg -> global setting -> Extensions Tab -> select hggit -> OK.
Then use below commands to migarte and push to VSTS git repo:
# In an empty folder
mkdir git
cd git
git init
cd ..
hg clone <URL for Hg repo>
cd hgrepo
hg bookmarks ../git
cd ..
cd git
git checkout hg
git remote add origin <VSTS git repo URL>
git push origin --all
Upvotes: 0
Reputation: 91
I think your concern is that you imported the "hg-fast-export" into a directory that was not added to your environment variables, according to the error message "D:\fast-export-master\hg-fast-export.sh" was not found in the list of your environment variables, so try to add th following "D:\fast-export-master\"in your environment variables and then try again.
If it does not work out yet, look at this article and follow step by step what was said:
https://www.appveyor.com/blog/2014/02/23/converting-mercurial-repository-to-git-on-windows/
The author has copied the directory "hg-fast-export" into the new directory git (without the .git of "hg-fast-export") and has also added hg, git and python to his environment variables.
good luck
Upvotes: 1
Reputation: 9238
There seems to be a bug in the bash bundled with git. It does not initialize "$@" properly if started from directly running .sh file from cmd.
Open "GIT Bash" from start menu, then issue commands:
cd "/D/MyProject-git"
to navigate to D:\MyProject-git
, and
../fast-export-master/hg-fast-export.sh -r "D:\MyProject"
to run your script
Upvotes: 0