{"id":43,"date":"2009-12-02T09:44:36","date_gmt":"2009-12-02T14:44:36","guid":{"rendered":"http:\/\/blog.mozilla.org\/ted\/?p=43"},"modified":"2009-12-22T07:17:38","modified_gmt":"2009-12-22T12:17:38","slug":"easy-branch-landing-of-patches","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/ted\/2009\/12\/02\/easy-branch-landing-of-patches\/","title":{"rendered":"Easy branch-landing of patches"},"content":{"rendered":"<p>I often find myself landing patches on our <a href=\"http:\/\/hg.mozilla.org\/releases\/mozilla-1.9.2\/\">1.9.2<\/a> and <a href=\"http:\/\/hg.mozilla.org\/releases\/mozilla-1.9.1\/\">1.9.1<\/a> branches, both of which are in <a href=\"http:\/\/mercurial.selenic.com\/\">Mercurial<\/a> repositories. This generally involves getting a changeset from the <a href=\"http:\/\/hg.mozilla.org\/mozilla-central\/\">mozilla-central<\/a> repository into one of these repositories, and also amending the changeset message to include the name of the person who gave me approval to land. There was <a title=\"Thread: Adding &quot;APPROVAL REQUIRED&quot; to the CLOSED TREE hook.\" href=\"http:\/\/groups.google.com\/group\/mozilla.dev.tree-management\/browse_thread\/thread\/352bc473c506ab1a\/\">some discussion recently<\/a> on how it&#8217;s kind of a pain to do that. I&#8217;ve cooked up an easy solution for my own needs, perhaps it will serve yours as well.<\/p>\n<p>I use &#8220;<a href=\"http:\/\/mercurial.selenic.com\/wiki\/TransplantExtension\">hg transplant<\/a>&#8221; to get changesets from one repository to another. This assumes that you have local clones of both the source repository (mozilla-central in this case) and the destination repository (mozilla-1.9.2 or 1.9.1, usually). Assuming you had both clones side-by-side in a directory, you could run the transplant command in the destination repository&#8217;s working directory like so (where xxx is the changeset identifier of the changeset you want transplanted, you can also specify more than one changeset):<\/p>\n<pre>hg transplant -s ..\/mozilla-central xxx<\/pre>\n<p>The transplant command conveniently includes a &#8220;&#8211;filter&#8221; option that will let you alter the commit message or patch while transplanting. This requires you to have some sort of script for transplant to run. Here&#8217;s what I&#8217;m using (on Linux):<\/p>\n<pre>#!\/bin\/sh\r\n\r\nif test -n \"$APPEND\"; then\r\n echo \" $APPEND\" &gt;&gt; \"$1\";\r\nelse\r\n if test -n \"$EDITOR\"; then\r\n $EDITOR \"$1\";\r\n else\r\n editor \"$1\";\r\n fi\r\nfi<\/pre>\n<p>Save this as &#8220;<a href=\"http:\/\/people.mozilla.com\/~tmielczarek\/transplant.sh\">transplant.sh<\/a>&#8221; somewhere (and ensure that it&#8217;s executable), then in your ~\/.hgrc, add a section:<\/p>\n<pre>[transplant]\r\nfilter = \/path\/to\/transplant.sh<\/pre>\n<p>Now, when you run &#8220;hg transplant&#8221;, by default it will open an editor to edit the commit message for each changeset, allowing you to add approval information. But, even better, transplant.sh will append the contents of the &#8220;APPEND&#8221; variable if set, so you can run transplant like so to quickly append approval information:<\/p>\n<pre>APPEND=\"a=someone\" hg transplant -s ..\/mozilla-central xxx<\/pre>\n<p>I find that this saves me a bunch of time, so hopefully it&#8217;s useful to someone else!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I often find myself landing patches on our 1.9.2 and 1.9.1 branches, both of which are in Mercurial repositories. This generally involves getting a changeset from the mozilla-central repository into one of these repositories, and also amending the changeset message to include the name of the person who gave me approval to land. There was [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,289],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/posts\/43"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}