|
1 #!/bin/bash |
|
2 |
|
3 relpipe-in-hglog() { |
|
4 # on repositories with long history |
|
5 # it is good to process just a subset of the log using hg log parameters |
|
6 hg log --template xml \ |
|
7 | relpipe-in-xmltable \ |
|
8 --relation hg_log \ |
|
9 --records "/log/logentry" \ |
|
10 --attribute "revision" integer "@revision" \ |
|
11 --attribute "date" string "date" \ |
|
12 --attribute "hash" string "@node" \ |
|
13 --attribute "hash_short" string "substring(@node,1,12)" \ |
|
14 --attribute "branch" string "branch" \ |
|
15 --attribute "author_name" string "author" \ |
|
16 --attribute "message" string "msg" |
|
17 # --attribute "author_email" string "author/@email" \ |
|
18 } |
|
19 |
|
20 relpipe-in-hgtags() { |
|
21 hg tags \ |
|
22 | sed -E 's/([^ \s]+)\s+([0-9]+):(.*)/\1\n\2\n\3/g' \ |
|
23 | tr \\n \\0 \ |
|
24 | relpipe-in-cli \ |
|
25 generate-from-stdin hg_tags 3 \ |
|
26 tag string \ |
|
27 revision integer \ |
|
28 hash_short string |
|
29 } |
|
30 |
|
31 |
|
32 # just view everything: |
|
33 # (relpipe-in-hglog; relpipe-in-hgtags) | relpipe-out-tabular | less -RSi |
|
34 |
|
35 |
|
36 # filter and JOIN data, do some statistics: |
|
37 (relpipe-in-hglog; relpipe-in-hgtags) \ |
|
38 | relpipe-tr-sql \ |
|
39 --relation "tags" \ |
|
40 "SELECT |
|
41 t.*, |
|
42 l.date |
|
43 FROM hg_tags AS t |
|
44 JOIN hg_log AS l USING (hash_short)" \ |
|
45 --relation "filtered_log" \ |
|
46 "SELECT |
|
47 revision, |
|
48 date, |
|
49 hash_short, |
|
50 branch, |
|
51 author_name |
|
52 FROM hg_log |
|
53 ORDER BY revision DESC |
|
54 LIMIT ?" \ |
|
55 --parameter 10 \ |
|
56 --relation "author_statistics" \ |
|
57 "SELECT |
|
58 author_name, |
|
59 branch, |
|
60 count(*) AS count, |
|
61 min(date) AS first_commit, |
|
62 max(date) AS last_commit |
|
63 -- TODO: user proper data type for date |
|
64 FROM hg_log |
|
65 GROUP BY author_name, branch |
|
66 ORDER BY count" \ |
|
67 | relpipe-out-tabular |
|
68 |