Skip to content
  • Denis Laxalde's avatar
    revert: use an exact matcher in interactive diff selection (issue5789) · 39b3aab6231e
    Denis Laxalde authored
    When going through _performrevert() in the interactive case, we build a
    matcher with files to revert and pass it patch.diff() for later
    selection of diff hunks to revert. The files set used to build the
    matcher comes from dirstate and accounts for patterns explicitly passed
    to revert ('hg revert -i <file>') and, in case of nonexistent pattern,
    this set is empty (which is expected). Unfortunately, the matcher built
    from scmutil.match(ctx, []) is wrong as it leads patch.diff() to rebuild
    a 'changes' tuple with dirstate information, ignoring user-specified
    pattern. This leads to the situation described in issue5789, where
    one gets prompted about reverting files unrelated to specified patterns
    because they made a typo or so.
    
    We fix this by building an exact matcher with the correct set of file
    paths (built earlier). Thanks to Yuya Nishihara for suggesting the
    correct fix.
    39b3aab6231e