mercurial --> plain text --> mercurial

Matt Mackall mpm at selenic.com
Thu Mar 27 12:05:04 CDT 2008


On Thu, 2008-03-27 at 16:56 +0000, didier deshommes wrote:
> Matt Mackall <mpm <at> selenic.com> writes:
> 
> > 
> > 
> > On Thu, 2008-03-27 at 14:24 +0000, didier deshommes wrote:
> > > Hi everyone,
> > > Sage (http://www.sagemath.org/) uses hg for its source control and recently a
> > > question has come up about the possibility of doing the following:
> > > 
> > >  (1) export everything in the .hg repo to something (perhaps a ton of
> > > stuff) in plain text format,
> > >  (2) delete .hg/ directory
> > >  (3) do something that recovers the .hg/ directory from the output of (1).
> > 
> > This will work for the export side:
> > 
> > #!/usr/bin/env python
> > import sys
> > from mercurial import revlog, node
> > 
> > for f in sys.argv[1:]:
> >     r = revlog.revlog(open, f)
> >     print "file:", f
> >     for i in xrange(r.count()):
> >         n = r.node(i)
> >         p = r.parents(i)
> >         d = r.revision(n)
> >         print "node:", node.hex(n)
> >         print "linkrev:", r.linkrev(n)
> >         print "parents:", node.hex(p[0]), node.hex(p[1])
> >         print "length:", len(d)
> >         print "-start-"
> >         print d
> >         print "-end-"
> > 
> > Then you can do something like:
> > 
> > find .hg/store -name "*.i" | xargs ./dumprevlog > repo.dump 
> 
> Hi Matt,
> Thanks for the script. we don't have .hg/store, but we don have .hg/data. We
> still got this error:
> """
> dfdeshom at sage:~/custom/sage/devel/sage-hg$ find .hg/data -name "*.i" | xargs
> ./dumprevlog > repo.dump
> Traceback (most recent call last):
>   File "./dumprevlog", line 10, in <module>
>     p = r.parents(i)
>   File "/home/dfdeshom/bin/hg/lib/python2.5/site-packages/mercurial/revlog.py",
> line 528, in parents
>     d = self.index[self.rev(node)][5:7]
>   File "/home/dfdeshom/bin/hg/lib/python2.5/site-packages/mercurial/revlog.py",
> line 522, in rev
>     raise LookupError(node, self.indexfile, _('no node'))
> mercurial.revlog.LookupError: .hg/data/c_lib/ChangeLog.i at 0: no node

I made a last minute change before posting the script. You instead need:

        p = r.parents(n)

I'm about to test an undumper, so I'll post both scripts in a bit.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list