Search code examples
pythonmercurialhglib

hglib: show patches for a revision, possible?


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?


Solution

  • 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'))