On Sun, Jan 11, 2009 at 7:03 AM, Steve Borho <[email protected]> wrote:

> Has anyone ever successfully made Mercurial use a python hook or extension
> without having python installed on their machine.
> In other words, have you been able to make the bundled python interpreter
> run python that wasn't packaged in library.zip?


I've gotten the bundled python interpreter to load extensions not bundled in
library.zip (absolute path on rhs in %HOMEPATH%\Mercurial.ini)...

Native installed python (python:extmodule.function) hooks, on the other hand
don't work as well.  You can still specify an absolute path to a python file
(without python:), but since it executes in a subshell, you'll only be able
to access the variables passed through the os.environ dict.

If you have the time a patience, you can get native hooks working another
way:

1) All extensions in the binary distribution's Mercurial.ini MUST load
correctly
2) Write an extension that, from uisetup, calls ui.setconfig with the
appropriate section and name.  BUT- Instead of passing a string for value,
pass a callable (defined or imported elsewhere by your extension)

This is in some c:\src\share\hgext\myhooks.py:
>>>
def dosomething(*args, **kwargs):
    print "---- BEGIN my hook ----"
    for k, v in kwargs.iteritems():
        print "%s: %s"%(k, str(v))
    print "---- END my hook ----"

def uisetup(ui):
    ui.setconfig('hooks', 'pre-commit.peekvalues', dosomething)
<<<
Adding the following section to the repository or user local
hgrc/mercurial.ini:
>>>
[extensions]
myhooks=c:\src\share\hgext\myhooks.py
<<<

Will load said hook for a pre-commit command hook:
>>>
C:\foo\test4>hg -v --traceback commit
---- BEGIN my hook ----
repo: <hgext.mq.mqrepo object at 0x02A39470>
args: -v --traceback commit
ui: <mercurial.ui.ui object at 0x024B6570>
hooktype: pre-commit
---- END my hook ----
nothing changed
<<<



>
>
> This is one of those things I've wondered about for a while, but have never
> tried.
>
> --
> Steve
>
>
Hope this helps!

-- 
Peter Ruibal
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to