fromupstream: Support --replace for gitfetch commands

If the user wants to replace a CL with something from upstream while
using the git://url#branch/hash or https://url#branch/hash syntax it
will fail because we don't rewind HEAD to HEAD~. Add the replace code
that we use everywhere else.

BUG=None
TEST=fromupstream.py --replace git://git.kernel.org/torvalds#master/hash

Change-Id: I1c7bde18b636b07900e43576bebda5b4079e6d18
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2020909
Commit-Queue: Stephen Boyd <swboyd@chromium.org>
Commit-Queue: Douglas Anderson <dianders@chromium.org>
Tested-by: Stephen Boyd <swboyd@chromium.org>
Auto-Submit: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
diff --git a/contrib/fromupstream.py b/contrib/fromupstream.py
index 433ee85..62d9771 100755
--- a/contrib/fromupstream.py
+++ b/contrib/fromupstream.py
@@ -311,6 +311,9 @@
     if args['tag'] is None:
         args['tag'] = 'FROMGIT: '
 
+    if args['replace']:
+        _git(['reset', '--hard', 'HEAD~1'])
+
     return _git_returncode(['cherry-pick', commit])
 
 def main(args):