add sss into readme
[freebsd-maintainer-scripts/.git] / sss
CommitLineData
6b8001db
SB
1#!/usr/bin/env python
2
3"""
4sss - sbz svn status verbose on one line
5"""
6
7import os
8import shlex
9import subprocess
10import sys
11import xml.etree.ElementTree as ET
12
13"""
14line = Parse output of svn up
15foreach path in lines
16 xml data = svn log -rHEAD path --xml
17 author, shortmsg, status, path = parse xml data
18 print status, path, shortmsg, status, author
19"""
20
21x_data = """U src/bin/dd/args.c
22U src/bin/dd/conv.c
23U src/bin/dd/dd.c
24U src/bin/dd/dd.h
25U src/bin/dd/position.c
26U src/bin/pkill/pkill.c
27U src/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
28U src/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
29U src/cddl/usr.sbin/zfsd/zfsd_event.cc
30U src/contrib/compiler-rt/lib/builtins/arm/aeabi_dcmp.S
31U src/contrib/compiler-rt/lib/builtins/arm/aeabi_fcmp.S
32U src/contrib/compiler-rt/lib/esan/esan_sideline_linux.cpp
33U src/contrib/compiler-rt/lib/profile/InstrProfilingNameVar.c
34U src/contrib/compiler-rt
35U src/contrib/libc++
36"""
37
38x_xml_data = """<?xml version="1.0" encoding="UTF-8"?>
39<log>
40<logentry
41 revision="322826">
42<author>kevans</author>
43<date>2017-08-24T01:23:33.506520Z</date>
44<msg>bsdgrep: add a primitive literal matcher
45</msg>
46</logentry>
47</log>"""
48
49
50def valid_line(line):
51 if line.startswith('U ') or \
52 line.startswith('A ') or \
53 line.startswith('D '):
54 return True
55 else:
56 return False
57
58
59def main():
60 src_path = os.path.expanduser('~/svn/src/')
61 ports_path = os.path.expanduser('~/svn/ports/')
62 svn_path = sys.argv[1] if len(sys.argv) == 2 else src_path
63 out = {}
64 data = subprocess.run(shlex.split('svn up {0}'.format(svn_path)),
65 stdout=subprocess.PIPE).stdout
66 data = data.decode("utf-8")
67 for line in data.split('\n'):
68 if not valid_line(line):
69 continue
70 status, path = line.split()
71 out['status'] = status
72 out['path'] = path
73 xml = subprocess.run(
74 shlex.split('svn log -l 1 {path} --xml'.format(path=path)),
75 stdout=subprocess.PIPE
76 )
77 xml_data = xml.stdout
78 xml_data = xml_data.decode("utf-8")
79 try:
80 root = ET.fromstring(xml_data)
81 for commit in root.findall('logentry'):
82 author = commit.find('author').text
83 shortmsg = commit.find('msg').text.split('\n')[0]
84 out['author'] = author
85 out['shortmsg'] = shortmsg
86 print("{status} {path}\t {shortmsg} | {author}".format(**out))
87 except:
88 pass
89
90
91if __name__ == '__main__':
92 sys.exit(main())