[RFC] mtn to git conversion script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC] mtn to git conversion script

Felipe Contreras
Hi,

I developed a script that converts a monotone repository into a git
one (exact clone), I want to contribute it so everybody can use it.

However, I might have not done it correctly.

This is the gist of the script:

mtn update --revision #{@id} --reallyquiet
git ls-files --modified --others --exclude-standard -z | git
update-index --add --remove -z --stdin
git write-tree
git write-raw < /tmp/commit.txt
git update-ref refs/mtn/#{@id} #{@git_id}

branches.each do |e|
    git update-ref refs/heads/#{e} #{@git_id}
end

I wrote "git write-raw" which takes the commit text as is, and puts it
into the repository.

I've read about 'fast-import' but I'm not sure if it would be more
efficient, because you would have to parse the output of different mtn
tools.

What do you think? Does it makes sense to have a 'write-raw' command?
Or should I somehow use 'fast-import'?

Best regards.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Miklos Vajna
On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras <[hidden email]> wrote:
> What do you think? Does it makes sense to have a 'write-raw' command?
> Or should I somehow use 'fast-import'?

Yes, you should. ;-)

The syntax of it is not so hard, see for example 'git fast-export
HEAD~2..' on a git repo and you'll see.

This should help a lot if you are like me, who likes to learn from
examples.

_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

attachment0 (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Johannes Schindelin
Hi,

On Sun, 24 Aug 2008, Miklos Vajna wrote:

> On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras <[hidden email]> wrote:
> > What do you think? Does it makes sense to have a 'write-raw' command?
> > Or should I somehow use 'fast-import'?
>
> Yes, you should. ;-)
>
> The syntax of it is not so hard, see for example 'git fast-export
> HEAD~2..' on a git repo and you'll see.
>
> This should help a lot if you are like me, who likes to learn from
> examples.

Heh.  I am glad you like fast-export.  To be honest, I never intended to
use fast-export for anything else than as an example how to drive
fast-import... :-)

Ciao,
Dscho



_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Felipe Contreras
In reply to this post by Miklos Vajna
On Sun, Aug 24, 2008 at 4:14 PM, Miklos Vajna <[hidden email]> wrote:

> On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras <[hidden email]> wrote:
>> What do you think? Does it makes sense to have a 'write-raw' command?
>> Or should I somehow use 'fast-import'?
>
> Yes, you should. ;-)
>
> The syntax of it is not so hard, see for example 'git fast-export
> HEAD~2..' on a git repo and you'll see.
>
> This should help a lot if you are like me, who likes to learn from
> examples.

Is it possible to create a fast-import from the index? I realize this
is not the best thing to do, but for now I would like to do that.

Best regards.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Shawn O. Pearce
Felipe Contreras <[hidden email]> wrote:

> On Sun, Aug 24, 2008 at 4:14 PM, Miklos Vajna <[hidden email]> wrote:
> > On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras <[hidden email]> wrote:
> >> What do you think? Does it makes sense to have a 'write-raw' command?
> >> Or should I somehow use 'fast-import'?
> >
> > Yes, you should. ;-)
> >
> > The syntax of it is not so hard, see for example 'git fast-export
> > HEAD~2..' on a git repo and you'll see.
> >
> > This should help a lot if you are like me, who likes to learn from
> > examples.
>
> Is it possible to create a fast-import from the index? I realize this
> is not the best thing to do, but for now I would like to do that.

No, fast-import uses its own internal structure and avoids the
index file.

Also, look at `git-hash-objects -w` as a replacement for your
git-write-raw tool if you aren't going to use git-fast-import.

--
Shawn.


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Felipe Contreras
On Mon, Aug 25, 2008 at 1:46 AM, Shawn O. Pearce <[hidden email]> wrote:

> Felipe Contreras <[hidden email]> wrote:
>> On Sun, Aug 24, 2008 at 4:14 PM, Miklos Vajna <[hidden email]> wrote:
>> > On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras <[hidden email]> wrote:
>> >> What do you think? Does it makes sense to have a 'write-raw' command?
>> >> Or should I somehow use 'fast-import'?
>> >
>> > Yes, you should. ;-)
>> >
>> > The syntax of it is not so hard, see for example 'git fast-export
>> > HEAD~2..' on a git repo and you'll see.
>> >
>> > This should help a lot if you are like me, who likes to learn from
>> > examples.
>>
>> Is it possible to create a fast-import from the index? I realize this
>> is not the best thing to do, but for now I would like to do that.
>
> No, fast-import uses its own internal structure and avoids the
> index file.

