title: Mercurial .hgignore Negative Lookahead
body: <p>Using Mercurial, I need to ignore all files except for those in a certain directory called "keepers".</p>
  
  <p>On the face of things, this seemed easy using Regex and Negative Lookahead; however, although I am able to verify my regex in Regex Buddy and other tools, in TortoiseHg, it doesn't work as expected.</p>
  
  <p>Files:</p>
  
  <ul>
  <li>junk\junk.txt</li>
  <li>junk\text</li>
  <li>keepers\test\test</li>
  <li>keepers\test\test2\hi.txt</li>
  <li>keepersblah.txt</li>
  </ul>
  
  <p>Only the two files under keepers should be not be ignored.</p>
  
  <p>Here is the regex I hoped would work:</p>
  
  <pre><code>^(?!keepers/).+$
  </code></pre>
  
  <p>Regrettably, this causes all files to be ignored.  If I change it to:</p>
  
  <pre><code>^(?!keepers).+$
  </code></pre>
  
  <p>it works as you would expect.  That is it ignores any files/folders that don't start with keepers.  But I do want to ignore files that start with keepers.</p>
  
  <p>Bizarrely, if I change it to this:</p>
  
  <pre><code>^(?!keepers/).+\..+$
  </code></pre>
  
  <p>It will properly match the folder, but it will not ignore files that are not in the keepers folder if they don't have an extension.</p>
  
  <p>Any advice would be appreciated.</p>
  
  <p><em>removing dead ImageShack link</em></p>