{"thread":{"id":"32750","subject":"Updating shared ref from remote helper, or fetch hook","startedAt":"2013-01-28T05:19:36Z","lastAt":"2013-01-30T08:06:41Z","messageCount":3,"participants":["Jed Brown","Max Horn"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"208053","messageId":"87ehh5lw9j.fsf@59A2.org","threadId":"32750","inReplyTo":null,"subject":"Updating shared ref from remote helper, or fetch hook","fromName":"Jed Brown","fromEmail":"jed@59a2.org","sentAt":"2013-01-28T05:19:36Z","receivedAt":"2013-01-28T05:19:36Z","isPatch":false,"sender":{"key":"jed@59a2.org","avatar":"https://gravatar.com/avatar/1391d04d82555f9058a9fdf5eead233e909a48e40480db31fc554e7afeb301da?d=mp&s=160"},"body":"I'm working on an hg remote helper that uses git notes for the sha1\nrevision, so that git users can more easily refer to specific commits\nwhen communicating with hg users.  Since there may be multiple\nconcurrent fast-import streams, I write the notes to a private ref\n(refs/notes/hg-REMOTE), to be merged eventually using\n\n  git notes --ref hg merge hg-REMOTE*\n\nThere will never be conflicts because each hg commit translates to a\nunique git commit, thus even if multiple concurrent remotes process the\nsame commit, the corresponding note will match.\n\nUnfortunately, I couldn't find a safe way to get this run after a fetch\nor clone.  Of course I can ask the user to arrange to have this command\nrun, but it would be a better interface to have it run automatically\nsince it is a natural responsibility of the remote helper.  Am I missing\na way to do this or a viable alternative approach?\n"},{"id":"208188","messageId":"EAAA778A-EEAE-42C6-95C1-21F47F8DBC64@quendi.de","threadId":"32750","inReplyTo":"87ehh5lw9j.fsf@59A2.org","subject":"Re: Updating shared ref from remote helper, or fetch hook","fromName":"Max Horn","fromEmail":"max@quendi.de","sentAt":"2013-01-29T15:00:14Z","receivedAt":"2013-01-29T15:00:14Z","isPatch":false,"sender":{"key":"max@quendi.de","avatar":"https://avatars.githubusercontent.com/u/241512?v=4"},"body":"Hi Jed, all,\n\n\nOn 28.01.2013, at 06:19, Jed Brown wrote:\n\n> I'm working on an hg remote helper that uses git notes for the sha1\n> revision, so that git users can more easily refer to specific commits\n> when communicating with hg users.\n\nFor the record, I am also working on that very same thing; it is yet another git-remote-hg alternative, based on Felipe's code but with many improvements. You can find it here: <https://github.com/buchuki/gitifyhg>.\n\nAnyway, back to Jed's (and also my) question:\n\n>  Since there may be multiple\n> concurrent fast-import streams, I write the notes to a private ref\n> (refs/notes/hg-REMOTE), to be merged eventually using\n> \n>  git notes --ref hg merge hg-REMOTE*\n> \n> There will never be conflicts because each hg commit translates to a\n> unique git commit, thus even if multiple concurrent remotes process the\n> same commit, the corresponding note will match.\n> \n> Unfortunately, I couldn't find a safe way to get this run after a fetch\n> or clone.  Of course I can ask the user to arrange to have this command\n> run, but it would be a better interface to have it run automatically\n> since it is a natural responsibility of the remote helper.  Am I missing\n> a way to do this or a viable alternative approach?\n\nOne idea we (well, Jed :-) had when brain storming about this was that perhaps one could (or even should?) (ab)use the \"checkpoint\" feature for that.\n\nBasically, when the remote-helper is almost done with everything, issue a \"checkpoint\" command, to flush out everything we just imported to the HD. \n\nThen once this completed, we can perform the notes merge. The main remaining problem with that is: How would we know when the \"checkpoint\" actually completed? Any ideas?\n\nPerhaps a way to do that would be to make use of the new \"bidi-import\" remote helper capability -- if I understand it right, then this effectively connects the fast-import stdout to the stdin of the remote helper. Thus, if one were to follow the \"checkpoint\" by a \"progress\" command, then by waiting for that progress command's output to appear back on stdin, the remote helper could determine whether the import succeeded, and perform finalization actions (like merging notes, as in our case).\n\n\nDoes that sound viable? Crazy? Anybody got better a idea?\n\n\nCheers,\nMax"},{"id":"208252","messageId":"874nhzksby.fsf@59A2.org","threadId":"32750","inReplyTo":"87ehh5lw9j.fsf@59A2.org","subject":"Re: Updating shared ref from remote helper, or fetch hook","fromName":"Jed Brown","fromEmail":"jed@59a2.org","sentAt":"2013-01-30T08:06:41Z","receivedAt":"2013-01-30T08:06:41Z","isPatch":false,"sender":{"key":"jed@59a2.org","avatar":"https://gravatar.com/avatar/1391d04d82555f9058a9fdf5eead233e909a48e40480db31fc554e7afeb301da?d=mp&s=160"},"body":"Jed Brown <jed@59A2.org> writes:\n\n> I'm working on an hg remote helper that uses git notes for the sha1\n> revision, so that git users can more easily refer to specific commits\n> when communicating with hg users.  Since there may be multiple\n> concurrent fast-import streams, I write the notes to a private ref\n> (refs/notes/hg-REMOTE), to be merged eventually using\n>\n>   git notes --ref hg merge hg-REMOTE*\n\nA related issue is that when a remote helper replies to an 'import' with\n_only_ a commit in refs/notes/, git (fetch or pull) produces an error\nmessage like\n\n  error: refs/notes/hg-84b3865b750a567acb16929c21e14c4a45a5639b does not point to a valid object\n\nbut successfully updates the ref (which is indeed valid) and returns\n0. I have not been able to determine what exactly git thinks is\ninvalid. As long as there is at least one non-notes commit in the\nstream, no such error message is produced.\n\nIs this behavior intended?\n"}]}