You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Neson Maxmelbin (RBEI/EMT5)" <Ma...@in.bosch.com> on 2011/02/21 15:24:19 UTC

Hook help

Hello .

I am trying to write a hook to prevent deletion of elements through a pre-commit hook.

My Plan is to execute "svn status" and then based on the o/p allow or deny.
But the problem is that the hook is being executed in the server and I see not now way to get the "working copy" path in the client machine which is required by the svn status command.
How do I come around this?

Do you have any examples?


Mit freundlichen Grüßen / Best regards
Maxmelbin Neson




Re: Betr.: RE: Hook help

Posted by Ch...@bcbsks.com.
Personally I run the svnlook changed command on the txn. This allows us to
see exactly what is being done on the changed files. If there is a delete
you can exit out and kill the commit. Here is the example written in
python:

look_cmd = "svnlook changed -t %s %s" % (txn, path)

for file in os.popen(look_cmd).readlines():
     line = file.splitlines()).
     chgedfiles.append(line))).
     changedFile = str(line))).
     changed = changedFile[6:-2] #This will show you what file is being
changed
     action = changedFile[2:3]      #This will show you what action is
being taken on the file. This includes: add, delete, and update.
     print(changed)
     print(action))


I later on block changes and deletes made only to tag directories.

Chris



                                                                                                                             
  From:       Jan Keirse <ja...@tvh.be>                                                                                 
                                                                                                                             
  To:         "users@subversion.apache.org" <us...@subversion.apache.org>                                                    
                                                                                                                             
  Date:       02/21/2011 09:07 AM                                                                                            
                                                                                                                             
  Subject:    Betr.: RE: Hook help.                                                                                          
                                                                                                                             






"Neson Maxmelbin (RBEI/EMT5)" <Ma...@in.bosch.com> schreef op
21/02/2011 15:54:24:

>
> > I am trying to write a hook to prevent deletion of elements through a
> pre-commit hook.
>
>
> >>If you're not using the bindings you'd want svnlook, probably svnlook
> diff.
>
> >>But, do you really want such a hook? If a user has permission to add
> stuff they should be allowed to also unwind any mistakes, providing it's
> not a tag or something.
>
>
> Max : What do you mean by bindings?
> And also svnlook seems to give info about already commited stuff..
> Svnlook changed gives me info abt previous commit... (unless I got
> everything wrong .. :-) )
>
> Yes, I want to have deletion control on atleast one repo.


The pre-commit hook will get two input parameters. The first is the
repostiory path, the second is the transaciton ID.
You need to pass this to svnlook:
svnlook diff c:\somerepository --transaction sometransactionId
This will allow you to watch the commit that's begin executed.
Have a look at the manual:
http://svnbook.red-bean.com/nightly/en/index.html In this case you need
http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svnlook
  but if you have not yet read the entire manual, you really should, it
will save you a lot of time and headaches!**** DISCLAIMER ****

http://www.tvh.com/newen2/emaildisclaimer/default.html

"This message is delivered to all addressees subject to the conditions
set forth in the attached disclaimer, which is an integral part of this
message."




CONFIDENTIALITY NOTICE: This email message and any attachments are for the sole use of the intended recipient(s) and may contain proprietary, confidential, trade secret or privileged information.  Any unauthorized review use, disclosure or distribution is prohibited and may be a violation of law.  If you are not the intended recipient or a person responsible for delivering this message to an intended recipient, please contact the sender by reply email and destroy all copies of the original message.

Re: Betr.: RE: Hook help

Posted by ankush chadha <an...@yahoo.com>.
> 

> > I am trying to write a hook to prevent deletion of elements through a
> pre-commit hook.
> 
> 
> >>If you're not using the bindings you'd want svnlook, probably svnlook
> diff.
> 
> >>But, do you really want such a hook? If a user has permission to add
> stuff they should be allowed to also unwind any mistakes, providing it's
> not a tag or something.
> 
> 
> Max : What do you mean by bindings?
> And also svnlook seems to give info about already commited stuff.. 
> Svnlook changed gives me info abt previous commit... (unless I got 
> everything wrong .. :-) )
> 
> Yes, I want to have deletion control on atleast one repo.
 

> The pre-commit hook will get two input parameters. The first is the repostiory 
>path, the second is the 
>
> transaciton ID.  
> You need to pass this to svnlook:  
> svnlook diff c:\somerepository --transaction sometransactionId 
> This will allow you to watch the commit that's begin executed.  
> Have a look at the manual: http://svnbook.red-bean.com/nightly/en/index.htmlIn 
>this case you 
>need http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svnlook but
> if > you have not yet read the entire manual, you really should, it will save 
>you a lot of time and headaches!


A different approach to solve the problem of tracking deletes

What we do is during the post-commit event, we identify the operation. 

If the revision consists of a delete operation, we add buzz words  such as 
delete in the subject of the post-commit email. 


In this way, developers have freedom to delete trivial stuff and at the same 
time managers can track of deletes.

Ankush


      

Betr.: RE: Hook help

Posted by Jan Keirse <ja...@tvh.be>.
"Neson Maxmelbin (RBEI/EMT5)" <Ma...@in.bosch.com> schreef op 
21/02/2011 15:54:24:

> 
> > I am trying to write a hook to prevent deletion of elements through a
> pre-commit hook.
> 
> 
> >>If you're not using the bindings you'd want svnlook, probably svnlook
> diff.
> 
> >>But, do you really want such a hook? If a user has permission to add
> stuff they should be allowed to also unwind any mistakes, providing it's
> not a tag or something.
> 
> 
> Max : What do you mean by bindings?
> And also svnlook seems to give info about already commited stuff.. 
> Svnlook changed gives me info abt previous commit... (unless I got 
> everything wrong .. :-) )
> 
> Yes, I want to have deletion control on atleast one repo.


The pre-commit hook will get two input parameters. The first is the 
repostiory path, the second is the transaciton ID. 
You need to pass this to svnlook: 
svnlook diff c:\somerepository --transaction sometransactionId
This will allow you to watch the commit that's begin executed. 
Have a look at the manual: 
http://svnbook.red-bean.com/nightly/en/index.html In this case you need 
http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svnlook 
 but if you have not yet read the entire manual, you really should, it 
will save you a lot of time and headaches!
**** DISCLAIMER ****

http://www.tvh.com/newen2/emaildisclaimer/default.html 

"This message is delivered to all addressees subject to the conditions
set forth in the attached disclaimer, which is an integral part of this
message."

RE: Hook help

Posted by "Neson Maxmelbin (RBEI/EMT5)" <Ma...@in.bosch.com>.
> I am trying to write a hook to prevent deletion of elements through a
pre-commit hook.


>>If you're not using the bindings you'd want svnlook, probably svnlook
diff.

>>But, do you really want such a hook? If a user has permission to add
stuff they should be allowed to also unwind any mistakes, providing it's
not a tag or something.


Max : What do you mean by bindings?
And also svnlook seems to give info about already commited stuff.. Svnlook changed gives me info abt previous commit... (unless I got everything wrong .. :-) )

Yes, I want to have deletion control on atleast one repo.

jamie


===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================


RE: Hook help

Posted by "Echlin, Jamie" <ja...@credit-suisse.com>.
> I am trying to write a hook to prevent deletion of elements through a
pre-commit hook.

If you're not using the bindings you'd want svnlook, probably svnlook
diff. 

But, do you really want such a hook? If a user has permission to add
stuff they should be allowed to also unwind any mistakes, providing it's
not a tag or something.

jamie


=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
===============================================================================