Bug 1393594 - "dnf history (undo|redo|info) last" does not work in DNF 2.0rc1
Summary: "dnf history (undo|redo|info) last" does not work in DNF 2.0rc1
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: rawhide
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
Assignee: Štěpán Smetana
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-09 22:56 UTC by Neal Gompa
Modified: 2016-12-07 03:18 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-07 03:18:47 UTC
Type: Bug


Attachments (Terms of Use)

Description Neal Gompa 2016-11-09 22:56:21 UTC
Description of problem:
When running DNF 2.0rc1, the history subcommand does not understand "last" to identify the latest transaction recorded to act on.

Version-Release number of selected component (if applicable):
2.0.0-0.0.1.rc1.mga6 (= 2.0.0-0.rc1.3.fc26)


How reproducible:
Always

Steps to Reproduce:
1. Install something with dnf
2. Run "dnf history (undo|redo|info) last"

Actual results:
Returns error: "Bad transaction ID given"

Expected results:
Does appropriate action with last transaction recorded

Additional info:
This issue was discovered on Mageia Cauldron using the DNF 2.0 Copr for Cauldron[1]. 

[1]: https://copr.fedorainfracloud.org/coprs/ngompa/dnf2-mga/

Comment 1 Neal Gompa 2016-11-09 22:59:14 UTC
Err, the DNF 2.0rc1 package in the COPR repo is actually equivalent to dnf-2.0.0-0.rc1.4.fc26 in Rawhide.

Comment 2 Igor Gnatenko 2016-11-10 05:41:40 UTC
Please provide backtrace.

Comment 3 Igor Gnatenko 2016-11-10 05:41:58 UTC
oops, wrong bug.

Comment 4 Honza Silhan 2016-11-14 12:14:29 UTC
we'll fix this.

Comment 5 Michal Luscon 2016-11-18 09:18:24 UTC

*** This bug has been marked as a duplicate of bug 1393595 ***

Comment 6 Neal Gompa 2016-11-21 11:27:43 UTC
Any progress on this? I've not seen any pull requests related to this issue show up in DNF...

Comment 7 Vít Ondruch 2016-11-22 14:02:41 UTC
Just FTR, man pages say:

```
SPECIFYING TRANSACTIONS
       <transaction-spec>  can  be  in  one of several forms. If it is an integer, it specifies a transaction ID. Specifying --last is the same as specifying the ID of the most recent transaction. The last form is --last-<offset>, where <offset> is a positive integer. It specifies offset-th transaction preceding the most recent transaction.
```

So trying last:

```
$ sudo dnf history undo --last
usage: dnf history [-c [config file]] [-q] [-v] [--version]
                   [--installroot [path]] [--noplugins]
                   [--disableplugins [plugin]] [--releasever RELEASEVER]
                   [--setopt SETOPTS] [-h] [--allowerasing] [-b] [-C]
                   [-d [debug level]] [--debugsolver] [--showduplicates]
                   [-e ERRORLEVEL] [--rpmverbosity [debug level name]] [-y]
                   [--assumeno] [--enablerepo [repo]] [--disablerepo [repo] |
                   --repo [repo]] [-x [package]] [--disableexcludes [repo]]
                   [--repofrompath [repo,path]] [--nogpgcheck] [--color COLOR]
                   [--refresh] [-4] [-6] [--downloadonly]
                   [[list|info|redo|undo|rollback|userinstalled]
                   [[list|info|redo|undo|rollback|userinstalled] ...]]
dnf history: error: unrecognized arguments: --last
```

But I used to be to use just "last" without dashes when using YUM, but it fails with different error:

```
$ sudo dnf history undo last
Repository 'tiliado-nuvolaplayer' is missing name in configuration, using id.
Last metadata expiration check: 4:24:15 ago on Tue Nov 22 10:37:33 2016 CET.
Failed to synchronize cache for repo 'rcm-tools-fedora-rpms', disabling.
Failed to synchronize cache for repo 'tiliado-nuvolaplayer', disabling.
Bad transaction ID given
Error: Failed history undo
```

So you probably want to clarify the behavior/documentation ...

Comment 8 Štěpán Smetana 2016-11-22 15:11:30 UTC
In document "doc/cli_vs_yum.rst" was documented that dnf considers last option as <package-ID>, but yum considered it as package name. So because of back compatibility it was renamed to "--last" option (Commit https://github.com/rpm-software-management/dnf/commit/1681a5fafbb66e115b8ab71ae9b374227aeb7c6c)

Few weeks later was changed handling or arguments and I found that "--last" option did not work. So I created PR (https://github.com/rpm-software-management/dnf/pull/584) that fixed that but after some discussion about doing this the right way we found out that there was mistake in "doc/cli_vs_yum.rst" and dnf worked as yum.

Unfortunately argparser is not able to handle this option in some new pretty way so we need to apply old parsing of "last" option to new argparser.

Comment 9 Vít Ondruch 2016-11-23 10:55:35 UTC
(In reply to Štěpán Smetana from comment #8)
> Unfortunately argparser is not able to handle this option in some new pretty
> way so we need to apply old parsing of "last" option to new argparser.

Yep, YUM always accepted just plain "last" as far as I remember, so this plan works for me.

Comment 10 Michael Mráka 2016-11-24 09:08:25 UTC
Fixed in
https://github.com/rpm-software-management/dnf/pull/659

Comment 11 Neal Gompa 2016-11-24 15:44:52 UTC
Verified that it's fixed:

```
[ngompa@mgacauldron-dnftst Music]$ sudo dnf history info last
Last metadata expiration check: 0:01:58 ago on Thu Nov 24 10:40:27 2016 EST.
Transaction ID : 90
Begin time     : Thu Nov 24 10:42:01 2016
Begin rpmdb    : 2623:fef133c1f4cd41f0af864d6b9d9dffde4e203958
End time       :            10:42:09 2016 (8 seconds)
End rpmdb      : 2623:633bc9ecb97873fcf3dd271784b2fe599cff3b6f
User           : System <unset>
Return-Code    : Success
Command Line   : --best --allowerasing install dnf
Transaction performed with:
    Upgraded      dnf-2.0.0-0.0.1.rc1.mga6.noarch @ngompa-dnf2-mga
    Installed     1:rpm-4.13.0-2.mga6.x86_64      @cauldron-x86_64
Packages Altered:
    Upgraded dnf-2.0.0-0.0.1.rc1.mga6.noarch         @ngompa-dnf2-mga
    Upgrade      2.0.0-0.0.3.rc1.mga6.noarch         @ngompa-dnf2-mga
    Upgraded dnf-conf-2.0.0-0.0.1.rc1.mga6.noarch    @ngompa-dnf2-mga
    Upgrade           2.0.0-0.0.3.rc1.mga6.noarch    @ngompa-dnf2-mga
    Upgraded dnf-yum-2.0.0-0.0.1.rc1.mga6.noarch     @ngompa-dnf2-mga
    Upgrade          2.0.0-0.0.3.rc1.mga6.noarch     @ngompa-dnf2-mga
    Upgraded python3-dnf-2.0.0-0.0.1.rc1.mga6.noarch @ngompa-dnf2-mga
    Upgrade              2.0.0-0.0.3.rc1.mga6.noarch @ngompa-dnf2-mga

```

Comment 12 Neal Gompa 2016-12-07 03:18:47 UTC
Fixed with the dnf 2.0rc2 builds in rawhide.


Note You need to log in before you can comment on or make changes to this bug.