Clean way of extracting rename information from mercurial
Dustin Sallings
dustin at spy.net
Wed Nov 28 11:36:58 CST 2007
[please excuse me for replying to myself]
On Nov 28, 2007, at 9:05, Dustin Sallings wrote:
> There's an api provided by mercurial that will do that for you. I
> don't remember exactly what it is since I don't have a computer out,
> but I have a program that relies on it.
Here's an example program that will read a git style diff and print
out all of the renames. If there are any reliability problems with
it, they'd be fatal to mercurial:
#########################################
#!/usr/bin/env python
import sys
import mercurial.patch
f=open(sys.argv[1])
num, patches=mercurial.patch.readgitpatch(f)
f.close()
for patch in [p for p in patches if p.op == 'RENAME']:
print "%s -> %s" % (patch.oldpath, patch.path)
#########################################
I made a test patch by exporting a patch that contained a rename. It
sounds like you may already have such a thing, though.
--
Dustin Sallings
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20071128/94dfbdc5/attachment.htm
More information about the Mercurial
mailing list