propsRep.setExpandedSize(size);
    public static FSID writeFinalRevision(FSID newId, final RandomAccessFile protoFile, long revision, FSID id, String startNodeId, String startCopyId, File reposRootDir) throws SVNException, IOException {        newId = null;        /* Check to see if this is a transaction node. */        if(!id.isTxn()){            return newId;        }        FSRevisionNode revNode = FSReader.getRevNodeFromID(reposRootDir, id);        if(revNode.getType() == SVNNodeKind.DIR){            /* This is a directory.  Write out all the children first. */            Map namesToEntries = FSReader.getDirEntries(revNode, reposRootDir);            for(Iterator entries = namesToEntries.values().iterator(); entries.hasNext();){                FSEntry dirEntry = (FSEntry)entries.next();                newId = writeFinalRevision(newId, protoFile, revision, dirEntry.getId(), startNodeId, startCopyId, reposRootDir);                if(newId != null && newId.getRevision() == revision){                    dirEntry.setId(new FSID(newId));                }            }            if(revNode.getTextRepresentation() != null && revNode.getTextRepresentation().isTxn()){                /* Write out the contents of this directory as a text rep. */                Map unparsedEntries = FSRepositoryUtil.unparseDirEntries(namesToEntries);                FSRepresentation textRep = revNode.getTextRepresentation();                 textRep.setTxnId(FSID.ID_INAPPLICABLE);                textRep.setRevision(revision);                try{                    textRep.setOffset(protoFile.getFilePointer());                    final MessageDigest checksum = MessageDigest.getInstance("MD5");                    long size = HashRepresentationWriter.writeHashRepresentation(unparsedEntries, protoFile, checksum);                    String hexDigest = SVNFileUtil.toHexDigest(checksum);                    textRep.setSize(size);                    textRep.setHexDigest(hexDigest);                    textRep.setExpandedSize(textRep.getSize());                }catch(NoSuchAlgorithmException nsae){                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "MD5 implementation not found: {0}", nsae.getLocalizedMessage());                    SVNErrorManager.error(err, nsae);                }            }        }else{            /* This is a file.  We should make sure the data rep, if it             * exists in a "this" state, gets rewritten to our new revision             * num.              */            if(revNode.getTextRepresentation() != null && revNode.getTextRepresentation().isTxn()){               FSRepresentation textRep = revNode.getTextRepresentation();               textRep.setTxnId(FSID.ID_INAPPLICABLE);               textRep.setRevision(revision);            }        }        /* Fix up the property reps. */        if(revNode.getPropsRepresentation() != null && revNode.getPropsRepresentation().isTxn()){            Map props = FSReader.getProperties(revNode, reposRootDir);            FSRepresentation propsRep = revNode.getPropsRepresentation();            try{                propsRep.setOffset(protoFile.getFilePointer());                final MessageDigest checksum = MessageDigest.getInstance("MD5");                long size = HashRepresentationWriter.writeHashRepresentation(props, protoFile, checksum);                String hexDigest = SVNFileUtil.toHexDigest(checksum);                propsRep.setSize(size);                propsRep.setHexDigest(hexDigest);                propsRep.setTxnId(FSID.ID_INAPPLICABLE);                propsRep.setRevision(revision);            }catch(NoSuchAlgorithmException nsae){                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "MD5 implementation not found: {0}", nsae.getLocalizedMessage());                SVNErrorManager.error(err, nsae);            }        }        /* Convert our temporary ID into a permanent revision one. */        long myOffset = protoFile.getFilePointer();        String myNodeId = null;        String nodeId = revNode.getId().getNodeID();        if(nodeId.startsWith("_")){            myNodeId = FSKeyGenerator.addKeys(startNodeId, nodeId.substring(1));        }else{            myNodeId = nodeId;        }        String myCopyId = null;        String copyId = revNode.getId().getCopyID();        if(copyId.startsWith("_")){            myCopyId = FSKeyGenerator.addKeys(startCopyId, copyId.substring(1));        }else{            myCopyId = copyId;        }        if(revNode.getCopyRootRevision() == FSConstants.SVN_INVALID_REVNUM){            revNode.setCopyRootRevision(revision);        }        newId = FSID.createRevId(myNodeId, myCopyId, revision, myOffset);        revNode.setId(newId);        /* Write out our new node-revision. */        OutputStream protoFileAdapter = new OutputStream(){            public void write(int b) throws IOException{                protoFile.write(b);            }        };        writeTxnNodeRevision(protoFileAdapter, revNode);        putTxnRevisionNode(id, revNode, reposRootDir);        /* Return our ID that references the revision file. */        return newId;    }