[Yum-devel] [PATCH 2/2] Change "history info" to display the last transaction, even aborted ones.
James Antill
james at and.org
Tue Dec 22 19:37:25 UTC 2009
Let undo/redo refer to the last transaction, without the user having
to look it up manually.
---
docs/yum.8 | 7 +++++--
output.py | 31 ++++++++++++++++++++++++-------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/docs/yum.8 b/docs/yum.8
index ddb44a8..c65fcaa 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -246,10 +246,13 @@ transactions (assuming the history_record config. option is set). You can use
info/list/summary to view what happened, undo/redo to act on that information
and new to start a new history file.
-The info/list/summary commands take either a transactions id or a package (with
+The info/list/summary commands take either a transaction id or a package (with
wildcards, as in \fBSpecifying package names\fP), all three can also be passed
no arguments. list can be passed the keyword "all" to list all the transactions.
-undo/redo just take a transaction id.
+
+The undo/redo commands take either a transaction id or the keyword last and
+an offset from the last transaction (Eg. if you've done 250 transactions,
+"last" refers to transaction 250, and "last-4" refers to transaction 246).
In "history list" output the Altered column also gives some extra information
if there was something not good with the transaction.
diff --git a/output.py b/output.py
index 89c8f91..4102a51 100755
--- a/output.py
+++ b/output.py
@@ -1297,12 +1297,29 @@ to exit.
return None
tids = []
- try:
- int(extcmds[1])
- tids.append(extcmds[1])
- except ValueError:
- self.logger.critical(_('Bad transaction ID given'))
- return None
+ last = None
+ for extcmd in extcmds[1:]:
+ try:
+ if extcmd == 'last' or extcmd.startswith('last-'):
+ if last is None:
+ last = self.history.last(False)
+ if last is None:
+ int("z")
+ tid = last.tid
+ if extcmd.startswith('last-'):
+ off = int(extcmd[len('last-'):])
+ if off <= 0:
+ int("z")
+ tid -= off
+ tids.append(str(tid))
+ continue
+
+ if int(extcmd) <= 0:
+ int("z")
+ tids.append(extcmd)
+ except ValueError:
+ self.logger.critical(_('Bad transaction ID given'))
+ return None
old = self.history.old(tids)
if not old:
@@ -1330,7 +1347,7 @@ to exit.
tids.update(self.history.search(pats))
if not tids and len(extcmds) < 2:
- old = self.history.last()
+ old = self.history.last(False)
if old is not None:
tids.add(old.tid)
--
1.6.5.2
More information about the Yum-devel
mailing list