No announcement yet.

Add file to repository in post-commit hook

  • Filter
  • Time
  • Show
Clear All
new posts

  • Add file to repository in post-commit hook

    Hi all,

    Is it possible to add new file to Repository in post-commit hooks.

    when users checkin the files, the new file need to be added to the repository which contains commit comments given by the user.

    for second time checkin(same file) need to append the file which already added.

    Can i do this by using svn.exe add command... ?

    Is it possible...

    Thanks in advance

  • #2
    Yes, but it is not trivial. A commit executed from a post-commit will trigger the post-commit again so you need to detect this and avoid infinite recursion. This is probably best done by using a distinct user to execute the commit from the post-commit, but it could be also be done by using an identifiable log message or some other identifiable commit change. The second difficulty is that post-commit is asynchronous so there is no guarantee that the post-commits run in the same order as the original commits. Finally, if revprop editing is enabled the log message associated with old revisions can be modified.


    • #3
      Thanks philip,

      svn.exe add file - just add the file to the working copy. how can add the file to the Repository instead of working copy.

      Is it possible ??? bcoz we are not maintaining the working copy at server side... & working on server side hooks scripts not client side.


      • #4
        Yes, it is possible.

        It's also very possible for it to become recursive and cripple your repository.

        You will have to maintain a working copy server side. There is no way around this.

        As I have told you many times before here, what you are attempting to do is a bad idea and you should not be doing it.

        There is absolutely no reason to be appending to a file which is stored in the repository with the contents of the commit message, or a note about what file was just added. This is what the log is for in the first place, so use it.


        • #5
          Thanks all,

          I have another ques,

          How can i get url path in post-commit hook.

          For eg: svn://localhost:3939/Users/Satheesh/Desktop/SVN/svn1.7.6/Repos is my URL Path of my repository.



          • #6
            svnlook changed will tell you the paths in the repository which changed. You can then create the URL using that knowledge and the knowledge of how your repository is configured.

            A configuration which is currently very inadvisable, as you're running the repository out of a folder on a user's desktop.