Examples of HgRepository


Examples of org.tmatesoft.hg.repo.HgRepository

  public ErrorCollectorExt errorCollector = new ErrorCollectorExt();

 
  @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.HgRepository

    Assert.assertArrayEquals(expected, apiResult);
  }
 
  @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[] {
      clog.getRevisionIndex(Nodeid.fromAscii("946b131962521f9199e1fedbdc2487d3aaef5e46")), // 539
      clog.getRevisionIndex(Nodeid.fromAscii("1e95f48d9886abe79b9711ab371bc877ca5e773e")), // 541
      /*, TIP */};
    for (int cs : toTest) {
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgRepository

    }
  }
 
  @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.HgRepository

     */
  }
 
  @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)) {
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgRepository

  }

 
  @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

Examples of org.tmatesoft.hg.repo.HgRepository

  }

  @Test
  public void testAnnotateCmdFollowNoFollow() throws Exception {
    HgRepoFacade hgRepoFacade = new HgRepoFacade();
    HgRepository repo = Configuration.get().find("test-annotate2");
    hgRepoFacade.init(repo);
    HgAnnotateCommand cmd = hgRepoFacade.createAnnotateCommand();
    final Path fname = Path.create("file1b.txt");
    final int changeset = TIP;
    AnnotateInspector ai = new AnnotateInspector();

    cmd.changeset(changeset);
    // follow
    cmd.file(fname);
    cmd.execute(ai);
    AnnotateRunner ar = new AnnotateRunner(fname, repo.getWorkingDir());
    ar.run(changeset, true);
    doAnnotateLineCheck(changeset, ar, ai);
   
    // no follow
    cmd.file(fname, false);
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgRepository

    doAnnotateLineCheck(changeset, ar, ai);
  }
 
  @Test
  public void testDiffTwoRevisions() throws Exception {
    HgRepository repo = Configuration.get().find("test-annotate");
    HgDataFile df = repo.getFileNode("file1");
    LineGrepOutputParser gp = new LineGrepOutputParser("^@@.+");
    ExecHelper eh = new ExecHelper(gp, repo.getWorkingDir());
    int[] toTest = { 3, 4, 5 }; // p1 ancestry line, p2 ancestry line, not in ancestry line
    final HgDiffCommand diffCmd = new HgDiffCommand(repo).file(df);
    for (int cs : toTest) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      diffCmd.range(cs, 8).executeDiff(new DiffOutInspector(new PrintStream(bos)));
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgRepository

  /**
   * Make sure boundary values are ok (down to BlameHelper#prepare and FileHistory)
   */
  @Test
  public void testAnnotateFirstFileRev() throws Exception {
    HgRepository repo = Configuration.get().find("test-annotate");
    HgDataFile df = repo.getFileNode("file1");
    LineGrepOutputParser gp = new LineGrepOutputParser("^@@.+");
    ExecHelper eh = new ExecHelper(gp, repo.getWorkingDir());
    eh.run("hg", "diff", "-c", "0", "-U", "0", df.getPath().toString());
    //
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    HgDiffCommand diffCmd = new HgDiffCommand(repo).file(df);
    diffCmd.changeset(0).executeParentsAnnotate(new DiffOutInspector(new PrintStream(bos)));
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgRepository

    Assert.assertArrayEquals(expected, apiResult);
  }
 
  @Test
  public void testAnnotateMergeMapViaBase() throws Exception {
    HgRepository repo = Configuration.get().find("test-annotate3");
    HgDataFile df1 = repo.getFileNode("file1");
    HgDataFile df4 = repo.getFileNode("file4");
    HgDataFile df5 = repo.getFileNode("file5");
    assertTrue("[sanity]", df1.exists() && df4.exists());
    // hg annotate handles merge in its own way, here we check
    // how map(diff(p1->base->p2)) merge strategy works
    final String file1AnnotateResult = "3:1:1\n3:2:2x\n3:3:3y\n2:4:z\n0:1:1\n1:2:2x\n4:3:3y\n";
    final String file4AnnotateResult = "3:1:1\n1:2:2x\n4:3:3y\n2:4:z\n0:1:1\n3:6:2x\n3:7:3y\n";
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgRepository

    }
  }
 
  private void ddd() throws Throwable {
//    HgRepository repo = new HgLookup().detect("/home/artem/hg/blame-merge/");
    HgRepository repo = new HgLookup().detect("/home/artem/hg/junit-test-repos/test-annotate3/");
    final DiffOutInspector insp = new DiffOutInspector(System.out);
    insp.needRevisions(true);
    new HgDiffCommand(repo).file(Path.create("file1")).executeParentsAnnotate(insp);
  }
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.