{"id":235,"date":"2011-08-24T12:21:31","date_gmt":"2011-08-24T19:21:31","guid":{"rendered":"http:\/\/blog.mozilla.org\/sfink\/?p=235"},"modified":"2011-09-19T11:29:29","modified_gmt":"2011-09-19T18:29:29","slug":"hg-qedit","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/sfink\/2011\/08\/24\/hg-qedit\/","title":{"rendered":"hg qedit"},"content":{"rendered":"<p>On <a href='http:\/\/blog.zpao.com\/post\/8695952974\/hg-qedit'>his blog<\/a>, Paul O\u2019Shannessy came up with an &#8216;hg qedit&#8217; alias that opens up an editor on your .hg\/patches\/series file for reordering your patch queue. It&#8217;s a nice simple solution to a common problem, so obviously I felt compelled to muck it up.<\/p>\n<p>Here&#8217;s my version, for insertion into your ~\/.hgrc:<\/p>\n<pre>\r\n[alias]\r\nqedit = !S=$(hg root)\/.hg\/patches\/series; cp $S $S.bak && perl -pale 'BEGIN { chomp(@a = qx(hg qapplied -q)); die if $?; @a{@a}=(); }; s\/^\/# (applied) \/ if exists $a{$F[0]}' $S > $S.new && ${EDITOR-vim} $S.new && sed -e 's\/^# .applied. \/\/' $S.new > $S\r\n                                                                                                                                                                                                                   # Did you see this by scrolling over?\r\n                                                                                                                                                                                                                   # I want better code snippet support\r\n<\/pre>\n<p>This fixes the main problem with zpao&#8217;s solution, which is that it&#8217;s too clean and simple.<\/p>\n<p>No, wait, that&#8217;s not a problem.<\/p>\n<p>The problem is that when I edit my series file, I often forget that I have some patches applied and end up reordering applied patches, which makes a complete mess. The above alias opens up an editor on your series file, only it also inserts comments showing which patches are already applied. (If you really, really want to mess yourself up, go ahead and reorder the commented lines. You&#8217;ll get what you deserve.)<\/p>\n<p>Here&#8217;s what my queue looks like when editing the series file:<\/p>\n<pre>\r\n# (applied) better-dtrace-probes\r\n# (applied) try-enable-dtrace\r\n# (applied) bug-650078-no-remote\r\nbug-677985-callouts\r\nbug-677949-gc-roots\r\nhack-stackiter\r\n<\/pre>\n<p>Come to think of it, mq really shouldn&#8217;t let you mess up that way in the first place. It knows the original patch names for your applied patches (unless you are <b>really<\/b> determined to make your life difficult, and commit things on top without going through mq at all). It could detect when you reordered applied patches, and just undo what you did. And call you names. But maybe that would slow things down.<\/p>\n<p><strong>Update<\/strong>: it wasn&#8217;t working for jlebar, which turned out to be because he had added <code>qapplied=-v<\/code> to his <code>[defaults]<\/code> section. The above is now fixed for that scenario by adding a <code>-q<\/code> flag to <code>hg qapplied<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On his blog, Paul O\u2019Shannessy came up with an &#8216;hg qedit&#8217; alias that opens up an editor on your .hg\/patches\/series file for reordering your patch queue. It&#8217;s a nice simple solution to a common problem, so obviously I felt compelled to muck it up. Here&#8217;s my version, for insertion into your ~\/.hgrc: [alias] qedit = [&hellip;]<\/p>\n","protected":false},"author":206,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[477,137],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/posts\/235"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/users\/206"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}