git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* importing mercurial patch
@ 2008-11-11 10:58 Ondrej Certik
  2008-11-11 10:59 ` Ondrej Certik
  2008-11-11 12:00 ` Johannes Schindelin
  0 siblings, 2 replies; 6+ messages in thread
From: Ondrej Certik @ 2008-11-11 10:58 UTC (permalink / raw)
  To: Git Mailing List

Hi,

I'd like git to be able to import mercurial-exported patches. This
short Python program does it:


-------------------------------------
#! /usr/bin/python

import os
import sys
import re
import tempfile

def run(cmd):
    print cmd
    os.system(cmd)

patch = sys.argv[1]
p = open(patch).read()
author = re.search("# User (.+)", p).groups()[0]
p = p.split("\n")
while not p[0].startswith("# Parent"):
    del p[0]
i = 1
while not p[i].startswith("diff -r "):
    i += 1
commit_message = "\n".join(p[1:i])
_, filename = tempfile.mkstemp()
f = open(filename, "w")
f.write(commit_message)
f.close()

run("git apply %s" % patch)
run("git ci -a --author='%s' -F %s" % (author, filename) )
---------------------


How should this be implemented in git? Should I try to extend
"git-am.sh" to handle it?

For better imagination, this is how the patch looks like:

http://paste.debian.net/21210/

Thanks for any feedback,
Ondrej

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-11-11 23:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-11 10:58 importing mercurial patch Ondrej Certik
2008-11-11 10:59 ` Ondrej Certik
2008-11-11 12:00 ` Johannes Schindelin
2008-11-11 12:18   ` Ondrej Certik
2008-11-11 14:41     ` Johannes Schindelin
2008-11-11 23:36       ` Ondrej Certik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).