3 ### This is a debugging script to test date-ordering in an SVN repository.
5 '''Tell which revisions are out of order w.r.t. date in a repository.
6 Takes "svn log -q -r1:HEAD" output, prints results like this:
8 $ svn log -q -r1:HEAD | ./datecheck.py
10 r42 OK 2003-06-02 22:20:31 -0500
11 r43 OK 2003-06-02 22:20:31 -0500
12 r44 OK 2003-06-02 23:29:14 -0500
13 r45 OK 2003-06-02 23:29:14 -0500
14 r46 OK 2003-06-02 23:33:13 -0500
15 r47 OK 2003-06-10 15:19:47 -0500
16 r48 NOT OK 2003-06-02 23:33:13 -0500
17 r49 OK 2003-06-10 15:19:48 -0500
18 r50 NOT OK 2003-06-02 23:33:13 -0500
25 log_msg_separator
= "-" * 72 + "\n"
27 line
= sys
.stdin
.readline()
34 if line
== log_msg_separator
:
35 line
= sys
.stdin
.readline()
38 # We're looking at a revision line like this:
40 # "r1 | svn | 2001-08-30 23:24:14 -0500 (Thu, 30 Aug 2001)"
44 rev
, ignored
, date_full
= line
.split("|")
46 date_full
= date_full
.strip()
48 # We only need the machine-readable portion of the date, so ignore
49 # the parenthesized part on the end, which is meant for humans.
51 # Get the "2004-06-02 00:15:08" part of "2004-06-02 00:15:08 -0500".
52 date
= date_full
[0:19]
53 # Get the "-0500" part of "2004-06-02 00:15:08 -0500".
54 offset
= date_full
[20:25]
56 # Parse the offset by hand and adjust the date accordingly, because
57 # http://docs.python.org/lib/module-time.html doesn't seem to offer
58 # a standard way to parse "-0500", "-0600", etc, suffixes. Arggh.
59 offset_sign
= offset
[0:1]
60 offset_hours
= int(offset
[1:3])
61 offset_minutes
= int(offset
[3:5])
63 # Get a first draft of the date...
64 date_as_int
= time
.mktime(time
.strptime(date
, "%Y-%m-%d %H:%M:%S"))
65 # ... but it's still not correct, we must adjust for the offset.
66 if offset_sign
== "-":
67 date_as_int
-= (offset_hours
* 3600)
68 date_as_int
-= (offset_minutes
* 60)
69 elif offset_sign
== "+":
70 date_as_int
+= (offset_hours
* 3600)
71 date_as_int
+= (offset_minutes
* 60)
73 sys
.stderr
.write("Error: unknown offset sign '%s'.\n" % offset_sign
)
77 if last_date
> date_as_int
:
80 print "%-8s %s %s %s" % (rev
, ok_not_ok
, date
, offset
)
81 last_date
= date_as_int
82 line
= sys
.stdin
.readline()