Package org.tmatesoft.hg.util

Examples of org.tmatesoft.hg.util.Path$Matcher


      if (!expected.containsKey(r)) {
        expected.put(r, Nodeid.NULL);
      }
    }
    assertEquals(revisions.length, expected.size());
    final Path path = Path.create(fname);
    repo.getManifest().walkFileRevisions(path, new HgManifest.Inspector() {

      private Nodeid expectedNodeid;
      private int clogRev;
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

    };
    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

  public void testRefreshOnChange() throws Exception {
    File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-refresh-hgignore", false);
    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
View Full Code Here

    }
    if (!isCopy(fileRevisionIndex)) {
      throw new UnsupportedOperationException();
    }
    Path.Source ps = getRepo().getSessionContext().getPathFactory();
    Path origin = ps.path(metadata.find(fileRevisionIndex, "copy"));
    Nodeid originRev = Nodeid.fromAscii(metadata.find(fileRevisionIndex, "copyrev")); // XXX reuse/cache Nodeid
    return new HgFileRevision(getRepo(), originRev, null, origin);
  }
View Full Code Here

  private Path asPath(Path p) {
    CharSequence s = pathRewrite.rewrite(p.toString());
    // rewrite string, not path to avoid use of Path object as key
    // in case pathRewrite does nothing and returns supplied instance
    //
    Path cached = get(s, false);
    if (cached == null) {
      cache.put(s, new SoftReference<Path>(cached = p));
    }
    return cached;
  }
View Full Code Here

    cache.clear();
  }

  private Path get(CharSequence p, boolean create) {
    SoftReference<Path> sr = cache.get(p);
    Path path = sr == null ? null : sr.get();
    if (path == null) {
      if (create) {
        path = Path.create(p);
        cache.put(p, new SoftReference<Path>(path));
      } else if (sr != null) {
View Full Code Here

    public boolean end(int revision) throws HgRuntimeException {
      try {
        if (needDirs) {
          LinkedHashMap<Path, LinkedList<HgFileRevision>> breakDown = new LinkedHashMap<Path, LinkedList<HgFileRevision>>();
          for (HgFileRevision fr : manifestContent) {
            Path filePath = fr.getPath();
            Path dirPath = pathPool.parent(filePath);
            LinkedList<HgFileRevision> revs = breakDown.get(dirPath);
            if (revs == null) {
              revs = new LinkedList<HgFileRevision>();
              breakDown.put(dirPath, revs);
            }
View Full Code Here

  public void testFollowHistory() throws Exception {
    if (repo == null) {
      repo = Configuration.get().own();
      eh.cwd(repo.getWorkingDir());
    }
    final Path f = Path.create("cmdline/org/tmatesoft/hg/console/Remote.java");
    assertTrue(repo.getFileNode(f).exists());
    changelogParser.reset();
    eh.run("hg", "log", "--debug", "--follow", f.toString());
   
    CollectWithRenameHandler h = new CollectWithRenameHandler();
    new HgLogCommand(repo).file(f, true).execute(h);
    errorCollector.assertEquals(1, h.rh.renames.size());
    HgFileRevision from = h.rh.renames.get(0).first();
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.util.Path$Matcher

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.