Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: man/include/, man/, /
Date: Sat, 30 Jan 2021 10:38:00
Message-Id: 1612002955.3ef45fa46d5a45a3f19806cf62aba8532b4e401f.grobian@gentoo
1 commit: 3ef45fa46d5a45a3f19806cf62aba8532b4e401f
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 30 10:35:55 2021 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 30 10:35:55 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3ef45fa4
7
8 qlop: support -d 0 (or @0)
9
10 Allow setting the zero date, to basically have a quick way to list
11 everything, useful with -E, e.g. -Evd 0 to show the entire emerge
12 history.
13
14 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
15
16 man/include/qlop.desc | 2 +-
17 man/include/qlop.optdesc.yaml | 2 +-
18 man/qlop.1 | 6 +++---
19 qlop.c | 25 +++++++++++++++++--------
20 4 files changed, 22 insertions(+), 13 deletions(-)
21
22 diff --git a/man/include/qlop.desc b/man/include/qlop.desc
23 index e39f689..0f7fa7c 100644
24 --- a/man/include/qlop.desc
25 +++ b/man/include/qlop.desc
26 @@ -19,7 +19,7 @@ in further on specific packages.
27 .P
28 After version \fB0.74\fR of portage-utils, \fIqlop\fR was changed
29 considerably to be more consistent and more advanced. Most notably,
30 -this has changed default date output and commmand line flags. Instead
31 +this has changed default date output and command line flags. Instead
32 of reporting the time the operation finished, \fIqlop\fR now reports the
33 time the operation started. The behaviour of the old \fB-g\fR flag is
34 best matched by the new \fB-t\fR flag. Similar, the old \fB-t\fR flag
35
36 diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml
37 index c6e0833..fc268d6 100644
38 --- a/man/include/qlop.optdesc.yaml
39 +++ b/man/include/qlop.optdesc.yaml
40 @@ -16,7 +16,7 @@ date: |
41 .IP YYYY-MM-DDThh:mm:ss
42 As before, but hours, minutes and seconds added. This is the same
43 format qlop prints for timestamps.
44 - .IP SSSSSSSSS
45 + .IP "SSSSSSSSS or @SSSSSSSSS"
46 Seconds since 1970-01-01 00:00:00 +0000 (UTC), the UNIX epoch.
47 .IP FORMAT|DATE
48 Use \fIFORMAT\fR as input for \fBstrptime\fR(3) to parse \fIDATE\fR.
49
50 diff --git a/man/qlop.1 b/man/qlop.1
51 index 5aafa82..a175332 100644
52 --- a/man/qlop.1
53 +++ b/man/qlop.1
54 @@ -1,5 +1,5 @@
55 .\" generated by mkman.py, please do NOT edit!
56 -.TH qlop "1" "Nov 2020" "Gentoo Foundation" "qlop"
57 +.TH qlop "1" "Jan 2021" "Gentoo Foundation" "qlop"
58 .SH NAME
59 qlop \- emerge log analyzer
60 .SH SYNOPSIS
61 @@ -27,7 +27,7 @@ in further on specific packages.
62 .P
63 After version \fB0.74\fR of portage-utils, \fIqlop\fR was changed
64 considerably to be more consistent and more advanced. Most notably,
65 -this has changed default date output and commmand line flags. Instead
66 +this has changed default date output and command line flags. Instead
67 of reporting the time the operation finished, \fIqlop\fR now reports the
68 time the operation started. The behaviour of the old \fB-g\fR flag is
69 best matched by the new \fB-t\fR flag. Similar, the old \fB-t\fR flag
70 @@ -110,7 +110,7 @@ year, followed by month and day of month.
71 .IP YYYY-MM-DDThh:mm:ss
72 As before, but hours, minutes and seconds added. This is the same
73 format qlop prints for timestamps.
74 -.IP SSSSSSSSS
75 +.IP "SSSSSSSSS or @SSSSSSSSS"
76 Seconds since 1970-01-01 00:00:00 +0000 (UTC), the UNIX epoch.
77 .IP FORMAT|DATE
78 Use \fIFORMAT\fR as input for \fBstrptime\fR(3) to parse \fIDATE\fR.
79
80 diff --git a/qlop.c b/qlop.c
81 index 5045d17..2d01689 100644
82 --- a/qlop.c
83 +++ b/qlop.c
84 @@ -1,5 +1,5 @@
85 /*
86 - * Copyright 2005-2020 Gentoo Foundation
87 + * Copyright 2005-2021 Gentoo Foundation
88 * Distributed under the terms of the GNU General Public License v2
89 *
90 * Copyright 2005-2010 Ned Ludd - <solar@g.o>
91 @@ -116,14 +116,17 @@ parse_date(const char *sdate, time_t *t)
92 } else {
93 /* Handle automatic formats:
94 * - "12315128" -> %s
95 + * - "@12315128" -> %s
96 * - "2015-12-24" -> %Y-%m-%d
97 * - "2019-03-28T13:52:31" -> %Y-%m-%dT%H:%M:%s"
98 * - human readable format (see below)
99 */
100 - size_t len = strspn(sdate, "0123456789-:T");
101 + size_t len = strspn(sdate, "0123456789-:T@");
102 if (sdate[len] == '\0') {
103 const char *fmt;
104 - if (strchr(sdate, '-') == NULL) {
105 + if (sdate[0] == '@') {
106 + fmt = "@%s";
107 + } else if (strchr(sdate, '-') == NULL) {
108 fmt = "%s";
109 } else if ((s = strchr(sdate, 'T')) == NULL) {
110 fmt = "%Y-%m-%d";
111 @@ -1394,8 +1397,8 @@ int qlop_main(int argc, char **argv)
112 DECLARE_ARRAY(atoms);
113 int runningmode = 0;
114
115 - start_time = 0;
116 - end_time = LONG_MAX;
117 + start_time = -1;
118 + end_time = -1;
119 m.do_time = 0;
120 m.do_merge = 0;
121 m.do_unmerge = 0;
122 @@ -1435,10 +1438,10 @@ int qlop_main(int argc, char **argv)
123 case 'l': m.show_lastmerge = 1; break;
124 case 'F': m.fmt = optarg; break;
125 case 'd':
126 - if (start_time == 0) {
127 + if (start_time == -1) {
128 if (!parse_date(optarg, &start_time))
129 err("invalid date: %s", optarg);
130 - } else if (end_time == LONG_MAX) {
131 + } else if (end_time == -1) {
132 if (!parse_date(optarg, &end_time))
133 err("invalid date: %s", optarg);
134 } else
135 @@ -1539,7 +1542,7 @@ int qlop_main(int argc, char **argv)
136 }
137
138 /* handle -l / -d conflict */
139 - if (start_time != 0 && m.show_lastmerge) {
140 + if (start_time != -1 && m.show_lastmerge) {
141 if (!m.show_emerge)
142 warn("-l and -d cannot be used together, dropping -l");
143 m.show_lastmerge = 0;
144 @@ -1563,6 +1566,12 @@ int qlop_main(int argc, char **argv)
145 m.fmt = "%[CATEGORY]%[PN]";
146 }
147
148 + /* adjust time ranges when unset */
149 + if (start_time == -1)
150 + start_time = 0;
151 + if (end_time == -1)
152 + end_time = LONG_MAX;
153 +
154 if (m.do_running) {
155 array_t *new_atoms = NULL;