2 # ====================================================================
3 # Copyright (c) 2004 CollabNet. All rights reserved.
5 # This software is licensed as described in the file COPYING, which
6 # you should have received as part of this distribution. The terms
7 # are also available at http://subversion.tigris.org/license.html.
8 # If newer versions of this license are posted there, you may use a
9 # newer version instead, at your option.
11 # This software consists of voluntary contributions made by many
12 # individuals. For exact contribution history, see the revision
13 # history and logs, available at http://subversion.tigris.org/.
14 # ====================================================================
16 import sys
, os
, string
18 SVNLOOK
='/usr/local/bin/svnlook'
22 We're sorry, but we just couldn't allow you to have the
23 revision {REVISION} commit.
25 -- Love, Your Administrator(s).
30 "Usage: %s REPOS AUTHOR BLOCKED_REV BLOCKED_AUTHOR [...]\n"
32 "Disallow a set BLOCKED_AUTHORS from committing the revision\n"
33 "expected to bring REPOS to a youngest revision of BLOCKED_REV.\n"
34 "Written as a prank for use as a start-commit hook (which provides\n"
35 "REPOS and AUTHOR for you).\n"
37 "NOTE: There is a small chance that while HEAD is BLOCKED_REV - 2,\n"
38 "a commit could slip in between the time we query the youngest\n"
39 "revision and the time this commit-in-progress actually occurs.\n"
46 blocked_rev
= sys
.argv
[3]
47 blocked_authors
= sys
.argv
[4:]
49 if author
in blocked_authors
:
50 youngest_cmd
= '%s youngest %s' % (SVNLOOK
, repos
)
51 youngest
= os
.popen(youngest_cmd
, 'r').readline().rstrip('\n')
53 # See if this is the blocked revision
54 if int(youngest
) == int(blocked_rev
) - 1:
55 MESSAGE
= MESSAGE
.replace('{AUTHOR}', author
)
56 MESSAGE
= MESSAGE
.replace('{REVISION}', blocked_rev
)
57 sys
.stderr
.write(MESSAGE
)