@Test
public void testSegmentsRegexMatch() throws Exception {
// regex patterns that don't start with explicit ^ are allowed to match anywhere in the string
String s = "syntax:regexp\n/\\.git\n^abc\n";
HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s), null);
Path p = Path.create(".git/aa");
errorCollector.assertTrue(p.toString(), !hgIgnore.isIgnored(p));
p = Path.create("dir/.git/bb");
errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p));
p = Path.create("dir/abc/aa");
errorCollector.assertTrue(p.toString(), !hgIgnore.isIgnored(p));
p = Path.create("abc/bb");
errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p));
// Mercurial (in fact, likely pyton's regex match() function) treats
// regex patterns as having .* at the end (unless there's explicit $).
// IOW, matches to the beginning of the string, not to the whole string
p = Path.create("abcde/fg");
errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p));
}