props tsvn:*hook expierences

37 views
Skip to first unread message

Oto BREZINA

unread,
Sep 3, 2022, 5:37:46 AM9/3/22
to TortoiseSVN
Hi,

as I outlined in dev group I have been (after long time) updating TSvn hook script and related setting in our repositories.

What I got
----------
consider following repository layout (hopefuly ascii art will get thru)

(root)
 - trunk/
 - - hooks/ [ext link to (root)/hooks]
 - - - hook.js
 - - foo/
 - branches/
 - - test/
 - - - hooks/ [ext link to (root)/hooks]
 - - - - hooks.js
 - - - bar/
 - hook/
 - - hooks.js

and following WCs

WC-root checked out from (root)
WC-trunk checked out from trunk
WC-branches checked out from branches
WC-test checked out from branches/test

What I want
-----------
for sake of simplicity I will focus on startprecommithook as it is simplest to invoke and I believe all other script will follow same rules.

start commiting any of this will start hook script
WC-root
WC-root/trunk
WC-root/trunk/* - any file within trunk
WC-root/branches
WC-root/branches/*
WC-root/branches/test

wc-trunk
wc-trunk/*

WC-branches
WC-branches/test
WC-branches/test/*

WC-test
WC-test/*

note:
 - I'm not picky in what copy script should run as they are same
 - I have no particular behavior in mind yet for commiting foo and bar, but invoking script if expected

What I've tried
---------------
note: when taking about what script has run I'm using path from start script confimation dialog, if more paths was tried i dont see it.
note: it seems there is no differece if startprecommithook is set directly or inherited

I will set startcommithook to something like 'wscript %REPOROOT%/hooks/hook.js startcommithook' trying different path

1) WC-root
a) %REPOROOT%/hooks/hook.js
- (root), (root)/*, (root)/*/ -> WC-root/hooks/hook.js = OK
- */*/ e.g. branches/*/ -> WC-root/branches/hooks/hook.js = not good
b) %REPOROOT+%/hooks/hook.js
- NONE commits ask for confirmation to start hook
= not expected
c) ./hooks/hook.js
- (root), trunk, branches\test -> their copy of hook is ran = good
- anything else -> script is not found = expected


2) WC-trunk, WC-test (honesly I tested only WC-trunk, but should be same)
a) %REPOROOT%/hooks/hook.js
- (root), * -> run hook from outside of WC = really bad
- foo/, foo/* -> WC-trunk/hooks/hook.js = OK
- foo/*/ -> WC-trunk/foo/hooks/hook.js = not good
- hooks/ -> no invocation = ok

b) %REPOROOT+%/hooks/hook.js
- any commit (except hooks) run WC-trunk/hooks/hook.js = OK


3) WC-branches
a) %REPOROOT%/hooks/hook.js
- (root), * -> run hook from outside of WC = really bad
- test/, test/* -> WC-branches/hooks/hook.js = does not exists
- test/bar/, test/bar/* -> WC-branches/test/hooks/hook.js = OK
- test/bar/*/, test/bar/*/* -> WC-branches/test/bar/hooks/hook.js = does not exists

b) %REPOROOT+%/hooks/hook.js
- (root), * -> nothing is run = somewhat unexpected
- test/, test/*, test/... -> WC-branches/test/hooks/hook.js = OK

c) %REPOROOT%/test/hooks/hook.js
- (root), *, test/, test/* -> WC-branches/test/hooks/hook.js = OK
- test/bar/, test/bar/* -> WC-branches/test/test/hooks/hook.js = does not exists
- test/bar/*/, test/bar/*/* -> WC-branches/test/bar/test/hooks/hook.js = does not exists

d) %REPOROOT+%/test/hooks/hook.js
- all commits -> WC-branches/test/hooks/hook.js = OK


4) mixing it all together
(root) - %REPOROOT%/hooks/hook.js
 - trunk/ - %REPOROOT+%/hooks/hook.js
 - - hooks/ [ext link to (root)/hooks]
 - - - hook.js
 - - foo/
 - branches/ - %REPOROOT+%/test/hooks/hook.js (or %REPOROOT%/test/hooks/hook.js)
 - - test/ - %REPOROOT+%/hooks/hook.js (also copied when branching)
 - - - hooks/ [ext link to (root)/hooks]
 - - - - hooks.js
 - - - bar/
 - hook/
 - - hooks.js

In following test it does not matter what folder is WC based on
- (root), *, */ - (root)/hooks/hook.js = OK
- trunk/, trunk/... - trunk/hooks/hook.js = OK
- branches/, branches/... - branches/test/hooks/hook.js = OK

After a long day I finaly got setup which seems workable.

final results and notes
-----------------------
- after all it seems inherited or explicit value gives not the same result (e.g. base folder changes)
- using %REPOROOT+% on (root) does not run any script what is somewhat unexpected
- it would be great to have this solution (or similar) online in documentation there is some cryptic information, but it is somewhat hard to follow (maybe im just getting old) e.g. https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-propertypage.html#tsvn-dug-propertypage-tsvn-props
- %REPOROOT% should never try to run script outside of WC, e.g. WC based on bar
- is there way to disable script for bar if its parrent have script set (for case it is WC base)
- using cancel in 'Approve or reject client-side hook script' gives error 'The hook script returned an error: User cancelled' for this case I like no error message.
- It may be good to have warning (similar to new version is avalable) in commit dialog that hook was not approvedin if 'Don't run' was used
- in Properties dialog
- - you are allowed to use remove on inherited value, but it turn it does nothing (except asking if remove recursively or not)
- - you can see all parents values (i would expect to see only inherited one, at least order should be reversed so closer parent is closer to local value)
- - in context menu having option to turn inherited into local would be nice too
- - in context menu having option andvaced edit will help as well
- trying to run update on multiple WCs may end up with error "Error: The hook script returned an error:  Error: The system cannot find the file specified.' with no hint on WC


