Examples of HgInternals


Examples of org.tmatesoft.hg.repo.HgInternals

      return true;
    }
  }
 
  private void dumpDirstate() throws Exception {
    new HgInternals(hgRepo).getDirstate().walk(new DirstateDump());
    HgWorkingCopyStatusCollector wcc = HgWorkingCopyStatusCollector.create(hgRepo, new Path.Matcher.Any());
    wcc.getDirstate().walk(new HgDirstate.Inspector() {
     
      public boolean next(EntryKind kind, Record entry) {
        System.out.printf("%s %s\n", kind, entry.name());
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

    assertTrue(e.getString(ext2_key, null).length() > 0);
    assertFalse(e.isEnabled(ext2_key));
    assertNotNull(e.getString(ext3_key, null));
    assertTrue(e.isEnabled(ext3_key.substring("hgext.".length())));
    //
    assertEquals(username, new HgInternals(repo).getNextCommitUsername());
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

    return null;
  }

  public String getNextCommitUsername() {
    if (nextCommitAuthor == null) {
      nextCommitAuthor = new HgInternals(repo).getNextCommitUsername();
    }
    return nextCommitAuthor;
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

  private String detectUser() {
    if (user != null) {
      return user;
    }
    // TODO HgInternals is odd place for getNextCommitUsername()
    return new HgInternals(repo).getNextCommitUsername();
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

    repo = Configuration.get().find("log-branches");
    final Pair<Nodeid, Nodeid> wcParents = repo.getWorkingCopyParents();
    assertEquals("5f24ef64e9dfb1540db524f88cb5c3d265e1a3b5", wcParents.first().toString());
    assertTrue(wcParents.second().isNull());
    //
    HgDirstate ds = new HgInternals(repo).getDirstate();
    final Pair<Nodeid, Nodeid> wcParents2 = ds.parents();
    assertEquals(wcParents.first(), wcParents2.first());
    assertEquals(wcParents.second(), wcParents2.second());
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

    // 1. dirstate: /a/b/c, FileIterator: /a/B/C
    // 2. dirstate: /a/B/C, FileIterator: /a/b/c
    // 2. dirstate: /a/B/C, FileIterator: /A/b/C
    repo = Configuration.get().find("mixed-case");
    // Windows, case-insensitive file system
    final HgInternals testAccess = new HgInternals(repo);
    HgDirstate dirstate = testAccess.createDirstate(false);
    final TreeSet<Path> entries = new TreeSet<Path>();
    dirstate.walk(new HgDirstate.Inspector() {
     
      public boolean next(EntryKind kind, Record entry) {
        entries.add(entry.name());
        return true;
      }
    });
    Path[] expected = new Path[] {
      Path.create("a/low/low"),
      Path.create("a/low/UP"),
      Path.create("a/UP/low"),
      Path.create("a/UP/UP"),
    };
    Path[] allLower = new Path[expected.length];
    Path[] allUpper = new Path[expected.length];
    Path[] mixedNonMatching = new Path[expected.length];
    for (int i = 0; i < expected.length; i++) {
      assertTrue("prereq", entries.contains(expected[i]));
      final String s = expected[i].toString();
      allLower[i] = Path.create(s.toLowerCase());
      allUpper[i] = Path.create(s.toUpperCase());
      char[] ss = s.toCharArray();
      for (int j = 0; j < ss.length; j++) {
        if (isLetter(ss[j])) {
          ss[j] = isLowerCase(ss[j]) ? toUpperCase(ss[j]) : toLowerCase(ss[j]);
        }
      }
      Path mixed = Path.create(new String(ss));
      mixedNonMatching[i] = mixed;
    }
    // prereq
    checkKnownInDirstate(testAccess, dirstate, expected, expected);
    // all upper
    checkKnownInDirstate(testAccess, dirstate, allUpper, expected);
    // all lower
    checkKnownInDirstate(testAccess, dirstate, allLower, expected);
    // mixed
    checkKnownInDirstate(testAccess, dirstate, mixedNonMatching, expected);
    //
    // check that in case-sensitive file system mangled names do not match
    dirstate = testAccess.createDirstate(true);
    // ensure read
    dirstate.walk(new HgDirstate.Inspector() {
      public boolean next(EntryKind kind, Record entry) {
        return false;
      }
    });
    Path[] known = testAccess.checkKnown(dirstate, mixedNonMatching);
    for (int i = 0; i < known.length; i++) {
      if (known[i] != null) {
        fail(expected[i] + " in case-sensitive dirstate matched " + known[i]);
      }
    }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

  private List<HgSubrepoLocation> readConfig(BufferedReader br, Map<String, String> substate) throws IOException {
    try {
      String line;
      LinkedList<HgSubrepoLocation> res = new LinkedList<HgSubrepoLocation>();
      HgInternals hgRepoInternal = new HgInternals(repo);
      final Path.Source pathFactory = repo.getSessionContext().getPathFactory();
      while ((line = br.readLine()) != null) {
        int sep = line.indexOf('=');
        if (sep == -1) {
          continue;
        }
        // since both key and value are referenced from HgSubrepoLocation, doesn't make sense
        // to have separate String instances (new String(line.substring()))
        String key = line.substring(0, sep).trim();
        String value = line.substring(sep + 1).trim();
        if (key.length() == 0 || value.length() == 0) {
          // XXX log bad line?
          continue;
        }
        HgSubrepoLocation.Kind kind = HgSubrepoLocation.Kind.Hg;
        int kindEnd = value.indexOf(']', 1);
        if (value.charAt(0) == '[' && kindEnd != -1) {
          String kindStr = value.substring(1, kindEnd);
          value = value.substring(kindEnd + 1);
          if ("svn".equals(kindStr)) {
            kind = HgSubrepoLocation.Kind.SVN;
          } else if ("git".equals(kindStr)) {
            kind = HgSubrepoLocation.Kind.Git;
          }
        }
        // TODO respect paths mappings in config file
        //
        // apparently, key value can't end with '/', `hg commit` fails if it does:
        // abort: path ends in directory separator: fourth/
        Path p = pathFactory.path(key.charAt(key.length()-1) == '/' ? key : key + '/');
        String revValue = substate.get(key);
        HgSubrepoLocation loc = hgRepoInternal.newSubrepo(p, value, kind, revValue == null ? null : Nodeid.fromAscii(revValue));
        res.add(loc);
      }
      return Arrays.asList(res.toArray(new HgSubrepoLocation[res.size()]));
    } finally {
      br.close();
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgInternals

      Internals internalRepo = Internals.getInstance(repo);
      if (cleanCheckout) {
        // remove tracked files from wd (perhaps, just forget 'Added'?)
        // for now, just delete each and every tracked file
        // TODO WorkingCopy container with getFile(HgDataFile/Path) to access files in WD
        HgDirstate dirstate = new HgInternals(repo).getDirstate();
        dirstate.walk(new HgDirstate.Inspector() {
         
          public boolean next(EntryKind kind, Record entry) {
            File f = new File(repo.getWorkingDir(), entry.name().toString());
            if (f.exists()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.