Announcement

Collapse
No announcement yet.

Accessing message of LOCK in pre-lock hook script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing message of LOCK in pre-lock hook script

    Hello forum,

    is there a possibility to access the message text of a LOCK command inside the pre-lock script?

    Ciao

    Olaf

  • #2
    Hi,

    did you ever tried to do "svnlook lock ..." ?

    Kind regards
    Karl Heinz Marbaise

    Comment


    • #3
      Hi,

      maybe this code snippet will help.

      ----------pre-lock.bat --------------

      @echo off

      set SVN_REPOS=%1
      set SVN_PATH=%2
      set SVN_USER=%3

      set lock_owner=""
      set lock_message=""

      ...

      for /f "skip=5 tokens=*" %%U in ('svnlook lock %SVN_REPOS% %SVN_PATH%') do (
      set lock_message=%%U
      )

      @echo on
      if not "%lock_message%" == "" echo Lock message: %lock_message% 1>&2
      echo Sorry %SVN_USER%. Error: %SVN_PATH% locked by %lock_owner%. 1>&2
      exit 1

      -------------------------------------

      Regards
      Boris Zelenkapić

      Comment


      • #4
        run script on window

        Hi,
        Based on your idea,I changed pre-lock.tmpl into pre-lock.bat but I don'r know to process this code :
        :lock_owner=`$svnlook lock "$SVN_REPOS" "$SVN_PATH" | \
        : $GREP '^Owner: ' | $SED 's/Owner: //'`

        I don't know output of this command is input of the another command.
        Could you help me!






        set SVN_REPOS=%1
        set SVN_PATH=%2
        set SVN_USER=%3

        set svnlook=FIND C:\Program Files\VisualSVN Server\bin\svnlook.exe

        set lock_owner=svnlook lock %SVN_REPOS% %SVN_PATH%

        :lock_owner=`$svnlook lock "$SVN_REPOS" "$SVN_PATH" | \
        : $GREP '^Owner: ' | $SED 's/Owner: //'`

        if %lock_owner% == "" exit 0
        if %lock_owner% == %SVN_USER% exit 0
        echo Sorry %SVN_USER%. Error: %SVN_PATH% locked by %lock_owner%. 1>&2
        exit 1

        Comment


        • #5
          This is the whole script for my pre-lock hook.
          Code:
          @echo off
          
          set SVN_REPOS=%1
          set SVN_PATH=%2
          set SVN_USER=%3
          
          set lock_owner = ""
          set lock_message = ""
          
          REM Skip one row of output, take second token, and delimiter is " "
          for /f "skip=1 tokens=2" %%U in ('svnlook lock %SVN_REPOS% %SVN_PATH%') do (
            set lock_owner=%%U
            goto :check_owner
          )
          
          :check_owner
          if "%lock_owner%" == "" exit 0
          if "%lock_owner%" == "%SVN_USER%" exit 0
          
          for /f "skip=5 tokens=*" %%U in ('svnlook lock %SVN_REPOS% %SVN_PATH%') do (
            set lock_message=%%U
          )
          
          @echo on
          if not "%lock_message%" == "" echo Lock message: %lock_message% 1>&2
          echo Sorry %SVN_USER%. Error: %SVN_PATH% locked by %lock_owner%. 1>&2
          exit 1
          This script requires that svn is a part of your Path environment variable. Test this with next code in cmd.
          Code:
          C:\xxx\yyy>svnlook help lock
          @matbuon02
          And output of this command is answer on your question.
          Code:
          lock: usage: svnlook lock REPOS_PATH PATH_IN_REPOS
          If a lock exists on a path in the repository, describe it.

          Comment


          • #6
            Thanks for your help!

            Thank you so much.I will try your script.It's useful!

            Comment


            • #7
              Thanks for your help!

              Thank you so much.I will try your script.It's useful!

              Comment


              • #8
                guys I have a problem of pre lock hook, because when I give the lock with this other person matriculation taking this lock, and I need help for the same person who made the lock so she could strip has q how to do this, please help

                Comment


                • #9
                  Hi,

                  Can you try and explain a little clearer what you are trying to accomplish? Also any outputs or errors you are currently getting will be useful.

                  Thanks in advance.

                  Comment

                  Working...
                  X