示例#1
0
  public RepositoryTagMap(
      AbstractRepository repository,
      RepositoryTagMap parent,
      Map<String, RepositoryTagEntry> tagMap)
      throws IOException {
    _tagMap = Collections.unmodifiableMap(tagMap);

    long now = Alarm.getCurrentTime();

    if (parent.getSequence() < now) _sequence = now;
    else _sequence = parent.getSequence() + 1;

    TempStream os = new TempStream();
    WriteStream out = new WriteStream(os);

    writeTagMap(out);
    out.close();

    String tagHash;

    InputStream is = os.getInputStream();

    try {
      tagHash = repository.addBlob(is);
    } finally {
      is.close();
    }

    _tree = new GitTree();

    _tree.addBlob("tags", 0775, tagHash);

    for (String key : tagMap.keySet()) {
      RepositoryTagEntry entry = tagMap.get(key);

      String sha1 = entry.getTagEntryHash();
      String root = entry.getRoot();

      _tree.addBlob(sha1, 0644, sha1);

      GitType type = repository.getType(root);

      if (type == GitType.BLOB) _tree.addBlob(root, 0644, root);
      else if (type == GitType.TREE) _tree.addDir(root, root);
      else throw new IllegalStateException(L.l("'{0}' has an unknown type {1}", root, type));
    }

    String treeHash = repository.addTree(_tree);

    _commit = new GitCommit();
    _commit.setTree(treeHash);
    _commit.put("sequence", String.valueOf(_sequence));

    _commitHash = repository.addCommit(_commit);
  }
示例#2
0
  /**
   * @param oldTagMap
   * @return
   */
  public int compareTo(RepositoryTagMap oldTagMap) {
    if (getSequence() < oldTagMap.getSequence()) return -1;
    else if (oldTagMap.getSequence() < getSequence()) return 1;

    return getCommitHash().compareTo(oldTagMap.getCommitHash());
  }