title: Mercurial: check whether last pull/update introduced changes
body: <p>I am the process of writing an update script, which pulls the latest version of a number of repositories, and rebuilds the projects. I wanted to make the build conditional, so I tried </p>
  
  <pre><code>hg pull -u &amp;&amp; ant clean build
  </code></pre>
  
  <p>and the variation</p>
  
  <pre><code>hg pull; hg update &amp;&amp; ant clean build
  </code></pre>
  
  <p>However, the ant build is always invoked, even when nothing has changed. I know that I can use <code>hg incoming</code> to check for changes before doing the pull, but this feels wasteful to me.</p>
  
  <p>How can I check for new changes, without having to contact the server twice (once for <code>hg incoming</code>, once for <code>hg pull</code>)?</p>
  
  <p><strong>UPDATE:</strong> This is my build script now:</p>
  
  <pre><code>update() {
    TIP=$(hg tip --template "{node"})
    hg pull -u
    if test "$TIP" != $(hg tip --template "{node}"); then
      ant clean build
    fi
  }
  
  (cd repo1; update )
  (cd repo2; update )
  </code></pre>
  
  <p>And for people wondering why I do a clean build every time, there are two reasons for that:</p>
  
  <ol>
  <li>The repositories depend on each other, and when the API in one of them changes, I need to do a full rebuild to find places where these API changes break code</li>
  <li>The Java compiler inlines constants, also from other class files. Now, when I change a constant in a class back to a field that can change, all other class files using that constant remain untouched by a build, and this can lead to subtle bugs that I want to avoid.</li>
  </ol>