File: mailer-tweak.py

package info (click to toggle)
subversion 1.4.2dfsg1-3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,284 kB
  • ctags: 32,888
  • sloc: ansic: 406,472; python: 38,378; sh: 15,438; cpp: 9,604; ruby: 8,313; perl: 5,308; java: 4,576; lisp: 3,860; xml: 3,298; makefile: 856
file content (44 lines) | stat: -rwxr-xr-x 983 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
#
# mailer-tweak.py: tweak the svn:date properties on all revisions
#
# We need constant dates for the revisions so that we can consistently
# compare an output against a known quantity.
#
# USAGE: ./mailer-tweak.py REPOS
#


import sys
import os
import getopt

from svn import fs, core

DATE_BASE = 1000000000
DATE_INCR = 10000


def tweak_dates(pool, home='.'):
  db_path = os.path.join(home, 'db')
  if not os.path.exists(db_path):
    db_path = home

  fsob = fs.new(None, pool)
  fs.open_berkeley(fsob, db_path)

  for i in range(fs.youngest_rev(fsob, pool)):
    # convert secs into microseconds, then a string
    date = core.svn_time_to_cstring((DATE_BASE+i*DATE_INCR) * 1000000L, pool)
    #print date
    fs.change_rev_prop(fsob, i+1, core.SVN_PROP_REVISION_DATE, date, pool)

def main():
  if len(sys.argv) != 2:
    print 'USAGE: %s REPOS' % sys.argv[0]
    sys.exit(1)

  core.run_app(tweak_dates, sys.argv[1])

if __name__ == '__main__':
  main()