PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/2014/04/01/using-mercurial-for-status-reports/index.html

https://github.com/indygreg/indygreg.github.com
HTML | 205 lines | 162 code | 32 blank | 11 comment | 0 complexity | 2444b9c134b6e0b26ddf6d07ca6417dd MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <!--
  4. Design by Free CSS Templates
  5. http://www.freecsstemplates.org
  6. Released for free under a Creative Commons Attribution 2.5 License
  7. Name : Pollinating
  8. Description: A two-column, fixed-width design with dark color scheme.
  9. Version : 1.0
  10. Released : 20101114
  11. -->
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  15. <title>Gregory Szorc's Digital Home
  16. | Using Mercurial for Status Reports
  17. </title>
  18. <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/blog/feed" />
  19. <link rel="alternate" type="application/atom+xml" title="Atom 1.0"
  20. href="/blog/feed/atom" />
  21. <link rel="stylesheet" href="/style/style.css" type="text/css" />
  22. <link rel="stylesheet" href="/css/pygments_murphy.css" type="text/css" />
  23. </head>
  24. <body>
  25. <div id="wrapper">
  26. <div id="menu">
  27. <ul>
  28. <li><a href="/">Home</a></li>
  29. <li><a href="/blog/">Blog</a></li>
  30. <li><a href="/notes">Notes</a></li>
  31. <li><a href="/work.html">Work</a></li>
  32. <li><a href="/skills.html">Skills</a></li>
  33. <li><a href="/thoughts.html">Thoughts</a></li>
  34. <li><a href="/resume.pdf">Resume</a></li>
  35. </ul>
  36. </div>
  37. <div id="page">
  38. <div id="page-bgtop">
  39. <div id="page-bgbtm">
  40. <div id="content">
  41. <div class="blog_post">
  42. <a name="using-mercurial-for-status-reports"></a>
  43. <h2 class="blog_post_title"><a href="/blog/2014/04/01/using-mercurial-for-status-reports" rel="bookmark" title="Permanent Link to Using Mercurial for Status Reports">Using Mercurial for Status Reports</a></h2>
  44. <small>April 01, 2014 at 12:30 PM | categories:
  45. <a href='/blog/category/mercurial'>Mercurial</a>, <a href='/blog/category/mozilla'>Mozilla</a>
  46. </small><p/>
  47. <div class="post_prose">
  48. <p>Mercurial has a pair of amazing features called
  49. <a href="http://www.selenic.com/hg/help/revsets">Revisions Sets</a>
  50. and <a href="http://www.selenic.com/hg/help/templates">Templates</a>. Combined,
  51. they allow you to query Mercurial like a database and to generate custom
  52. reports from obtained data.</p>
  53. <p>As I've <a href="/blog/2013/11/08/using-mercurial-to-query-mozilla-metadata/">demonstrated</a>,
  54. you can write Mercurial extensions to provide custom revision set
  55. queries and template functions and keywords. My
  56. <a href="https://hg.mozilla.org/hgcustom/version-control-tools/file/default/hgext/mozext">mozext</a>
  57. extension aggregates Mozilla's <em>pushlog</em> data into a local SQLite
  58. database and makes this data available to revision sets and templates.</p>
  59. <p>My hack of the day is to use revision sets and templates to create a
  60. weekly status report:</p>
  61. <div class="pygments_murphy"><pre><span></span>hg log -r &#39;public() and me() and firstpushdate(&quot;-7&quot;)&#39; \
  62. --template &#39;* {ifeq(reviewer, &quot;gps&quot;, &quot;Review: &quot;, &quot;Landing: &quot;)}{firstline(desc)}\n&#39;
  63. </pre></div>
  64. <p>When I run this, I get the output:</p>
  65. <div class="pygments_murphy"><pre><span></span>* Review: Bug 957241 - Don&#39;t package the full sdk when we don&#39;t need it. r=gps
  66. * Review: Bug 987146 - Represent SQL queries more efficiently. r=gps.
  67. * Review: Bug 987984 - VirtualenvManager.call_setup() should use self.python_path instead of sys.executable, r=gps
  68. * Landing: Bug 987398 - Part 1: Run mochitests from manifests with mach; r=ahal
  69. * Landing: Bug 987398 - Part 2: Handle install-to-subdir in TestResolver; r=ahal
  70. * Landing: Bug 987414 - Pass multiple test arguments to mach testing commands; r=ahal
  71. * Review: Bug 988141 - Clean up config/recurse.mk after bug 969164. r=gps
  72. * Landing: Bug 973992 - Support experiments add-ons; r=Unfocused
  73. * Review: Bug 927672 - Force pymake to fall back to mozmake when run on build slaves. r=gps
  74. * Review: Bug 989147 - Use new sccache for Linux and Android builds. r=gps
  75. * Review: Bug 989147 - Add missing part of the patch from rebase conflict. r=gps
  76. * Landing: Bug 975000 - Disable updating and compatibility checking for Experiments; r=Unfocused
  77. * Landing: Bug 985084 - Experiment add-ons should be disabled by default; r=Unfocused
  78. * Landing: Backed out changeset 4834a3833639 and c580afddd1cb (bug 985084 and bug 97500)
  79. * Landing: Bug 975000 - Disable updating and compatibility checking for Experiments; r=Unfocused
  80. * Landing: Bug 985084 - Experiment add-ons should be disabled by default; r=Unfocused
  81. * Landing: Bug 989137 - Part 1: Uninstall unknown experiments; r=Unfocused
  82. * Landing: Bug 989137 - Part 2: Don&#39;t use a global logger; r=gfritzsche
  83. * Landing: Bug 989137 - Part 3: Log.jsm API to get a Logger that prefixes messages; r=bsmedberg
  84. * Landing: Bug 989137 - Part 4: Use a prefixing logger for Experiments logging; r=gfritzsche
  85. * Landing: Bug 989137 - Part 5: Prefix each log message with the instance of the object; r=gfritzsche
  86. * Review: Bug 988849 - Add mach target for jit tests; r=gps
  87. * Landing: Bug 989137 - Part 6: Create experiment XPIs during the build; r=bsmedberg
  88. * Landing: Bug 989137 - Part 7: Remove unncessary content from test experiments; r=Unfocused
  89. * Landing: Bug 985084 - Part 2: Properly report userDisabled in the API; r=Unfocused
  90. </pre></div>
  91. <p>Which I can then copy and paste directly into the
  92. <a href="http://benjamin.smedbergs.us/weekly-updates.fcgi/">status tool</a> to
  93. capture all my weekly code contributions! That takes a few seconds to
  94. run and saves me a few minutes of typing.</p>
  95. <p>For the curious, let's break that Mercurial command down.</p>
  96. <ul>
  97. <li>public() selects all <em>public</em> changesets. These are changesets in the
  98. repository that have been pushed to a publishing repository. In other
  99. words, patches that landed in Firefox.</li>
  100. <li>me() is a custom revset from my <em>mozext</em> extension that parses the
  101. commit message and selects changesets that I authored or reviewed.</li>
  102. <li>firstpushdate("-7") is a custom revset from my <em>mozext</em> extension. It
  103. selects changesets that were first pushed in the last 7 days (using
  104. pushlog data stored in a local SQLite database).</li>
  105. </ul>
  106. <p>The template piece should be easy to read. I have a simple branch
  107. testing whether the changeset is a review or not, then output a label
  108. followed by the first line of the commit message.</p>
  109. <p>I have this command saved under the <em>[alias]</em> section of my <em>~/.hgrc</em>
  110. file so I can just type <em>hg statusreport</em>.</p>
  111. <p>While there is room to improve the tool (stripping <em>r=</em> lines from
  112. commit messages for example), I think it's a pretty cool hack and shows
  113. how Mercurial can grow to solve problems you don't think your version
  114. control system knows how to solve.</p>
  115. </div>
  116. </div>
  117. </div>
  118. <div id="sidebar">
  119. <ul>
  120. <li>
  121. <h2>Categories</h2>
  122. <ul>
  123. <li><a href="/blog/category/apple">Apple</a></li>
  124. <li><a href="/blog/category/bugzilla">Bugzilla</a></li>
  125. <li><a href="/blog/category/ci">CI</a></li>
  126. <li><a href="/blog/category/clang">Clang</a></li>
  127. <li><a href="/blog/category/docker">Docker</a></li>
  128. <li><a href="/blog/category/firefox">Firefox</a></li>
  129. <li><a href="/blog/category/git">Git</a></li>
  130. <li><a href="/blog/category/javascript">JavaScript</a></li>
  131. <li><a href="/blog/category/mercurial">Mercurial</a></li>
  132. <li><a href="/blog/category/mozreview">MozReview</a></li>
  133. <li><a href="/blog/category/mozilla">Mozilla</a></li>
  134. <li><a href="/blog/category/personal">Personal</a></li>
  135. <li><a href="/blog/category/programming">Programming</a></li>
  136. <li><a href="/blog/category/puppet">Puppet</a></li>
  137. <li><a href="/blog/category/pyoxidizer">PyOxidizer</a></li>
  138. <li><a href="/blog/category/python">Python</a></li>
  139. <li><a href="/blog/category/review-board">Review Board</a></li>
  140. <li><a href="/blog/category/rust">Rust</a></li>
  141. <li><a href="/blog/category/sync">Sync</a></li>
  142. <li><a href="/blog/category/browsers">browsers</a></li>
  143. <li><a href="/blog/category/build-system">build system</a></li>
  144. <li><a href="/blog/category/code-review">code review</a></li>
  145. <li><a href="/blog/category/compilers">compilers</a></li>
  146. <li><a href="/blog/category/internet">internet</a></li>
  147. <li><a href="/blog/category/logging">logging</a></li>
  148. <li><a href="/blog/category/mach">mach</a></li>
  149. <li><a href="/blog/category/make">make</a></li>
  150. <li><a href="/blog/category/misc">misc</a></li>
  151. <li><a href="/blog/category/movies">movies</a></li>
  152. <li><a href="/blog/category/packaging">packaging</a></li>
  153. <li><a href="/blog/category/pymake">pymake</a></li>
  154. <li><a href="/blog/category/security">security</a></li>
  155. <li><a href="/blog/category/sysadmin">sysadmin</a></li>
  156. <li><a href="/blog/category/testing">testing</a></li>
  157. </ul>
  158. </li>
  159. </ul>
  160. </div>
  161. <div style="clear: both;">&nbsp;</div>
  162. </div>
  163. </div>
  164. </div>
  165. <div id="footer">
  166. <hr/>
  167. <p>Copyright (c) 2012- Gregory Szorc. All rights reserved. Design by <a href="http://www.freecsstemplates.org/"> CSS Templates</a>.</p>
  168. </div>
  169. </div>
  170. </body>
  171. </html>