findmissing: Improve SHA handling

Experience shows that in almost all cases, we want to abandon all
patches associated with a given upstream patch (fix) or with a given
stable release or Chrome OS patch.

At the same time, we need to be careful to not make too many uncontrolled
database changes.

To simplify the abandon/restore command line interface, only require
a single SHA. It does not matter which SHA is provided; it can be the
upstream SHA (the fix) or the stable release/ChromeOS SHA.
If that SHA reflects exactly one entry in the database, go ahead and
make the requested change. If there is more than one entry in the database,
only make the change if the '-f' or '--force' flag is provided. If the flag
is not provided, list the database entries which would be associated with
the change and exit.

Other changes:
- Convert "reason" argument into mandatory optional argument. This was
  necessary since the list of SHAs has to come last (as positional
- Do not require specific SHA order if two SHAs are specified.
- Ignore pointless pylint error when importing MySQLdb to make 'repo
  upload' happy.
- When abandoning patches, skip already abandoned patches.
  Also, do not let the user mark merged patches as "ABANDONED".

TEST=Run findmissing command and abandon/restore various patches

Change-Id: I8ad1a606508e6715c4e3e6fbb276493d0f5aa620
Commit-Queue: Guenter Roeck <>
Tested-by: Guenter Roeck <>
Reviewed-by: Curtis Malainey <>
3 files changed