private void Commit(IDictionary<HgNodeID, uint> revisions, IEnumerable<HgChunk> chunks, HgRevlog hgRevlog, ref int changes)
        {
            var hgRevlogWriter = new HgRevlogWriter(hgRevlog, fileSystem);
            changes += 
                hgRevlogWriter.WriteRevlogEntries(chunks, 
                    n => {
                        var linkRevision = revisions.ContainsKey(n) ? revisions[n] : (uint?)null;
                        if(!linkRevision.HasValue)
                            throw new Exception("missing changeset in bundle");

                        return linkRevision.Value;
                    });
        }
        private IDictionary<HgNodeID, uint> CommitChangelog(HgChangeset tip, IEnumerable<HgChunk> chunks, HgRevlog hgRevlog, out int changesets)
        {
            var revisions = new Dictionary<HgNodeID, uint>();
            var revision = tip == null ? 0 : 
                tip.Metadata.Revision + 1;
            
            changesets = 0;

            var hgRevlogWriter = new HgRevlogWriter(hgRevlog, atomicFileSystem);
            changesets = 
                hgRevlogWriter.WriteRevlogEntries(chunks, 
                    n => {
                        var linkRevision = revision++;
                        revisions[n] = linkRevision;

                        return linkRevision;
                    }, 
                    e => {
                        revisions[e.NodeID] = e.Revision;
                    });

            return revisions;
        }
        private HgNodeID Commit(HgNodeID firstParentNodeID, HgNodeID secondParentNodeID, byte[] content, HgRevlog hgRevlog)
        {
            var data = new byte[]{};

            if(firstParentNodeID != HgNodeID.Null)
            {
                var hgRevlogReader = new HgRevlogReader(hgRevlog, fileSystem);
                data = hgRevlogReader.ReadRevlogEntry(firstParentNodeID).Data;
            } // if
                        
            var linkRevision = Changelog == null ? 0 : Changelog.Revlog.Entries.Count;

            var hgNodeID = new HgRevlogWriter(hgRevlog, fileSystem).WriteRevlogEntryData((uint)linkRevision, firstParentNodeID, secondParentNodeID, content);
            return hgNodeID;
        }