[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

svnlook propget doesn't work for replaced files in pre-commit hook

From: Tsahi Asher <tsahi_75_at_yahoo.com>
Date: Wed, 11 Mar 2009 01:42:12 -0700 (PDT)

hi,
i've created this pre-commit.bat hook to check committed .resx files have the svn:needs-lock=* property. it works fine for existing or new files, but not for replaced files (i.e. when you delete a .resx file, and add a new file by the same name, in the same commit). the second svnlook command doesn't produce output for some reason, and the hook fails and prevents the commit. i checked that the new file has the svn:needs-lock property set.
the first svnlook command produces two lines for the file, one for deleting (status D) and one for adding the new file (status A). for example,

D Fantasy.NET/trunk/Fantasy.Presentation/AboutBoxForm.resx
A Fantasy.NET/trunk/Fantasy.Presentation/AboutBoxForm.resx

the bat file:

set REPOS=%1
set TXN=%2

rem check that .resx files have svn:needs-lock property set
set error=0
rem %%A gets status, the implicit %%B gets file path for each line svnlook prints
for /f "usebackq tokens=1,2" %%A in (`"C:\Program Files (x86)\Subversion\bin\svnlook" -t %TXN% changed %REPOS%`) do (
  if not %%A == D (
    rem %%~xB extracts the extension from the path
    if %%~xB == .resx (
      for /f "usebackq tokens=1" %%C in (`"C:\Program Files (x86)\Subversion\bin\svnlook" -t %TXN% propget %REPOS% svn:needs-lock %%B 2^>^&1`) do (
        if not %%C == * (
          rem echo to stderr
          echo %%B should have a svn:needs-lock=* property >&2
          set error=1
        )
      )
    )
  )
)
if not %error% == 0 (
  echo Goto TortoiseSVN settings ^> Edit button, add the following line to [auto-props]: >&2
  echo *.resx = svn:needs-lock >&2
  echo and make sure you set >&2
  echo enable-auto-props = yes >&2
  exit /b 1
)

 --
The day Micro$oft sells something that doesn't SUCK
is the day they start selling vacuum cleaners.
http://www.geocities.com/tsahi_75

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1307008

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-03-11 09:43:05 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.