-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make git push fail gracefully with nonzero exit status if upstream hg crashes or rejects push #342
base: master
Are you sure you want to change the base?
Make git push fail gracefully with nonzero exit status if upstream hg crashes or rejects push #342
Conversation
Thank you for the patches. Could you add your tests to tests/push.t instead of adding separate tests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind doing a separate PR for this one?
Edit: of course, github doesn't attach that to the commit I added the comment from: d5438e7
I can do that if you like, but push.t is already a long narrative which doesn't seem to involve anything that makes commits in git and pushes them to hg. So it wasn't obvious where to thread these test cases into the narrative -- it looked to me like the wrong place to put these tests altogether; likewise push-refs.t. Are you sure you want me to put these cases in push.t? Should I put them at the end? Reset the repositories first so the history isn't cluttered with extra stuff not germane to whether or not the git commit went through? |
Done: #343 |
These tests use the history that was pulled from mercurial instead of creating fresh commits with git. Technically speaking, you don't need to create more git commits, you just can reset the cinnabar metadata with rollback and push to a new empty (or non-empty) mercurial repo. From that perspective, add your two tests at the end ought to be enough. |
d5438e7
to
184c6d3
Compare
OK, I've moved the tests to the end of tests/push.t instead. Seems awkward to reuse the repository history previously set up by the rest of the test, but it does exhibit the issue and the fix, at least; let me know if I misunderstood what you were asking for. |
PKGREVISION++ (No change to devel/py-hg-cinnabarclone PKGREVISION even though the patch also applies to it, because the patch doesn't change any of the content of the py-hg-cinnabarclone package, which consists mainly of one .py file in git-cinnabar. The patch is applied merely for the convenience of sharing distinfo between the two packages.) Derived from the current state of: glandium/git-cinnabar#342
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have yet to check whether the changes in src/main.rs are what's wanted, but let's already get these comments out.
tests/push.t
Outdated
XXX This should fail with nonzero exit status and not update remote refs: | ||
https://github.com/glandium/git-cinnabar/issues/341 | ||
|
||
$ cat <<EOF >repo/.hg/hgrc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use $REPO
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/push.t
Outdated
ERROR Changes on branch 'default' resulted in multiple heads | ||
To hg::.*/push.t/repo (re) | ||
+ 687e015...846552c 846552c6f25c1b46e784f59d8249fb31afac2996 -> branches/default/tip (forced update) | ||
$ rm repo/.hg/hgrc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Run the command again with `git -c cinnabar.check=traceback <command>` to see the full traceback. | ||
error: git-remote-hg died of signal 6 | ||
To hg::.*/push.t/repo (re) | ||
! [remote rejected] 846552c6f25c1b46e784f59d8249fb31afac2996 -> branches/default/tip (nothing changed on remote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the git log below change too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think I see what's going on: since the first one overwrites the remote refs, even when the second one doesn't do anything, it still keeps the wrong refs from the first push. How about adding a git remote update
to reset the remote to what it's supposed to have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done -- I put a git remote update
in while that part is exhibiting the bug, and removed it with the bug fix.
$ rm repo/.hg/hgrc | ||
$ git -C abc-git log --graph --remotes --oneline --no-abbrev-commit | ||
* 846552c6f25c1b46e784f59d8249fb31afac2996 x | ||
* bc90f2819ad12e294b313097b8763d26ca0c08ae b | ||
* 687e015f9f646bb19797d991f2f53087297fbe14 c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! This should change in the previous commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
@@ -560,11 +560,13 @@ https://github.com/glandium/git-cinnabar/issues/341 | |||
\r (no-eol) (esc) | |||
ERROR Changes on branch 'default' resulted in multiple heads | |||
To hg::.*/push.t/repo (re) | |||
+ 687e015...846552c 846552c6f25c1b46e784f59d8249fb31afac2996 -> branches/default/tip (forced update) | |||
! [remote rejected] 846552c6f25c1b46e784f59d8249fb31afac2996 -> branches/default/tip (nothing changed on remote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XXX above this should be removed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
If connection to upstream is hosed, consider nothing to have been pushed. fix glandium#338
184c6d3
to
67644cc
Compare
OK, I think I have addressed all your comments on the tests. Like I said at the beginning, the changes to src/main.rs probably aren't quite right -- instead of reporting what was rejected, it just pretends nothing changed on the remote. Probably the right thing is to update |
Intended to fix the following three issues:
push-refs.t assumes ~/.gitconfig sets user.name #339(moved to tests/push-refs.t: Set committer name when making a tag. #343)Not 100% sure about the logic here in remote_helper_push, but it seems to produce the desired effect in the test cases. In particular, the mechanism for propagating an error through (resetting
pushed
to empty) seems questionable, and it's not immediately clear to me what to do about multi-part bundlev2 responses.