/** * 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(); }
private String computeMD5(File packageFile) throws IOException { return MD5.asHex(MD5.getHash(packageFile)); }