hglib: show patches for a revision, possible?

200 views Asked by At

I'm trying to get the patches for a given revision using hglib. I know the hg command is

hg log -pr rev

but I can't find how to do this or equivalent with hglib. It seems there is not functionality to do that, unless I hack the code myself to run the above command. Any help would be greatly appreciated?

2

There are 2 answers

0
martinako On BEST ANSWER

The hglib client.log() interface doesn't support what I wanted to do, but I found a simple way to run an arbitrary hg command. This two lines print the patch of revision rev:

out = client.rawcommand([b'log', b'-pr', b'%i'%rev])
print(str(out, 'utf-8'))
0
Amey Kumar Samala On

May be this is the actual answer!

import hglib
client = hglib.open(<path>)
client.export (revs = str(<revision number>), output = <output file path>)

You can execute the same with subprocess package by yourself to save interpretation time. Rawcommand just builds a command with the parameters we pass and executes with subprocess again.