git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: mercurial to git

From
Theodore Tso <tytso@mit.edu>
Date
Mar 6, 2007, 21:54 UTC
Message-ID
<20070306215459.GI18370@thunk.org>
In-Reply-To
<20070306210629.GA42331@peter.daprodeges.fqdn.th-h.de>
On Tue, Mar 06, 2007 at 09:06:29PM +0000, Rocco Rutte wrote:
> 
> attached are two files of take #1 of writing a hg2git converter/tracker 
> using git-fast-import. It basically works so use at your own risk and 
> send patches... :)

I was actually thinking about doing this too, but apparently you beat me too it. :-)

Show 9 quoted lines
> The performance bottleneck is hg exporting data, as discovered by people 
> on #mercurial, the problem is not really fixable and is due to hg's 
> revlog handling. As a result, I needed to let the script feed the full 
> contents of the repository at each revision we walk (i.e. all for the 
> initial import) into git-fast-import. This is horribly slow. For mutt 
> which contains several tags, a handfull of branches and only 5k commits 
> this takes roughly two hours at 1 commit/sec. My earlier version not 
> using 'deleteall' and feeding only files that changed took 15 minutes 
> alltogether, git-fast-import from a textfile 1 min 30 sec.

Hmm.... the way I was planning on handling the performance bottleneck was to use "hg manifest --debug <rev>" and diffing the hashes against its parents. Using "hg manifest" only hits .hg/00manifest.[di] and .hg/00changelog.[di] files, so it's highly efficient. With the --debug option to hg manifest (not needed on some earlier versions of hg, but it seems to be needed on the latest development version of hg), it outputs the mode and SHA1 hash of the files, so it becomes easy to see which files were changed relative to the revision's parent(s).

Once we know which files we need to feed to git-fast-import, it's just a matter of using "hg cat -r <rev> <pathname>" to feed the individual changed file to git-fast-import. For each file, you only have to touch .hg/data/pathane.[di] files. So this should allow us to feed input into git-fast-important without needing to feed the full contents of the repository for each revision.

The other thing that I've been working in my design is how to make the converter to be bidrectional. That is, if a changelog is made on the hg repository, it should be possible to push it over to the git repository, and vice versa, if there are changes made in the git repository, it should be possible to push it back to git.

In order to do this it becomes necessary to special case the .hgrc file, and in fact we need to make sure that the .hgrc file does *not* show up in the git repository, but the contents of the .hgrc file needs to be stored in the state file that lives alongside the git and hg repositories.

Regards,
						- Ted
Previous: Rocco RutteNext: Rocco Rutte
Message 2 of 19 in “mercurial to git”
  1. Rocco RutteMar 6, 2007
  2. Theodore TsoMar 6, 2007
  3. Rocco RutteMar 6, 2007
  4. Josef SipekMar 6, 2007
  5. Theodore TsoMar 7, 2007
  6. Rocco RutteMar 8, 2007
  7. Shawn O. PearceMar 7, 2007
  8. Rocco RutteMar 8, 2007
  9. Shawn O. PearceMar 7, 2007
  10. Rocco RutteMar 8, 2007
  11. Theodore TsoMar 15, 2007
  12. Rocco RutteMar 15, 2007
  13. Theodore TsoMar 15, 2007
  14. Rocco RutteMar 15, 2007
  15. Linus TorvaldsMar 15, 2007
  16. Theodore TsoMar 15, 2007
  17. Rocco RutteMar 15, 2007
  18. Simon 'corecode' SchubertMar 17, 2007
  19. Len BrownMar 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.