Package org.tmatesoft.hg.repo

Examples of org.tmatesoft.hg.repo.HgInvalidStateException


        switch (kind) {
        case Normal: normal.put(entry.name(), entry); break;
        case Added : added.put(entry.name(), entry); break;
        case Removed : removed.put(entry.name(), entry); break;
        case Merged : merged.put(entry.name(), entry); break;
        default: throw new HgInvalidStateException(String.format("Unexpected entry in the dirstate: %s", kind));
        }
        return true;
      }
    });
    parents(dirstate.parents().first(), dirstate.parents().second());
View Full Code Here


    progressSupport.start(10);
    common = Collections.unmodifiableList(findCommonWithRemote());
    // sanity check
    for (Nodeid n : common) {
      if (!localRepo.knownNode(n)) {
        throw new HgInvalidStateException("Unknown node reported as common:" + n);
      }
    }
    progressSupport.done();
    return this;
  }
View Full Code Here

    return this;
  }
 
  public List<Nodeid> getCommon() {
    if (common == null) {
      throw new HgInvalidStateException("Call #compare(Object) first");
    }
    return common;
  }
View Full Code Here

            break;
          }
        }
      } while(--watchdog > 0);
      if (watchdog == 0) {
        throw new HgInvalidStateException(String.format("Can't narrow down branch [%s, %s]", rb.head.shortNotation(), rb.root.shortNotation()));
      }
    }
    if (debug) {
      System.out.println("calculateMissingBranches:");
      for (BranchChain bc : branches2load) {
View Full Code Here

        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
    }
    if (debug) {
      System.out.println("Total queries:" + totalQueries);
    }
    if (!resultOk) {
      assert missing.size() > 0;
      // TODO post-1.0 perhaps, there's better alternative than HgInvalidStateException, e.g. HgDataFormatException?
      throw new HgInvalidStateException(String.format("Missing elements with indexes: %s", Arrays.toString(missing.toArray())));
    }
    return fromRootToHead;
  }
View Full Code Here

    HgStatusCollector.Record r = new HgStatusCollector.Record();
    try {
      shared.statusHelper.change(revNumber, r);
    } catch (CancelledException ex) {
      // Record can't cancel
      throw new HgInvalidStateException("Internal error");
    }
    final HgRepository repo = getRepo();
    for (Path s : r.getModified()) {
      Nodeid nid = r.nodeidAfterChange(s);
      if (nid == null) {
        throw new HgInvalidStateException(String.format("For the file %s recorded as modified in changeset %d couldn't find revision after change", s, revNumber));
      }
      modified.add(new HgFileRevision(repo, nid, null, s, null));
    }
    final Map<Path, Path> copied = r.getCopied();
    for (Path s : r.getAdded()) {
      Nodeid nid = r.nodeidAfterChange(s);
      if (nid == null) {
        throw new HgInvalidStateException(String.format("For the file %s recorded as added in changeset %d couldn't find revision after change", s, revNumber));
      }
      added.add(new HgFileRevision(repo, nid, null, s, copied.get(s)));
    }
    for (Path s : r.getRemoved()) {
      // with Path from getRemoved, may just copy
View Full Code Here

    } catch (CharacterCodingException ex) {
      // TODO post-1.2 respect ui.fallbackencoding actual setting
      try {
        return new String(data, start, length, "ISO-8859-1"); // XXX java5
      } catch (UnsupportedEncodingException e) {
        throw new HgInvalidStateException(ex.getMessage());
      }
    }
  }
View Full Code Here

    } catch (CharacterCodingException ex) {
      byte[] rv;
      try {
        rv = s.toString().getBytes(getUTF8().name()); // XXX Java 1.5
      } catch (UnsupportedEncodingException e) {
        throw new HgInvalidStateException("Unexpected error trying to get UTF-8 encoding");
      }
      return ByteBuffer.wrap(rv);
    }
  }
