source: LMDZ5/trunk/tools/fcm/templates/hook/post-revprop-change.py @ 5371

Last change on this file since 5371 was 1578, checked in by jghattas, 13 years ago
  • Add fcm in LMDZ5/tools directory

It is no longer needed to have fcm in your environement PATH variable.
Now makelmdz_fcm takes by default this fcm. It is still possible to use
another fcm, using -fcm_path argument in makelmdz_fcm.

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/usr/bin/python
2# ------------------------------------------------------------------------------
3# NAME
4#   post-revprop-change.py
5#
6# SYNOPSIS
7#   post-revprop-change.py REPOS REV USER PROPNAME ACTION <&0
8#
9# DESCRIPTION
10#   This script updates the Trac SQLite database with the new revision log
11#   following a change in svn:log. The old property value is passed via STDIN.
12#
13# COPYRIGHT
14#   (C) Crown copyright Met Office. All rights reserved.
15#   For further details please refer to the file COPYRIGHT.txt
16#   which you should have received as part of this distribution.
17# ------------------------------------------------------------------------------
18
19# Standard modules
20import commands
21import os.path
22import sqlite
23import sys
24
25def main ():
26  '''Main program'''
27
28  # Get command line arguments
29  (repos, rev, user, propname, action) = sys.argv [1:6]
30
31  # Handle only log message change
32  if not (propname == 'svn:log' and action == 'M'):
33    return
34
35  # Get new message with "svnlook"
36  message = commands.getoutput ('svnlook log -r ' + rev + ' ' + repos)
37  if not message:
38    return
39
40  # Name of the project
41  project = os.path.basename (repos)
42  project = project.replace ('_svn', '')
43
44  # Path to project Trac system
45  trac    = os.path.join (os.path.expanduser ('~fcm'), 'trac', 'live', project)
46  trac_db = os.path.join (trac, 'db', 'trac.db')
47
48  # Update Trac database
49  db      = sqlite.connect (trac_db)
50  cursor  = db.cursor ()
51  cursor.execute (
52    "UPDATE revision SET message = %s WHERE rev == %s", message, rev
53  )
54
55  try:
56    db.commit ()
57
58  except:
59    raise 'Failed to update log of revision ' + rev + ' in ' + trac_db + '.'
60
61  else:
62    print 'Updated log of revision ' + rev + ' in ' + trac_db + '.'
63
64  return
65
66# ------------------------------------------------------------------------------
67
68if __name__ == '__main__' :
69  main ()
Note: See TracBrowser for help on using the repository browser.