Re: [fossil-users] TH1 Hooks.

2014-10-07 Thread Joe Mistachkin

Andy Bradford wrote:

 If   Iconfigure   the   FOSSIL_ENABLE_TH1_HOOKS(e.g.   configure
 --with-th1-hooks) what does that get me?  I assume from the code that it
 will call Th_CommandHook  passing in the name and flags,  but to what in
 the TH1  environment? My guess  is that I need  a function by  a certain
 name, but what? Is there any documentation on using TH1 hooks? 
 

First, you would need to enable the th1-hooks setting.

Then, you would normally need a th1-setup script, set via the settings
command or a .fossil-settings file.  There would need to be a procedure
defined named command_hook (and/or command_notify), e.g.:

proc command_hook {} {
  if {$::cmd_name eq timeline} {
puts $::cmd_args\n
puts preparing the timeline... [tclEval {info patchlevel}]\n\n
  }
}

proc command_notify {} {
  if {$::cmd_name eq timeline} {
puts $::cmd_args\n
puts timeline completed. [tclEval {info patchlevel}]\n\n
  }
}

The hook procedure is evaluated prior to the actual command and the notify
procedure is evaluated after the command.  In the above example, which was
used for testing, I also made use of the native Tcl integration feature.

--
Joe Mistachkin

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] TH1 Hooks.

2014-10-07 Thread Ron W
On Tue, Oct 7, 2014 at 12:06 PM, Joe Mistachkin sql...@mistachkin.com
wrote:

 Then, you would normally need a th1-setup script, set via the settings
 command or a .fossil-settings file.  There would need to be a procedure
 defined named command_hook (and/or command_notify), e.g.:

 proc command_hook {} {
   if {$::cmd_name eq timeline} {
 puts $::cmd_args\n
 puts preparing the timeline... [tclEval {info
 patchlevel}]\n\n
   }
 }

 proc command_notify {} {
   if {$::cmd_name eq timeline} {
 puts $::cmd_args\n
 puts timeline completed. [tclEval {info patchlevel}]\n\n
   }
 }

 The hook procedure is evaluated prior to the actual command and the notify
 procedure is evaluated after the command.


What's in $::cmd_args ? Is it just the command line (or command URL)?

In command_notify, after a commit, is the commit ID included? What about
ticket and wiki writes?
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] TH1 Hooks.

2014-10-07 Thread Joe Mistachkin

Ron W wrote:

 What's in $::cmd_args ? Is it just the command line (or command URL)?


The command line arguments, just as they existed in the g.argv field at
that point.  It should be noted that the command line arguments _cannot_
currently be modified by the hook, only inspected.


 In command_notify, after a commit, is the commit ID included? What about
 ticket and wiki writes?


No.  Only the cmd_name, cmd_args, and cmd_flags TH1 variables are
specially set.  However, you are free to use TH1 (and Tcl if enabled) to
determine any additional context information you may need.

--
Joe Mistachkin

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users