pq: Try harder to cleanup after a failed patch
authorGuido Günther <agx@sigxcpu.org>
Mon, 19 May 2014 10:06:39 +0000 (12:06 +0200)
committerGuido Günther <agx@sigxcpu.org>
Mon, 19 May 2014 10:13:50 +0000 (12:13 +0200)
If we fail to apply the patch the tree is left in a dirty state
so reset to the last head. This avoids irritating errors like:

gbp:error: Failed to apply 'debian/patches/poison+remember_trash': Failed to commit tree: fatal: invalid date format: 1998/03/21

following files would be overwritten by checkout:
doc/hosts.nntp.5
innd/art.c
innd/innd.h
innd/rc.c
Please, commit your changes or stash them before you can switch branches.
Aborting

Thanks: Marco d'Itri for the repo to debug this

gbp/scripts/pq.py

index 05e5660c7f0b9d174916f4c3077cd59e1f2cfe89..ea33c26cdd652edeb6ccb2dee1957cda1770d9f3 100755 (executable)
@@ -176,6 +176,7 @@ def import_quilt_patches(repo, branch, series, tries, force):
                 apply_and_commit_patch(repo, patch, maintainer, patch.topic)
             except (GbpError, GitRepositoryError) as e:
                 gbp.log.err("Failed to apply '%s': %s" % (patch.path, e))
+                repo.force_head('HEAD', hard=True)
                 repo.set_branch(branch)
                 repo.delete_branch(pq_branch)
                 break