[Yum-devel] [PATCH] Add history_list_view, und change default to 1user-cmds. BZ 692780. options:
James Antill
james at and.org
Thu Apr 14 18:22:31 UTC 2011
users = display users (old behaviour).
cmds = display cmdline.
1user-cmds = display cmdline if only a single user, and >= 50% of entries
have a cmd line
...also adds documentation to yum.conf and yum.
---
docs/yum.8 | 3 +++
docs/yum.conf.5 | 13 +++++++++++++
output.py | 41 +++++++++++++++++++++++++++++++++++------
yum/config.py | 10 ++++++++++
4 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/docs/yum.8 b/docs/yum.8
index 39c7253..522f15f 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -345,6 +345,9 @@ an offset from the last transaction (Eg. if you've done 250 transactions,
The addon-info command takes a transaction ID, and the packages-list command
takes a package (with wildcards).
+In "history list" you can change the behaviour of the 2nd column via. the
+configuration option history_list_view.
+
In "history list" output the Altered column also gives some extra information
if there was something not good with the transaction (this is also shown at the
end of the package column in the packages-list command).
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 2e0d6ea..60e9f27 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -357,6 +357,19 @@ normally be necessary to add packages here. Not that this is also used for the
packages to look for in \-\-version. Defaults to rpm, yum, yum-metadata-parser.
.IP
+\fBhistory_list_view \fR
+Which column of information to display in the "yum history list" command. There
+are currently three options: users, cmds (or commands), auto.
+
+Older versions of yum acted like "users", which always outputs the user who
+initiated the yum transaction. You can now specify "cmds" which will instead
+always output the command line of the transaction. You can also specify
+"1user-cmds" which will display the users if there are more than one,
+otherwise it will display the command line.
+
+You can also specify "default" which currently selects "1user-cmds".
+
+.IP
\fBcommands\fR
List of functional commands to run if no functional commands are specified
on the command line (eg. "update foo bar baz quux"). None of the short options
diff --git a/output.py b/output.py
index 85b21f8..e9402d5 100755
--- a/output.py
+++ b/output.py
@@ -1441,24 +1441,53 @@ to exit.
if tids is None:
return 1, ['Failed history list']
+ limit = 20
+ if printall:
+ limit = None
+
+ old_tids = self.history.old(tids, limit=limit)
+ done = 0
+ if self.conf.history_list_view == 'users':
+ uids = [1,2]
+ elif self.conf.history_list_view == 'cmds':
+ uids = [1]
+ else:
+ assert self.conf.history_list_view == '1user-cmds'
+ uids = set()
+ blanks = 0
+ for old in old_tids:
+ if not printall and done >= limit:
+ break
+
+ done += 1
+ if old.cmdline is None:
+ blanks += 1
+ uids.add(old.loginuid)
+ if len(uids) == 1 and blanks > (done / 2):
+ uids.add('blah')
+
fmt = "%s | %s | %s | %s | %s"
+ if len(uids) == 1:
+ name = _("Command line")
+ else:
+ name = _("Login user")
print fmt % (utf8_width_fill(_("ID"), 6, 6),
- utf8_width_fill(_("Login user"), 24, 24),
+ utf8_width_fill(name, 24, 24),
utf8_width_fill(_("Date and time"), 16, 16),
utf8_width_fill(_("Action(s)"), 14, 14),
utf8_width_fill(_("Altered"), 7, 7))
print "-" * 79
fmt = "%6u | %s | %-16.16s | %s | %4u"
done = 0
- limit = 20
- if printall:
- limit = None
- for old in self.history.old(tids, limit=limit):
+ for old in old_tids:
if not printall and done >= limit:
break
done += 1
- name = self._pwd_ui_username(old.loginuid, 24)
+ if len(uids) == 1:
+ name = old.cmdline or ''
+ else:
+ name = self._pwd_ui_username(old.loginuid, 24)
tm = time.strftime("%Y-%m-%d %H:%M",
time.localtime(old.beg_timestamp))
num, uiacts = self._history_uiactions(old.trans_data)
diff --git a/yum/config.py b/yum/config.py
index 8c966f8..3407428 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -746,6 +746,16 @@ class YumConf(StartupConf):
loadts_ignorerpm = BoolOption(False)
clean_requirements_on_remove = BoolOption(False)
+
+
+ history_list_view = SelectionOption('1user-cmds',
+ ('1user-cmds', 'users', 'cmds'),
+ mapper={'commands' : 'cmds',
+ '1-user-cmds' : '1user-cmds',
+ 'one-user-cmds' : '1user-cmds',
+ '1-user-commands' : '1user-cmds',
+ 'one-user-commands' : '1user-cmds',
+ 'default' : '1user-cmds'})
_reposlist = []
def dump(self):
--
1.7.3.4
More information about the Yum-devel
mailing list