Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert a Mercurial repository to Git...in *Windows*? [duplicate]

Tags:

git

mercurial

Possible Duplicate:
Converting a Mercurial (hg) repository to Git on Windows (7)

There's a Mercurial repository that I want to convert to Git, which is what we use at work. I have Mercurial (for Windows) installed, and I've already cloned the Hg repository locally. I'm stuck on trying to convert it.

Most of the pages I've found assume that I'm using Unix/Linux, and the most common recommendation, hg-fast-export, seems to work only in those OSes. I do have access to the Git Bash. I've gotten as far as this (line-wrapped for easier reading):

$ ~/codeingit/fast-export/hg-fast-export.sh -r
        ~/codeinmercurial/projectiwanttoconvert

In response, I get:

ImportError: No module named mercurial

I've read a number of web pages about this which, again, assume that I'm using Unix/Linux and that I have Mercurial installed for that.

Is there anyone who's successfully converted an Hg repository to Git on Windows, and can write a step-by-step guide to doing it?

like image 985
Ryan Lundy Avatar asked Jul 03 '12 23:07

Ryan Lundy


People also ask

Does GitHub work with Mercurial?

hg-github is a Mercurial extension that wraps hg-git, and supports a work-flow where repositories are hosted on Bitbucket and mirrored on GitHub. This work-flow normally requires adding Git paths to each repository's config file, and creating Mercurial bookmarks pointing to the GitHub repository's branch name.

How do I cancel my Mercurial repository?

Jonathan: Removing it is quite proper. We try to keep simple things simple in Mercurial: hg init creates . hg for you, and rm -r . hg will undo that.

What is Hg in Git?

The Hg-Git plugin can convert commits/changesets losslessly from one system to another, so you can push via a Mercurial repository and another Mercurial client can pull it. In theory, the changeset IDs should not change, although this may not hold true for complex histories. Commands.


1 Answers

1) Install Cygwin or Bash on Windows 10

Cygwin

  • Run setup.exe
  • Select Install from Internet
  • In the Select Packages dialog box:
    • Click Install at the top of the tree (next to All) until it shows Default
    • Expand the Devel subtree: Install git (change from Skip to the version number)
    • In the Devel subtree: Install mercurial (change from Skip to the version number)
    • Install Python subtree (change from Default to Install)
    • Click Next
  • If prompted to resolve dependencies, click Next
  • Get a cup of coffee, watch your favorite movie, or take a long nap

After the Cygwin installation is complete, open a bash shell to run the commands indicated in the steps below. The shortcut to bash will be called Cygwin Terminal.

Windows 10

  • Install Bash on Windows 10
  • Get a cup of coffee
  • Open Bash and type the following:
    • sudo apt install git
    • sudo apt install mercurial

2) Install fast-export

Open terminal (bash shell) and install fast-export:

   https://github.com/frej/fast-export.git

3) Initialize new git repo and migrate mercurial repo

   mkdir new_git_repo
   cd new_git_repo
   git init
   ../fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
   git checkout HEAD


Potential Error

fatal: Invalid raw date "<devnull@localhost> xxx -xxxx" in ident:  <><devnull@localhost> xxx -xxxx

Try adding an "authors.txt" file as described here, containing:

<>=devnull <devnull@localhost>

The command line now reads:

../fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo -A ../fast-export/authors
like image 131
Christopher Peisert Avatar answered Oct 07 '22 23:10

Christopher Peisert