Ignore some mercury commands in the mercury hook

I have a mercurial hook like this:

[hooks]
pretxncommit.myhook = python:path/to/file:myhook

The code is as follows:

def myhook(ui, repo, **kwargs):
    #do some stuff

but this hook works with commands that use commit logic to do something else, in my case hg shelve. is there any way to get the command that the user enters to avoid running this command?

maybe something like this:

def myhook(ui, repo, command, **kwargs):
      if command is "hg shelve"
           return 0
      #do some stuff
+4
source share
1 answer

Unfortunately, the answer seems no. I was just debugging the hg 3.1 hook mechanism, and the information about which command was issued does not apply to the hook function. The only way I can think of is to crack something ugly with the api debugger to extract information from the call stack.

- sys.argv, , ( , - ).

BTW :

def myhook(ui, repo, **kwargs):
    print kwargs
    from pdb import set_trace
    set_trace()
+2

All Articles