Fix repo prune to work on git 1.6.1-rc3~5 and later

Prior to git 1.6.1-rc3~5 the output of 'git branch -d' matched:

  Deleted branch (.*)\.

where the subgroup grabbed the branch name. In v1.6.1-rc3~5 (aka
a126ed0a01e265d7f3b2972a34e85636e12e6d34) Brandon Casey changed
the output to include the SHA-1 of the branch name, now matching
the pattern:

  Deleted branch (.*) \([0-9a-f]*\)\.

Instead of parsing the output of git branch we now re-obtain the
list of branches after the deletion attempt and perform a set
difference in memory to determine which branches we were able to
successfully delete.

Bug: REPO-9
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/project.py b/project.py
index eebe96d..4056860 100644
--- a/project.py
+++ b/project.py
@@ -770,7 +770,8 @@
     """
     cb = self.CurrentBranch
     kill = []
-    for name in self._allrefs.keys():
+    left = self._allrefs
+    for name in left.keys():
       if name.startswith(R_HEADS):
         name = name[len(R_HEADS):]
         if cb is None or name != cb:
@@ -783,14 +784,12 @@
       self.work_git.DetachHead(HEAD)
       kill.append(cb)
 
-    deleted = set()
     if kill:
       try:
         old = self.bare_git.GetHead()
       except GitError:
         old = 'refs/heads/please_never_use_this_as_a_branch_name'
 
-      rm_re = re.compile(r"^Deleted branch (.*)\.$")
       try:
         self.bare_git.DetachHead(rev)
 
@@ -802,14 +801,12 @@
         b.Wait()
       finally:
         self.bare_git.SetHead(old)
+        left = self._allrefs
 
-      for line in b.stdout.split("\n"):
-        m = rm_re.match(line)
-        if m:
-          deleted.add(m.group(1))
-
-      if deleted:
-        self.CleanPublishedCache()
+      for branch in kill:
+        if (R_HEADS + branch) not in left:
+          self.CleanPublishedCache()
+          break
 
     if cb and cb not in kill:
       kill.append(cb)
@@ -817,7 +814,7 @@
 
     kept = []
     for branch in kill:
-      if branch not in deleted:
+      if (R_HEADS + branch) in left:
         branch = self.GetBranch(branch)
         base = branch.LocalMerge
         if not base: