Package org.tmatesoft.hg.util

Examples of org.tmatesoft.hg.util.FileWalker


  }
 
  private void testTreeTraversal() throws Exception {
    File repoRoot = hgRepo.getWorkingDir();
    Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), hgRepo.getToRepoPathHelper()));
    FileWalker w =  new FileWalker(new BasicSessionContext(null), repoRoot, pathSrc);
    int count = 0;
    final long start = System.currentTimeMillis();
    while (w.hasNext()) {
      count++;
      w.next();
    }
    System.out.printf("Traversal of %d files took %d ms", count, System.currentTimeMillis() - start);
  }
View Full Code Here


    File testRepoLoc = cloneRepoToTempLocation("test-flags", "test-checkout-flags", true);
    repo = new HgLookup().detect(testRepoLoc);
    new HgCheckoutCommand(repo).clean(true).changeset(0).execute();

    Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(testRepoLoc), repo.getToRepoPathHelper()));
    FileWalker fw = new FileWalker(repo, testRepoLoc, pathSrc, null);
    int execFound, linkFound, regularFound;
    execFound = linkFound = regularFound = 0;
    while(fw.hasNext()) {
      fw.next();
      FileInfo fi = fw.file();
      boolean executable = fi.isExecutable();
      boolean symlink = fi.isSymlink();
      if (executable) {
        execFound++;
      }
View Full Code Here

 
  @Test
  public void testFlagsInWorkingCopy() throws Exception {
    File repoRoot = repo.getWorkingDir();
    Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), repo.getToRepoPathHelper()));
    FileWalker fw = new FileWalker(repo, repoRoot, pathSrc, null);
   
    if (Internals.runningOnWindows()) {
      System.out.println("Executing tests on Windows, no actual file flags in working area are checked");
      assertFalse(fw.supportsExecFlag());
      assertFalse(fw.supportsLinkFlag());
      return;
    } else {
      assertTrue(fw.supportsExecFlag());
      assertTrue(fw.supportsLinkFlag());
    }
    ExecHelper eh = new ExecHelper(new OutputParser.Stub(false), repo.getWorkingDir());
    eh.run("hg", "checkout", "-C");

    boolean exec, link, file;
    exec = link = file = false;
    while (fw.hasNext()) {
      fw.next();
      FileInfo fi = fw.file();
      String fn = fw.name().toString();
      if (fn.equals("file-link")) {
        link = true;
        errorCollector.assertTrue("Symlink shall exist despite the fact it points to nowhere", fi.exists());
        errorCollector.assertFalse(fi.isExecutable());
        errorCollector.assertTrue(fi.isSymlink());
View Full Code Here

    File repoRoot = repo.getWorkingDir();
    Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), repo.getToRepoPathHelper()));
    // Impl note: simple source is enough as files in the working dir are all unique
    // even if they might get reused (i.e. after FileIterator#reset() and walking once again),
    // path caching is better to be done in the code which knows that path are being reused
    return new FileWalker(repo, repoRoot, pathSrc, workindDirScope);
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.util.FileWalker

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.