Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.Nodeid


           * no new information can be obtained. E.g. when it's 2, it might be case of [0..4] query with
           * [1,2] result, and we need one more query to get element 3.  
           */
          for (int i =1, j = 0; j < de.entries.size(); i = i<<1, j++) {
            int idx = de.headIndex + i;
            Nodeid x = de.entries.get(j);
            if (!queried.contains(x) && !scheduled.contains(x) && (rootIndex == -1 || rootIndex - de.headIndex > 1)) {
              /*queries for elements right before head is senseless, but unless we know head's index, do it anyway*/
              toQuery.add(new DataEntry(x, idx, null));
              scheduled.add(x);
            }
          }
        }
      } while (!datas.isEmpty());
      if (!toQuery.isEmpty()) {
        totalQueries++;
      }
      // for each query, create an between request range, keep record Range->DataEntry to know range's start index 
      LinkedList<HgRemoteRepository.Range> betweenBatch = new LinkedList<HgRemoteRepository.Range>();
      HashMap<HgRemoteRepository.Range, DataEntry> rangeToEntry = new HashMap<HgRemoteRepository.Range, DataEntry>();
      for (DataEntry de : toQuery) {
        queried.add(de.queryHead);
        HgRemoteRepository.Range r = new HgRemoteRepository.Range(branchRoot, de.queryHead);
        betweenBatch.add(r);
        rangeToEntry.put(r, de);
      }
      if (!betweenBatch.isEmpty()) {
        Map<Range, List<Nodeid>> between = remoteRepo.between(betweenBatch);
        for (Entry<Range, List<Nodeid>> e : between.entrySet()) {
          DataEntry de = rangeToEntry.get(e.getKey());
          assert de != null;
          de.entries = e.getValue();
          if (rootIndex == -1 && de.entries.size() == 1) {
            // returned sequence of length 1 means we used element from [head-2] as root
            int numberOfElementsExcludingRootAndHead = de.headIndex + 1;
            rootIndex = numberOfElementsExcludingRootAndHead + 1;
            if (debug) {
              System.out.printf("On query %d found out exact number of missing elements: %d\n", totalQueries, numberOfElementsExcludingRootAndHead);
            }
          }
          datas.add(de); // queue up to record result and construct further requests
        }
        betweenBatch.clear();
        rangeToEntry.clear();
      }
      toQuery.clear();
    }
    if (rootIndex == -1) {
      throw new HgInvalidStateException("Shall not happen, provided between output is correct");
    }
    result[rootIndex] = branchRoot;
    boolean resultOk = true;
    LinkedList<Nodeid> fromRootToHead = new LinkedList<Nodeid>();
    IntVector missing = new IntVector();
    for (int i = 0; i <= rootIndex; i++) {
      Nodeid n = result[i];
      if (n == null) {
        missing.add(i);
        resultOk = false;
      }
      fromRootToHead.addFirst(n); // reverse order
View Full Code Here


    List<Nodeid> parentBranch2 = visitBranches(bc.p2);
    // merge
    LinkedList<Nodeid> merged = new LinkedList<Nodeid>();
    ListIterator<Nodeid> i1 = parentBranch1.listIterator(), i2 = parentBranch2.listIterator();
    while (i1.hasNext() && i2.hasNext()) {
      Nodeid n1 = i1.next();
      Nodeid n2 = i2.next();
      if (n1.equals(n2)) {
        merged.addLast(n1);
      } else {
        // first different => add both, and continue adding both tails sequentially
        merged.add(n2);
View Full Code Here

      // hg pull total/2
      // hg in, hg4j in, compare
      List<Nodeid> incoming = runAndCompareIncoming(localRepo, hgRemote);
      Assert.assertTrue("Need remote repository of reasonable size to test incoming command for partially filled case", incoming.size() >= 5);
      //
      Nodeid median = incoming.get(incoming.size() / 2);
      System.out.println("About to pull up to revision " + median.shortNotation());
      new ExecHelper(new OutputParser.Stub(), dest).run("hg", "pull", "-r", median.toString(), hgRemote.getLocation());
      //
      // shall re-read repository to pull up new changes
      localRepo = lookup.detect(dest);
      runAndCompareIncoming(localRepo, hgRemote);
    }
View Full Code Here

  static void report(HgLogCommand.CollectHandler collector, LogOutputParser outParser, List<Nodeid> liteResult, ErrorCollectorExt errorCollector) {
    TestHistory.report("hg vs execFull", collector.getChanges(), outParser.getResult(), false, errorCollector);
    //
    ArrayList<Nodeid> expected = new ArrayList<Nodeid>(outParser.getResult().size());
    for (LogOutputParser.Record r : outParser.getResult()) {
      Nodeid nid = Nodeid.fromAscii(r.changesetNodeid);
      expected.add(nid);
    }
    checkNodeids("hg vs execLite:", liteResult, expected, errorCollector);
    //
    expected = new ArrayList<Nodeid>(outParser.getResult().size());
View Full Code Here

    return firstParent[i];
  }

  // never null, Nodeid.NULL if none known
  public Nodeid safeFirstParent(Nodeid nid) {
    Nodeid rv = firstParent(nid);
    return rv == null ? Nodeid.NULL : rv;
  }
View Full Code Here

    int i = seqWrapper.getReverseIndex(x);
    return secondParent[i];
  }

  public Nodeid safeSecondParent(Nodeid nid) {
    Nodeid rv = secondParent(nid);
    return rv == null ? Nodeid.NULL : rv;
  }
View Full Code Here

  public boolean appendParentsOf(Nodeid nid, Collection<Nodeid> c) {
    int x = seqWrapper.binarySearchSorted(nid);
    assertSortedIndex(x);
    int i = seqWrapper.getReverseIndex(x);
    Nodeid p1 = firstParent[i];
    boolean modified = false;
    if (p1 != null) {
      modified = c.add(p1);
    }
    Nodeid p2 = secondParent[i];
    if (p2 != null) {
      modified = c.add(p2) || modified;
    }
    return modified;
  }
View Full Code Here

   *             if failed to access revlog index/data entry. <em>Runtime exception</em>
   * @throws HgRuntimeException
   *             subclass thereof to indicate other issues with the library. <em>Runtime exception</em>
   */
  public HgPhase getPhase(HgChangeset cset) throws HgRuntimeException {
    final Nodeid csetRev = cset.getNodeid();
    final int csetRevIndex = cset.getRevisionIndex();
    return getPhase(csetRevIndex, csetRev);
  }
View Full Code Here

        if (lc.length != 2) {
          repo.getSessionContext().getLog().dump(getClass(), Warn, "Bad line in phaseroots:%s", line);
          continue;
        }
        int phaseIndex = Integer.parseInt(lc[0]);
        Nodeid rootRev = Nodeid.fromAscii(lc[1]);
        if (!getRepo().getChangelog().isKnown(rootRev)) {
          repo.getSessionContext().getLog().dump(getClass(), Warn, "Phase(%d) root node %s doesn't exist in the repository, ignored.", phaseIndex, rootRev);
          continue;
        }
        HgPhase phase = HgPhase.parse(phaseIndex);
View Full Code Here

      // in addition to existing draft csets, add one more draft, branching at some other public revision
      new HgCheckoutCommand(srcRepo).changeset(publicCsetToBranchAt).clean(true).execute();
      RepoUtils.modifyFileAppend(f1, "// aaa");
      final HgCommitCommand commitCmd = new HgCommitCommand(srcRepo).message("Commit aaa");
      assertTrue(commitCmd.execute().isOk());
      Nodeid newCommit = commitCmd.getCommittedRevision();
      //
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog srcClog = srcRepo.getChangelog();
      final HgChangelog dstClog = dstRepo.getChangelog();
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.core.Nodeid

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.