Stefan

unread,
Sep 6, 2022, 1:35:28 PM9/6/22
to TortoiseSVN
%REPOROOT% refers to the repo root. So you have so specify
%REPOROOT%/trunk/hooks/hook.js
 
using %REPOROOT+% instead of %REPOROOT% helps if you only check out from trunk, or branches/branchXXX with branches created from trunk and having the hooks/hook.js.

%REPOROOT+%/hooks/hook.js
should do the trick.

final results and notes
-----------------------
- after all it seems inherited or explicit value gives not the same result (e.g. base folder changes)
- using %REPOROOT+% on (root) does not run any script what is somewhat unexpected
- it would be great to have this solution (or similar) online in documentation there is some cryptic information, but it is somewhat hard to follow (maybe im just getting old) e.g. https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-propertypage.html#tsvn-dug-propertypage-tsvn-props
- %REPOROOT% should never try to run script outside of WC, e.g. WC based on bar

this is why the script is only run if a user confirms running it.
 
- is there way to disable script for bar if its parrent have script set (for case it is WC base)

Sorry, no.
 
- using cancel in 'Approve or reject client-side hook script' gives error 'The hook script returned an error: User cancelled' for this case I like no error message.

I'll consider changing that.
 
- It may be good to have warning (similar to new version is avalable) in commit dialog that hook was not approvedin if 'Don't run' was used

sorry, but the commit dialog is crowded with controls as it is. If you didn't approve it then you know you didn't.
 
- in Properties dialog
- - you are allowed to use remove on inherited value, but it turn it does nothing (except asking if remove recursively or not)
- - you can see all parents values (i would expect to see only inherited one, at least order should be reversed so closer parent is closer to local value)

actually that's a 'feature' of svn: all properties are inherited by default. But only a few actually use the inheritance.
 
- - in context menu having option to turn inherited into local would be nice too
- - in context menu having option andvaced edit will help as well
- trying to run update on multiple WCs may end up with error "Error: The hook script returned an error:  Error: The system cannot find the file specified.' with no hint on WC

I'll try to extend the error message.
 

Oto BREZINA

unread,
Sep 6, 2022, 2:47:53 PM9/6/22
to TortoiseSVN
On Tuesday, September 6, 2022 at 7:35:28 PM UTC+2 Stefan wrote:
On Saturday, September 3, 2022 at 11:37:46 AM UTC+2 htc...@gmail.com wrote:

...


What I've tried
---------------
note: when taking about what script has run I'm using path from start script confimation dialog, if more paths was tried i dont see it.
note: it seems there is no differece if startprecommithook is set directly or inherited

I will set startcommithook to something like 'wscript %REPOROOT%/hooks/hook.js startcommithook' trying different path

1) WC-root
a) %REPOROOT%/hooks/hook.js

%REPOROOT% refers to the repo root. So you have so specify
%REPOROOT%/trunk/hooks/hook.js
 
using %REPOROOT+% instead of %REPOROOT% helps if you only check out from trunk, or branches/branchXXX with branches created from trunk and having the hooks/hook.js.

%REPOROOT+%/hooks/hook.js
should do the trick.


As I tried to write after lot of testing I got it wokring, just manual could contain simple example (HOW TO USE) besides explanation (HOW IT WORKS). After setting on multiple WCs it turned out quotes may be necessary to use may be good to point it out.


final results and notes
-----------------------
- after all it seems inherited or explicit value gives not the same result (e.g. base folder changes)
- using %REPOROOT+% on (root) does not run any script what is somewhat unexpected
- it would be great to have this solution (or similar) online in documentation there is some cryptic information, but it is somewhat hard to follow (maybe im just getting old) e.g. https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-propertypage.html#tsvn-dug-propertypage-tsvn-props
- %REPOROOT% should never try to run script outside of WC, e.g. WC based on bar

this is why the script is only run if a user confirms running it.

Yeah kinda true, but I would still like not expanding outside WC, not sure what to do then thou.
 
 
- is there way to disable script for bar if its parrent have script set (for case it is WC base)

Sorry, no.

echo. it is :)

 
- using cancel in 'Approve or reject client-side hook script' gives error 'The hook script returned an error: User cancelled' for this case I like no error message.

I'll consider changing that.

THX for considering.
 
- It may be good to have warning (similar to new version is avalable) in commit dialog that hook was not approvedin if 'Don't run' was used

sorry, but the commit dialog is crowded with controls as it is. If you didn't approve it then you know you didn't.

I will try to think about it. I'm not 100% fan of bubble when manual script ends. Nice, but kinda used only there so looks out of place.
 
 
- in Properties dialog
- - you are allowed to use remove on inherited value, but it turn it does nothing (except asking if remove recursively or not)
- - you can see all parents values (i would expect to see only inherited one, at least order should be reversed so closer parent is closer to local value)

actually that's a 'feature' of svn: all properties are inherited by default. But only a few actually use the inheritance.

I will write separate email about this menu.
 
 
- - in context menu having option to turn inherited into local would be nice too
- - in context menu having option andvaced edit will help as well
- trying to run update on multiple WCs may end up with error "Error: The hook script returned an error:  Error: The system cannot find the file specified.' with no hint on WC

I'll try to extend the error message.

maybe simple "progress" messages would be sufficient. e.g
starting pre-commit hook on c:\where\ever\your\WC\is

 
Reply all
Reply to author
Forward
0 new messages