0

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?

martinako
  • 2,690
  • 1
  • 25
  • 44

2 Answers2

2

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'))
Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
martinako
  • 2,690
  • 1
  • 25
  • 44
1

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.

Amey Kumar Samala
  • 904
  • 1
  • 7
  • 20