Package org.tmatesoft.hg.repo

Examples of org.tmatesoft.hg.repo.HgIgnore


    System.out.println(bac.toArray().length);
  }
 
  private void dumpIgnored() throws HgInvalidControlFileException {
    String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"};
    HgIgnore ignore = hgRepo.getIgnore();
    for (int i = 0; i < toCheck.length; i++) {
      System.out.println("Ignored " + toCheck[i] + ": " + ignore.isIgnored(Path.create(toCheck[i])));
    }
  }
View Full Code Here


  }
 
  @Test
  public void testGlobWithAlternatives() throws Exception {
    String content = "syntax:glob\ndoc/*.[0-9].{x,ht}ml";
    HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(content), null);
    final Path p1 = Path.create("doc/asd.2.xml");
    final Path p2 = Path.create("doc/zxc.6.html");
    errorCollector.assertTrue(p1.toString(), hgIgnore.isIgnored(p1));
    errorCollector.assertTrue(p2.toString(), hgIgnore.isIgnored(p2));
  }
View Full Code Here

  }

  @Test
  public void testComplexFileParse() throws Exception {
    BufferedReader br = new BufferedReader(new FileReader(new File(Configuration.get().getTestDataDir(), "mercurial.hgignore")));
    HgIgnore hgIgnore = HgInternals.newHgIgnore(br, null);
    br.close();
    Path[] toCheck = new Path[] {
        Path.create("file.so"),
        Path.create("a/b/file.so"),
        Path.create("#abc#"),
View Full Code Here

  }

  @Test
  public void testSegmentsGlobMatch() throws Exception {
    String s = "syntax:glob\nbin\n.*\nTEST-*.xml";
    HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s), null);
    Path[] toCheck = new Path[] {
        Path.create("bin/org/sample/First.class"),
        Path.create(".ignored-file"),
        Path.create("dir/.ignored-file"),
        Path.create("dir/.ignored-dir/file"),
        Path.create("TEST-a.xml"),
        Path.create("dir/TEST-b.xml"),
    };
    doAssert(hgIgnore, toCheck, null);
    //
    s = "syntax:glob\n.git";
    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/.gittt/cc");
    errorCollector.assertTrue(p.toString(), !hgIgnore.isIgnored(p));
  }
View Full Code Here

  @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));
  }
View Full Code Here

  }

  @Test
  public void testWildcardsDoNotMatchDirectorySeparator() throws Exception {
    String s = "syntax:glob\na?b\nc*d";
    HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s), null);
    // shall not be ignored
    Path[] toPass = new Path[] {
        Path.create("a/b"),
        Path.create("a/b/x"),
        Path.create("x/a/b"),
View Full Code Here

  }

  @Test
  public void testSyntaxPrefixAtLine() throws Exception {
    String s = "glob:*.c\nregexp:.*\\.d";
    HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s), null);
    Path[] toPass = new Path[] {
        create("a/c"),
        create("a/d"),
        create("a/d.a"),
        create("a/d.e"),
View Full Code Here

  @Test
  public void testGlobWithWindowsPathSeparators() throws Exception {
    String s = "syntax:glob\n" + "bin\\*\n" + "*\\dir*\\*.a\n" + "*\\_ReSharper*\\\n";
    // explicit PathRewrite for the test to run on *nix as well
    HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s), new WinToNixPathRewrite());
    Path[] toPass = new Path[] {
        create("bind/x"),
        create("dir/x.a"),
        create("dir-b/x.a"),
        create("a/dir-b/x.b"),
View Full Code Here

    File hgignoreFile = new File(repoLoc, HgRepositoryFiles.HgIgnore.getPath());
    RepoUtils.createFile(hgignoreFile, "bin/");
    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    final Path p1 = Path.create("bin/a/b/c");
    final Path p2 = Path.create("src/a/b/c");
    HgIgnore ignore = hgRepo.getIgnore();
    errorCollector.assertTrue(ignore.isIgnored(p1));
    errorCollector.assertFalse(ignore.isIgnored(p2));
    Thread.sleep(1000); // Linux granularity for modification time is 1 second
    // file of the same length
    RepoUtils.createFile(hgignoreFile, "src/");
    ignore = hgRepo.getIgnore();
    errorCollector.assertFalse(ignore.isIgnored(p1));
    errorCollector.assertTrue(ignore.isIgnored(p2));
   
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.repo.HgIgnore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.