From: "Ondrej Certik" <ondrej@certik.cz>
To: "Git Mailing List" <git@vger.kernel.org>
Subject: Re: importing mercurial patch
Date: Tue, 11 Nov 2008 11:59:43 +0100 [thread overview]
Message-ID: <85b5c3130811110259x5d659f7ah74e7774773bdcc58@mail.gmail.com> (raw)
In-Reply-To: <85b5c3130811110258h53d389co97a3c33e10667ae8@mail.gmail.com>
On Tue, Nov 11, 2008 at 11:58 AM, Ondrej Certik <ondrej@certik.cz> wrote:
> 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?
Just to make it clear --- I will of course use sh or C with git, I
only used Python above because that's the language I know the best.
Ondrej
next prev parent reply other threads:[~2008-11-11 11:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-11 10:58 importing mercurial patch Ondrej Certik
2008-11-11 10:59 ` Ondrej Certik [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85b5c3130811110259x5d659f7ah74e7774773bdcc58@mail.gmail.com \
--to=ondrej@certik.cz \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).