View Full Code Here

            // (a) changegroup.py#builddeltaheader(): # do nothing with basenode, it is implicitly the previous one in HG10
            // (b) revlog.py#group(): prev, curr = revs[r], revs[r + 1]
            //               for c in bundler.revchunk(self, curr, prev):
            // so there's no reason to have code here to extract contents of deltaBase revision
            String m = String.format("Revision %s import failed: delta base %s is not the last node we've handled (and know content for) %s", ge.node(), deltaBase, prevRevision);
            throw new HgInvalidStateException(m);
          }
        }
        //
        Patch patch = HgInternals.patchFromData(ge);
        byte[] content = patch.apply(prevRevContent, -1);
        Nodeid p1 = ge.firstParent();
        Nodeid p2 = ge.secondParent();
        byte[] calculated = dh.sha1(p1, p2, content).asBinary();
        final Nodeid node = ge.node();
        if (!node.equalsTo(calculated)) {
          String m = String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename);
          throw new HgRevisionIntegrityException(m, null, new File(hgDir, filename));
        }
        revlogHeader.nodeid(node);
        //
        if (collectChangelogIndexes) {
          changelogIndexes.put(node, revisionSequence.size());
          revlogHeader.linkRevision(revisionSequence.size());
        } else {
          Integer csRev = changelogIndexes.get(ge.cset());
          if (csRev == null) {
            throw new HgInvalidStateException(String.format("Changelog doesn't contain revision %s of %s", ge.cset().shortNotation(), filename));
          }
          revlogHeader.linkRevision(csRev.intValue());
        }
        //
        revlogHeader.parents(knownRevision(p1), knownRevision(p2));
        //
        int patchSerializedLength = patch.serializedLength();
        // no reason to keep patch if it's close (here, >75%) in size to the complete contents,
        // save patching effort in this case
        writeComplete = writeComplete || preferCompleteOverPatch(patchSerializedLength, content.length);

        if (writeComplete) {
          revlogHeader.baseRevision(revisionSequence.size());
        }
        assert revlogHeader.baseRevision() >= 0;

        DataSerializer.DataSource dataSource = writeComplete ? new ByteArrayDataSource(content) : patch.new PatchDataSource();
        revlogDataZip.reset(dataSource);
        final int compressedLen;
        final boolean useUncompressedData = preferCompressedOverComplete(revlogDataZip.getCompressedLength(), dataSource.serializeLength());
        if (useUncompressedData) {
          // compression wasn't too effective,
          compressedLen = dataSource.serializeLength() + 1 /*1 byte for 'u' - uncompressed prefix byte*/;
        } else {
          compressedLen= revlogDataZip.getCompressedLength();
        }
   
        revlogHeader.length(content.length, compressedLen);
       
        // XXX may be wise not to create DataSerializer for each revision, but for a file
        DataSerializer sds = new DataSerializer() {
          @Override
            public void write(byte[] data, int offset, int length) throws HgIOException {
              try {
                indexFile.write(data, offset, length);
              } catch (IOException ex) {
                throw new HgIOException("Write failure", ex, currentFile);
              }
            }
        };
        revlogHeader.serialize(sds);

        if (useUncompressedData) {
          sds.writeByte((byte) 'u');
          dataSource.serialize(sds);
        } else {
          int actualCompressedLenWritten = revlogDataZip.writeCompressedData(sds);
          if (actualCompressedLenWritten != compressedLen) {
            throw new HgInvalidStateException(String.format("Expected %d bytes of compressed data, but actually wrote %d in %s", compressedLen, actualCompressedLenWritten, filename));
          }
        }
        sds.done();
        //
        revisionSequence.add(node);
View Full Code Here

    if (newCommitPhase == HgPhase.Draft) {
      updateRoots(newRoots.asList(), secretPhaseRoots);
    } else if (newCommitPhase == HgPhase.Secret) {
      updateRoots(draftPhaseRoots, newRoots.asList());
    } else {
      throw new HgInvalidStateException(String.format("Unexpected phase %s for new commits", newCommitPhase));
    }
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.repo.HgInvalidStateException

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.