Prune stale branches from mergers

Ensure that when a remote branch disappears, mergers prune that
branch from their local copy.  Otherwise, they will continue
to instruct executors to create that branch for jobs.  This is
not only incorrect, but it could lead to errors if the executors
don't have those objects locally.

The zuul-cloner used to use the merger.prune method to avoid this
issue, however, a straightforward application of that on the mergers
could be problematic.  If the merger's git repo is not in a coherent
state, the prune method will raise an error.  Further, at the end
of the reset() method, the merger actually leaves the repos in a
state where 'git prune' can not operate -- it leaves HEAD pointing
to a symbolic reference which may not exist as a head ref.  This
generally isn't an issue as the next thing that happens after reset()
is usually checkout.  But it does prevent us from running prune() at
the end of reset().

To address both of these issues, incorporate pruning into the reset
method in a safe manner.  First, create or update any non-stale
branches.  Pick the first of those to be the new local HEAD.  Reset
the repository to that.  Finally, delete any stale branches.

This change also updates all of the tests so that git clones of the
"upstream" repos use file:// urls, so that they do not rely on
hard links and more closely mimic actual behavior.  That was necessary
in this test in order to reproduce the situation where a merger
whch clones from upstream after a branch deletion would not have
objects that another merger which had cloned before deletion did have.

It also removes some test-specific debugging around git repo creation
which is no longer needed.

Change-Id: Ic34453ddb0205ad31708d154d53915d66d26b548
diff --git a/tests/fixtures/layouts/branch-deletion.yaml b/tests/fixtures/layouts/branch-deletion.yaml
new file mode 100644
index 0000000..f72902a
--- /dev/null
+++ b/tests/fixtures/layouts/branch-deletion.yaml
@@ -0,0 +1,34 @@
+- pipeline:
+    name: check
+    manager: independent
+    trigger:
+      gerrit:
+        - event: patchset-created
+    success:
+      gerrit:
+        Verified: 1
+    failure:
+      gerrit:
+        Verified: -1
+
+- job:
+    name: base
+    parent: null
+    run: playbooks/base.yaml
+
+- job:
+    name: project-test1
+    parent: base
+    branches: master
+
+- job:
+    name: project-test2
+    parent: base
+    branches: stable
+
+- project:
+    name: org/project
+    check:
+      jobs:
+        - project-test1
+        - project-test2