importing mercurial patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux