Commits

David Carr committed ebf4ea2

outgoing: don't delete remote refs

There was a bug introduced in 8c1f2b07c04b such that calling hg outgoing on
a Git repository would result in all refs being deleted from the remote
repository (with the possible exception of the currently checked out branch).
It wasn't noticed before because the existing test for outgoing didn't actually
verify the refs on the remote. This changeset fixes the bug, as well as adding
test coverage to allow verifying that the fix works.

  • Participants
  • Parent commits 5a688ad

Comments (0)

Files changed (2)

File hggit/git_handler.py

             old_refs.update(refs)
             to_push = set(self.local_heads().values() + self.tags.values())
             new_refs.update(self.get_changed_refs(refs, to_push, True))
-            # don't push anything
-            return {}
+            return refs # always return the same refs to make the send a no-op
 
         try:
-            try:
-                client.send_pack(path, changed, lambda have, want: [])
-            except UpdateRefsError:
-                pass # dulwich throws an error when send_pack doesn't upload
+            client.send_pack(path, changed, lambda have, want: [])
 
             changed_refs = [ref for ref, sha in new_refs.iteritems()
                             if sha != old_refs.get(ref)]

File tests/test-outgoing.t

   $ echo alpha > alpha
   $ git add alpha
   $ commit -m "add alpha"
+  $ git branch alpha
+  $ git show-ref
+  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/alpha
+  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/master
 
   $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ cd hgrepo
+  $ hg update -q master
   $ echo beta > beta
   $ hg add beta
   $ hgcommit -m 'add beta'
   % some more work on master from git
   $ cd gitrepo
 
+Check state of refs after outgoing
+  $ git show-ref
+  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/alpha
+  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/master
+
   $ git checkout master 2>&1 | sed s/\'/\"/g
   Already on "master"
   $ echo delta > delta