{"id":3393,"date":"2014-12-16T13:54:15","date_gmt":"2014-12-16T12:54:15","guid":{"rendered":"http:\/\/glandium.org\/blog\/?p=3393"},"modified":"2015-02-11T08:20:08","modified_gmt":"2015-02-11T07:20:08","slug":"one-step-closer-to-git-push-to-mercurial","status":"publish","type":"post","link":"https:\/\/glandium.org\/blog\/?p=3393","title":{"rendered":"One step closer to git push to mercurial"},"content":{"rendered":"<p>In case you missed it, I'm working on a new tool to <a href=\"\/blog\/?p=3382\">use mercurial remotes in git<\/a>. Since my previous post, I landed several fixes making clone and pull more reliable:<\/p>\n<ul>\n<li>Of 247316 unique changesets in the various mozilla-* repositories, now only two (but both in fact come from the same patch, one of the changesets being a backport to aurora of the other) are \"corrupted\" because their mercurial date have a <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=838055\">timezone with a second<\/a>.<\/li>\n<li>Of 23542 unique changesets in the <a href=\"http:\/\/selenic.com\/hg\/\">canonical mercurial repository<\/a>, only three are \"corrupted\" because their raw mercurial data contains, for an unknown reason, a whitespace after the timezone.<\/li>\n<\/ul>\n<p>By corrupted, here, I mean that the round-trip hg-&gt;git-&gt;hg doesn't lead to matching their sha1. They will be fixed eventually, but I haven't decided how yet, because they're really edge cases. They're old enough that they don't really matter for push anyways.<\/p>\n<p>Pushing to mercurial, however, is still not there, but it's getting closer. It involves several operations:<\/p>\n<ul>\n<li>Negotiating with the mercurial server what it doesn't have that we do.<\/li>\n<li>Creating mercurial changesets, manifests and files for local git commits that were not imported from mercurial.<\/li>\n<li>Creating a bundle of the mercurial changesets, manifests and files that we have that the server doesn't.<\/li>\n<li>Pushing that bundle to the server.<\/li>\n<\/ul>\n<p>The first step is mostly covered by the pull code, that does a similar negotiation. I now have the third step covered (although I cheated around the \"corruptions\" mentioned above):<\/p>\n<blockquote>\n<pre>$ git clone hg::http:\/\/selenic.com\/hg\r\nCloning into 'hg'...\r\n(...)\r\nChecking connectivity... done.\r\n$ cd hg\r\n$ git hgbundle &gt; ..\/hg.hg\r\n$ mkdir ..\/hg2\r\n$ cd ..\/hg2\r\n$ hg init\r\n$ hg unbundle ..\/hg.hg\r\nadding changesets\r\nadding manifests\r\nadding file changes\r\nadded 23542 changesets with 44305 changes to 2272 files\r\n(run 'hg update' to get a working copy)\r\n$ hg verify\r\nchecking changesets\r\nchecking manifests\r\ncrosschecking files in changesets and manifests\r\nchecking files\r\n2272 files, 23542 changesets, 44305 total revisions\r\n<\/pre>\n<\/blockquote>\n<p>Note: that <code>hgbundle<\/code> command won't actually exist. It's just an intermediate step allowing me to work incrementally.<\/p>\n<p>In case you wonder what happens when the bundle contains bad data, mercurial fortunately rejects it:<\/p>\n<blockquote>\n<pre>$ cd ..\/hg\r\n$ git hgbundle-corrupt &gt; ..\/hg.hg\r\n$ mkdir ..\/hg3\r\n$ cd ..\/hg3\r\n$ hg unbundle ..\/hg.hg\r\nadding changesets\r\ntransaction abort!\r\nrollback completed\r\nabort: integrity check failed on 00changelog.i:3180!\r\n<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>In case you missed it, I&#8217;m working on a new tool to use mercurial remotes in git. Since my previous post, I landed several fixes making clone and pull more reliable: Of 247316 unique changesets in the various mozilla-* repositories, now only two (but both in fact come from the same patch, one of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,25],"tags":[23],"class_list":["post-3393","post","type-post","status-publish","format-standard","hentry","category-cinnabar","category-planet-mozilla","tag-en"],"_links":{"self":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3393"}],"version-history":[{"count":11,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3393\/revisions"}],"predecessor-version":[{"id":3404,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3393\/revisions\/3404"}],"wp:attachment":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}