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
  arguments)
- 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".

BUG=None
TEST=Run findmissing command and abandon/restore various patches

Change-Id: I8ad1a606508e6715c4e3e6fbb276493d0f5aa620
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2252420
Commit-Queue: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
3 files changed