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

Re: Mercurial to git converter.

From
Nick Andrew <nick@nick-andrew.net>
Date
Jun 14, 2008, 10:23 UTC
Message-ID
<loom.20080614T101342-542@post.gmane.org>
In-Reply-To
<1168537766.22649.19.camel@localhost.localdomain>
Stelian Pop <stelian <at> popies.net> writes:
Show 7 quoted lines
> I switched recently from Mercurial to git for some of my projects, and
> needed a conversion tool with branch support (unlike tailor). I didn't
> find any, so I ended up writing my own one. 
> 
> hg-to-git.py can probably be greatly improved (it's a rather crude
> combination of shell and python) but it does already work quite well for
> me. [...]

Thanks for that. One small problem is that it does not get the changelog right if a commit is made on a local branch. It thinks the "branch:" line is part of the changelog.

Here's a patch to fix that:

diff -u -r1.1 hg-to-git.py --- hg-to-git.py +++ hg-to-git.py

@@ -151,7 +151,7 @@
         mparent = None

     (fdcomment, filecomment) = tempfile.mkstemp()
-    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v 
^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v 
^description: | grep -v ^tag:' % cset).read().strip()
+    csetcomment = os.popen('hg log -r %d -v | egrep -v "^(changeset|parent|
user|date|files|description|tag|branch):" ' % cset).read().strip()
     os.write(fdcomment, csetcomment)
     os.close(fdcomment)


Nick.
Previous: Stelian PopNext: Johannes Schindelin
Message 9 of 15 in “Mercurial to git converter.”
  1. Stelian PopJan 11, 2007
  2. Jakub NarebskiJan 12, 2007
  3. Stelian PopJan 12, 2007
  4. Add hg-to-git conversion utility.Stelian Pop, Jan 12, 2007
  5. Shawn O. PearceJan 12, 2007
  6. Stelian PopJan 12, 2007
  7. Junio C HamanoJan 12, 2007
  8. Stelian PopJan 12, 2007
  9. Nick AndrewJun 14, 2008
  10. Johannes SchindelinJun 14, 2008
  11. Jakub NarebskiJun 14, 2008
  12. Shawn O. PearceJun 16, 2008
  13. Nick AndrewJun 16, 2008
  14. Mike HommeyJun 16, 2008
  15. Johannes SchindelinJun 17, 2008

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.