Yeah, I knew that, but wanted to just replace the 'write-raw' command.
To avoid doing unnecessary changes.

> Also, look at `git-hash-objects -w` as a replacement for your
> git-write-raw tool if you aren't going to use git-fast-import.

Awesome, but I just did it properly :)

A few comments regarding fast-import:

Why the distinction between 'from' and 'merge'? Doesn't it make more
sense to use 'parent' for both?

I'm doing: commit refs/mtn/d137c7046bae7e4a0144fee82bfce8061f61e3b3

So I was expecing this to work:
from mtn/d137c7046bae7e4a0144fee82bfce8061f61e3b3

But it didn't, probably because the commit hasn't actually been
committed. Wouldn't it make sense to store it as a temporal commit so
my script doesn't have to deal with that?

Anyway, very nice tool. It's going much faster (1h) compared to before (1 day).

Best regards.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Brian Downing
In reply to this post by Felipe Contreras
On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras wrote:

> I developed a script that converts a monotone repository into a git
> one (exact clone), I want to contribute it so everybody can use it.
>
> This is the gist of the script:
>
> mtn update --revision #{@id} --reallyquiet
> git ls-files --modified --others --exclude-standard -z | git
> update-index --add --remove -z --stdin
> git write-tree
> git write-raw < /tmp/commit.txt
> git update-ref refs/mtn/#{@id} #{@git_id}
>
> branches.each do |e|
>     git update-ref refs/heads/#{e} #{@git_id}
> end
You definitely want to use fast-import, but you probably want to do
something a lot closer to fast-export for monotone (read: use its
automate stdio interface and avoid expensive calls).

