Mercurial > hg > hg-git
changeset 544:ebf4ea20ade5
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.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Thu, 27 Sep 2012 22:32:01 -0400 |
parents | 5a688ad69449 |
children | 22b8df4c54c5 |
files | hggit/git_handler.py tests/test-outgoing.t |
diffstat | 2 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -240,14 +240,10 @@ 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)]
--- a/tests/test-outgoing.t +++ b/tests/test-outgoing.t @@ -35,6 +35,10 @@ $ 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' @@ -42,6 +46,7 @@ 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' @@ -99,6 +104,11 @@ % 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