/**
   * Create a revision as a child of another revision.
   *
   * @param parent Parent revision, or null if this is the root revision.
   */
  public Revision(GVCLib gvclib, Revision parent, Map<String, Set<File>> fileSet, String comment)
      throws GVCException {
    this.parent = parent;
    this.date = new Date();
    this.comment = comment;

    if (parent == null) {
      // This is the initial revision.
      this.filesAdded = fileSet;
    } else {
      // Diff the given file set with parent's file set to get added and removed.
      List<Map<String, Set<File>>> diffList = filesetGetDiff(parent.getFileset(gvclib), fileSet);
      this.filesAdded = diffList.get(0);
      this.filesRemoved = diffList.get(1);
    }

    if (this.filesAdded == null && this.filesRemoved == null) {
      throw new GVCException("Will not create a revision with no changes.");
    }

    this.serialize();

    // Generate hash.
    MD5 md5 = new MD5();
    try {
      md5.Update(this.serialized, null);
    } catch (UnsupportedEncodingException e) {
      throw new GVCException(e);
    }
    this.hash = md5.asHex();
  }
 /**
  * Get the complete fileset of this revision with all parent diffs applied.
  *
  * @return Complete fileset of this revision.
  */
 public Map<String, Set<File>> getFileset(GVCLib gvclib) {
   if (this.parent != null) {
     return filesetApplyDiff(
         gvclib, parent.getFileset(gvclib), this.filesAdded, this.filesRemoved);
   } else {
     return this.filesAdded;
   }
 }