Here's a simple monotone to git converter I wrote.  You'll need the
Monotone::AutomateStdio perl module to use it (which I think I got it
from monotone's net.venge.monotone.contrib.lib.automate-stdio branch).
It is very fast; it can convert the OpenEmbedded repo in something like
5-10 minutes on my machine.

Note that for monotone export to go fast you absolutely /must/ avoid the
get_manifest operation.  In my converter I use the revision information
directly.  Getting the renames right with this is a little tricky; IIRC,
the ordering that works is:

* Rename all renamed files, innermost files first, to temporary names.
* Delete all deleted files, innermost first.
* Rename all temporary names to permanent names, outermost first.
* Add all new/modified files.

Conveniently, all of the above can be done by directly emitting
fast-import commands, so you don't have to keep track of trees directly.
(With one exception, which I'll elaborate on in a different email.)

-bcd

_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

mtn-to-git.pl (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Brian Downing
On Mon, Aug 25, 2008 at 11:35:31AM -0500, Brian Downing wrote:

> Note that for monotone export to go fast you absolutely /must/ avoid the
> get_manifest operation.  In my converter I use the revision information
> directly.  Getting the renames right with this is a little tricky; IIRC,
> the ordering that works is:
>
> * Rename all renamed files, innermost files first, to temporary names.
> * Delete all deleted files, innermost first.
> * Rename all temporary names to permanent names, outermost first.
> * Add all new/modified files.
>
> Conveniently, all of the above can be done by directly emitting
> fast-import commands, so you don't have to keep track of trees directly.
> (With one exception, which I'll elaborate on in a different email.)

The exception is one commit in monotone's repository.  There was
actually a commit that did:

    rename '/' '/something'
    add '/other'

Monotone can apparently handle that, but git fast-import cannot, last I
checked.  One would have to "know" what all the files were and recreate
them by hand, which was what fast-import's move/copy commands were
supposed to avoid.

Obviously this use case is not too important to me, as patches have not
been forthcoming to fix this, but I figured I'd mention it in case it's
important to somebody else.

-bcd


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Felipe Contreras
In reply to this post by Brian Downing
On Mon, Aug 25, 2008 at 7:35 PM, Brian Downing <[hidden email]> wrote:

> On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras wrote:
>> I developed a script that converts a monotone repository into a git
>> one (exact clone), I want to contribute it so everybody can use it.
>>
>> This is the gist of the script:
>>
>> mtn update --revision #{@id} --reallyquiet
>> git ls-files --modified --others --exclude-standard -z | git
>> update-index --add --remove -z --stdin
>> git write-tree
>> git write-raw < /tmp/commit.txt
>> git update-ref refs/mtn/#{@id} #{@git_id}
>>
>> branches.each do |e|
>>     git update-ref refs/heads/#{e} #{@git_id}
>> end
>
> You definitely want to use fast-import, but you probably want to do
> something a lot closer to fast-export for monotone (read: use its
> automate stdio interface and avoid expensive calls).
>
> Here's a simple monotone to git converter I wrote.  You'll need the
> Monotone::AutomateStdio perl module to use it (which I think I got it
> from monotone's net.venge.monotone.contrib.lib.automate-stdio branch).
> It is very fast; it can convert the OpenEmbedded repo in something like
> 5-10 minutes on my machine.

Interesting, how many commits?

> Note that for monotone export to go fast you absolutely /must/ avoid the
> get_manifest operation.  In my converter I use the revision information
> directly.  Getting the renames right with this is a little tricky; IIRC,
> the ordering that works is:
>
> * Rename all renamed files, innermost files first, to temporary names.
> * Delete all deleted files, innermost first.
> * Rename all temporary names to permanent names, outermost first.
> * Add all new/modified files.
>
> Conveniently, all of the above can be done by directly emitting
> fast-import commands, so you don't have to keep track of trees directly.
> (With one exception, which I'll elaborate on in a different email.)

I guess I haven't stumbled upon that problem yet =/

Best regards.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Brian Downing
On Mon, Aug 25, 2008 at 11:47:53PM +0300, Felipe Contreras wrote:
> On Mon, Aug 25, 2008 at 7:35 PM, Brian Downing <[hidden email]> wrote:
> > Here's a simple monotone to git converter I wrote.  You'll need the
> > Monotone::AutomateStdio perl module to use it (which I think I got it
> > from monotone's net.venge.monotone.contrib.lib.automate-stdio branch).
> > It is very fast; it can convert the OpenEmbedded repo in something like
> > 5-10 minutes on my machine.
>
> Interesting, how many commits?

:; git rev-list --all | wc -l
23498 revisions
:; git ls-tree -r org.openembedded.stable | wc -l
17502 files in HEAD

(Some of those files are .gitignore files, which I create in every
directory to hold open empty ones.)

-bcd


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Anand Kumria-2
In reply to this post by Felipe Contreras

Hi Felipe,

On Mon, 25 Aug 2008 03:45:11 +0300, Felipe Contreras wrote:

>
> Anyway, very nice tool. It's going much faster (1h) compared to before
> (1 day).

Will you be submitting this as something for/to contrib?

Thanks,
Anand



_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFC] mtn to git conversion script

Felipe Contreras
On Thu, Aug 28, 2008 at 8:57 AM, Anand Kumria <[hidden email]> wrote:

>
> Hi Felipe,
>
> On Mon, 25 Aug 2008 03:45:11 +0300, Felipe Contreras wrote:
>
>>
>> Anyway, very nice tool. It's going much faster (1h) compared to before
>> (1 day).
>
> Will you be submitting this as something for/to contrib?

Yes, that's the plan.

However, I still don't have something that creates an exact clone with
fast-import.

Also, I'm trying different ways to see what would be most efficient.
Right now it's a combination of Ruby + C, but once I get it working
I'll post it to the OE mailing lists to see if it works fine for them
too.

Once the design is good enough I might move everything to C.

Best regards.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFC] mtn to git conversion script

Felipe Contreras
On Thu, Aug 28, 2008 at 12:03 PM, Felipe Contreras
<[hidden email]> wrote:

> On Thu, Aug 28, 2008 at 8:57 AM, Anand Kumria <[hidden email]> wrote:
>>
>> Hi Felipe,
>>
>> On Mon, 25 Aug 2008 03:45:11 +0300, Felipe Contreras wrote:
>>
>>>
>>> Anyway, very nice tool. It's going much faster (1h) compared to before
>>> (1 day).
>>
>> Will you be submitting this as something for/to contrib?
>
> Yes, that's the plan.
>
> However, I still don't have something that creates an exact clone with
> fast-import.
>
> Also, I'm trying different ways to see what would be most efficient.
> Right now it's a combination of Ruby + C, but once I get it working
> I'll post it to the OE mailing lists to see if it works fine for them
> too.
>
> Once the design is good enough I might move everything to C.
>
> Best regards.

Ok, now the basics seem to be working. So I'm uploading some code if
anyone wants to take a look.

The C code is generating a topologically sorted list of revisions, and
storing the relevant information (certs and parents) separately. This
code is very fast. It's using GLib and sqlite3, so probably the GLib
stuff should be converted to use libgit.
http://gist.github.com/8742

The Ruby code takes that input and generates an output suitable for
fast-import. It would be tedious to port the parsing stuff to C, but
straightforward.
http://gist.github.com/8740

A patch for fast-import is required, I already submitted it.

Comments?

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFC] mtn to git conversion script

Jakub Narebski-2
"Felipe Contreras" <[hidden email]> writes:

> Ok, now the basics seem to be working. So I'm uploading some code if
> anyone wants to take a look.
>
> The C code is generating a topologically sorted list of revisions, and
> storing the relevant information (certs and parents) separately. This
> code is very fast. It's using GLib and sqlite3, so probably the GLib
> stuff should be converted to use libgit.
> http://gist.github.com/8742
>
> The Ruby code takes that input and generates an output suitable for
> fast-import. It would be tedious to port the parsing stuff to C, but
> straightforward.
> http://gist.github.com/8740
>
> A patch for fast-import is required, I already submitted it.
>
> Comments?

If you feel like it is good enough, could you add information about
this tool to Git Wiki:
  http://git.or.cz/gitwiki/InterfacesFrontendsAndTools
in the "Interaction with other Revision Control Systems" section?

TIA
--
Jakub Narebski
Poland
ShadeHawk on #git


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFC] mtn to git conversion script

Thomas Moschny
In reply to this post by Felipe Contreras
On Thu, Sep 4, 2008, Felipe Contreras wrote:
> Ok, now the basics seem to be working. So I'm uploading some code if
> anyone wants to take a look.
>
> The C code is generating a topologically sorted list of revisions, and
> storing the relevant information (certs and parents) separately. This
> code is very fast. It's using GLib and sqlite3, so probably the GLib
> stuff should be converted to use libgit.
> http://gist.github.com/8742

You shouldn't access Monotone's sqlite database directly, for various reasons.
Use the Automation Interface instead, see
http://www.monotone.ca/docs/Automation.html#Automation. Using 'mtn automate
stdio', you can feed an arbitrary amount of commands to one single running mtn
process.

- Thomas


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFC] mtn to git conversion script

Felipe Contreras
In reply to this post by Jakub Narebski-2
On Thu, Sep 4, 2008 at 1:31 PM, Jakub Narebski <[hidden email]> wrote:

> "Felipe Contreras" <[hidden email]> writes:
>
>> Ok, now the basics seem to be working. So I'm uploading some code if
>> anyone wants to take a look.
>>
>> The C code is generating a topologically sorted list of revisions, and
>> storing the relevant information (certs and parents) separately. This
>> code is very fast. It's using GLib and sqlite3, so probably the GLib
>> stuff should be converted to use libgit.
>> http://gist.github.com/8742
>>
>> The Ruby code takes that input and generates an output suitable for
>> fast-import. It would be tedious to port the parsing stuff to C, but
>> straightforward.
>> http://gist.github.com/8740
>>
>> A patch for fast-import is required, I already submitted it.
>>
>> Comments?
>
> If you feel like it is good enough, could you add information about
> this tool to Git Wiki:
>  http://git.or.cz/gitwiki/InterfacesFrontendsAndTools
> in the "Interaction with other Revision Control Systems" section?

Not yet.

It still needs to add the branches, tags, and HEAD.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFC] mtn to git conversion script

Felipe Contreras
In reply to this post by Thomas Moschny
On Thu, Sep 4, 2008 at 1:50 PM, Thomas Moschny <[hidden email]> wrote:

> On Thu, Sep 4, 2008, Felipe Contreras wrote:
>> Ok, now the basics seem to be working. So I'm uploading some code if
>> anyone wants to take a look.
>>
>> The C code is generating a topologically sorted list of revisions, and
>> storing the relevant information (certs and parents) separately. This
>> code is very fast. It's using GLib and sqlite3, so probably the GLib
>> stuff should be converted to use libgit.
>> http://gist.github.com/8742
>
> You shouldn't access Monotone's sqlite database directly, for various reasons.
> Use the Automation Interface instead, see
> http://www.monotone.ca/docs/Automation.html#Automation. Using 'mtn automate
> stdio', you can feed an arbitrary amount of commands to one single running mtn
> process.

I use mtn stdio when needed, that is, when doing it manually would be
too complicated (get_file). Doing it directly with sqlite3 is *very*
fast, I don't see any reason to not to do it.

Feel free to modify the code for stdio.

--
Felipe Contreras


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Juan Jose Comellas-4
In reply to this post by Brian Downing
I made some modifications to the script that converts Monotone repositories to Git to make it work with what I had. I also added support for renaming commit authors. To use the modified script just call it passing the name of the repository file as the first argument. You can add a second optional argument with the name of the file that holds the authors' names and email addresses. In this file you should have one line per commit author with the following format:

Firstname Lastname <[hidden email]>

This script still uses the AutomateStdio.pm Perl module that can be found in the net.venge.monotone.contrib.lib.automate-stdio branch of Monotone's main repository.

PS. I'm no Perl guru so there might be some bugs lurking in the code I added. It did work for my repositories, though.


On Mon, Aug 25, 2008 at 2:35 PM, Brian Downing <[hidden email]> wrote:
On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras wrote:
> I developed a script that converts a monotone repository into a git
> one (exact clone), I want to contribute it so everybody can use it.
>
> This is the gist of the script:
>
> mtn update --revision #{@id} --reallyquiet
> git ls-files --modified --others --exclude-standard -z | git
> update-index --add --remove -z --stdin
> git write-tree
> git write-raw < /tmp/commit.txt
> git update-ref refs/mtn/#{@id} #{@git_id}
>
> branches.each do |e|
>     git update-ref refs/heads/#{e} #{@git_id}
> end

You definitely want to use fast-import, but you probably want to do
something a lot closer to fast-export for monotone (read: use its
automate stdio interface and avoid expensive calls).

Here's a simple monotone to git converter I wrote.  You'll need the
Monotone::AutomateStdio perl module to use it (which I think I got it
from monotone's net.venge.monotone.contrib.lib.automate-stdio branch).
It is very fast; it can convert the OpenEmbedded repo in something like
5-10 minutes on my machine.

Note that for monotone export to go fast you absolutely /must/ avoid the
get_manifest operation.  In my converter I use the revision information
directly.  Getting the renames right with this is a little tricky; IIRC,
the ordering that works is:

* Rename all renamed files, innermost files first, to temporary names.
* Delete all deleted files, innermost first.
* Rename all temporary names to permanent names, outermost first.
* Add all new/modified files.

Conveniently, all of the above can be done by directly emitting
fast-import commands, so you don't have to keep track of trees directly.
(With one exception, which I'll elaborate on in a different email.)

-bcd


_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

mtn-to-git.pl (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] mtn to git conversion script

Juan Jose Comellas-4
In reply to this post by Brian Downing
I made some modifications to the script that converts Monotone
repositories to Git to make it work with what I had. I also added
support for renaming commit authors.

To use the modified script just call it passing the name of the
repository file as the first argument. You can add a second optional
argument with the name of the file that holds the authors' names and
email addresses. In this file you should have one line per commit
author with the following format:

Firstname Lastname <[hidden email]>

This script still uses the AutomateStdio.pm Perl module that can be
found in the net.venge.monotone.contrib.lib.automate-stdio branch of
Monotone's main repository.

I'm no Perl guru so there might be some bugs lurking in the code I
added. It did work for my repositories, though.

PS. Resending because I mistakenly sent the previous message as HTML mail.


On Mon, Aug 25, 2008 at 2:35 PM, Brian Downing <[hidden email]> wrote:

>
> On Sun, Aug 24, 2008 at 12:18:50PM +0300, Felipe Contreras wrote:
> > I developed a script that converts a monotone repository into a git
> > one (exact clone), I want to contribute it so everybody can use it.
> >
> > This is the gist of the script:
> >
> > mtn update --revision #{@id} --reallyquiet
> > git ls-files --modified --others --exclude-standard -z | git
> > update-index --add --remove -z --stdin
> > git write-tree
> > git write-raw < /tmp/commit.txt
> > git update-ref refs/mtn/#{@id} #{@git_id}
> >
> > branches.each do |e|
> >     git update-ref refs/heads/#{e} #{@git_id}
> > end
>
> You definitely want to use fast-import, but you probably want to do
> something a lot closer to fast-export for monotone (read: use its
> automate stdio interface and avoid expensive calls).
>
> Here's a simple monotone to git converter I wrote.  You'll need the
> Monotone::AutomateStdio perl module to use it (which I think I got it
> from monotone's net.venge.monotone.contrib.lib.automate-stdio branch).
> It is very fast; it can convert the OpenEmbedded repo in something like
> 5-10 minutes on my machine.
>
> Note that for monotone export to go fast you absolutely /must/ avoid the
> get_manifest operation.  In my converter I use the revision information
> directly.  Getting the renames right with this is a little tricky; IIRC,
> the ordering that works is:
>
> * Rename all renamed files, innermost files first, to temporary names.
> * Delete all deleted files, innermost first.
> * Rename all temporary names to permanent names, outermost first.
> * Add all new/modified files.
>
> Conveniently, all of the above can be done by directly emitting
> fast-import commands, so you don't have to keep track of trees directly.
> (With one exception, which I'll elaborate on in a different email.)
>
> -bcd

_______________________________________________
Monotone-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

mtn-to-git.pl (7K) Download Attachment