Examples of HgDataFile


Examples of org.tmatesoft.hg.repo.HgDataFile

   * Walks changelog in reverse order
   * @param file
   * @return changeset where specified file is mentioned among affected files, or <code>null</code> if none found up to leftBoundary
   */
  public RawChangeset findLatestChangeWith(Path file) throws HgRuntimeException {
    HgDataFile df = repo.getFileNode(file);
    if (!df.exists()) {
      return null;
    }
    int changelogRev = df.getChangesetRevisionIndex(HgRepository.TIP);
    if (changelogRev >= leftBoundary) {
      // the method is likely to be invoked for different files,
      // while changesets might be the same. Cache 'em not to read too much.
      RawChangeset cs = cache.get(changelogRev);
      if (cs == null) {
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

       * Imagine csetA and csetB, with corresponding manifestA and manifestB, the file didn't change (revision/nodeid is the same)
       * but flag of the file has changed (e.g. became executable). Since HgFileRevision doesn't keep reference to
       * an actual manifest revision, but only file's, and it's likely the flags returned from this method would
       * yield result as from manifestA (i.e. no flag change in manifestB ever noticed).
       */
      HgDataFile df = repo.getFileNode(path);
      int revIdx = df.getRevisionIndex(revision);
      flags = df.getFlags(revIdx);
    }
    return flags;
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

   * @return parent revisions of this file revision, with {@link Nodeid#NULL} for missing values.
   * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
   */
  public Pair<Nodeid, Nodeid> getParents() throws HgRuntimeException {
    if (parents == null) {
      HgDataFile fn = repo.getFileNode(path);
      int revisionIndex = fn.getRevisionIndex(revision);
      int[] pr = new int[2];
      byte[] p1 = new byte[20], p2 = new byte[20];
      // XXX Revlog#parents is not the best method to use here
      // need smth that gives Nodeids (piped through Pool<Nodeid> from repo's context)
      fn.parents(revisionIndex, pr, p1, p2);
      parents = new Pair<Nodeid, Nodeid>(Nodeid.fromBinary(p1, 0), Nodeid.fromBinary(p2, 0));
    }
    return parents;
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

   * @param sink accepts file revision content
   * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
   * @throws CancelledException if execution of the operation was cancelled
   */
  public void putContentTo(ByteChannel sink) throws HgRuntimeException, CancelledException {
    HgDataFile fn = repo.getFileNode(path);
    int revisionIndex = fn.getRevisionIndex(revision);
    fn.contentWithFilters(revisionIndex, sink);
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

  public String toString() {
    return String.format("HgFileRevision(%s, %s)", getPath().toString(), revision.shortNotation());
  }

  private void checkCopy() throws HgRuntimeException {
    HgDataFile df = repo.getFileNode(path);
    int revIdx = df.getRevisionIndex(revision);
    if (df.isCopy(revIdx)) {
      isCopy = Boolean.TRUE;
      origin = df.getCopySource(revIdx).getPath();
      return;
    }
    isCopy = Boolean.FALSE;
  }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

  @Test
  public void testSingleParentBlame() throws Exception {
    HgRepository repo = new HgLookup().detectFromWorkingDir();
    final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
    final int checkChangeset = repo.getChangelog().getRevisionIndex(Nodeid.fromAscii("946b131962521f9199e1fedbdc2487d3aaef5e46")); // 539
    HgDataFile df = repo.getFileNode(fname);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    HgDiffCommand diffCmd = new HgDiffCommand(repo);
    diffCmd.file(df).changeset(checkChangeset);
    diffCmd.executeParentsAnnotate(new DiffOutInspector(new PrintStream(bos)));
    LineGrepOutputParser gp = new LineGrepOutputParser("^@@.+");
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

 
  @Test
  public void testFileLineAnnotate1() throws Exception {
    HgRepository repo = new HgLookup().detectFromWorkingDir();
    final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
    HgDataFile df = repo.getFileNode(fname);
    AnnotateRunner ar = new AnnotateRunner(df.getPath(), null);

    final HgDiffCommand diffCmd = new HgDiffCommand(repo);
    diffCmd.file(df).order(NewToOld);
    final HgChangelog clog = repo.getChangelog();
    final int[] toTest = new int[] {
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

  }
 
  @Test
  public void testFileLineAnnotate2() throws Exception {
    HgRepository repo = Configuration.get().find("test-annotate");
    HgDataFile df = repo.getFileNode("file1");
    AnnotateRunner ar = new AnnotateRunner(df.getPath(), repo.getWorkingDir());

    final HgDiffCommand diffCmd = new HgDiffCommand(repo).file(df).order(NewToOld);
    for (int cs : new int[] { 4, 6 /*, 8 see below*/, TIP}) {
      ar.run(cs, false);
      diffCmd.range(0, cs);
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

  }
 
  @Test
  public void testComplexHistoryAnnotate() throws Exception {
    HgRepository repo = Configuration.get().find("test-annotate");
    HgDataFile df = repo.getFileNode("file1");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DiffOutInspector dump = new DiffOutInspector(new PrintStream(bos));
    HgDiffCommand diffCmd = new HgDiffCommand(repo);
    diffCmd.file(df).range(0, TIP).order(OldToNew);
    diffCmd.executeAnnotate(dump);
    LinkedList<String> apiResult = new LinkedList<String>(Arrays.asList(splitLines(bos.toString())));
   
    /*
     * FIXME this is an ugly hack to deal with the way `hg diff -c <mergeRev>` describes the change
     * and our merge handling approach. For merged revision m, and lines changed both in p1 and p2
     * we report lines from p2 as pure additions, regardless of intersecting p1 changes (which
     * are reported as deletions, if no sufficient changed lines in m found)
     * So, here we try to combine deletion that follows a change (based on identical insertionPoint)
     * into a single change
     * To fix, need to find better approach to find out reference info (i.e. `hg diff -c` is flawed in this case,
     * as it uses first parent only).
     */
    Pattern fix = Pattern.compile("@@ -(\\d+),(\\d+) \\+(\\d+),(\\d+) @@");
    int v1, v2, v3, v4;
    v1 = v2 = v3 = v4 = -1;
    for (ListIterator<String> it = apiResult.listIterator(); it.hasNext();) {
      String n = it.next();
      Matcher m = fix.matcher(n);
      if (m.find()) {
        int d1 = Integer.parseInt(m.group(1));
        int d2 = Integer.parseInt(m.group(2));
        int d3 = Integer.parseInt(m.group(3));
        int d4 = Integer.parseInt(m.group(4));
        if (v1 == d1 && d4 == 0) {
          it.previous(); // shift to current element
          it.previous(); // to real previous
          it.remove();
          it.next();
          it.set(String.format("@@ -%d,%d +%d,%d @@", v1, v2+d2, v3, v4));
        }
        v1 = d1;
        v2 = d2;
        v3 = d3;
        v4 = d4;
      }
    }
   
    LineGrepOutputParser gp = new LineGrepOutputParser("^@@.+");
    ExecHelper eh = new ExecHelper(gp, repo.getWorkingDir());
    for (int cs : dump.getReportedTargetRevisions()) {
      gp.reset();
      eh.run("hg", "diff", "-c", String.valueOf(cs), "-U", "0", df.getPath().toString());
      for (String expected : splitLines(gp.result())) {
        if (!apiResult.remove(expected)) {
          errorCollector.fail(String.format("Expected diff output '%s' for changes in revision %d", expected, cs));
        }
      }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgDataFile

 
  @Test
  public void testPartialHistoryFollow() throws Exception {
    HgRepository repo = Configuration.get().find("test-annotate2");
    HgDataFile df = repo.getFileNode("file1b.txt");
    // rev3: file1 -> file1a,  rev7: file1a -> file1b, tip: rev10
    DiffOutInspector insp = new DiffOutInspector(new PrintStream(new OutputStream() {
      @Override
      public void write(int b) throws IOException {
        // NULL OutputStream
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.