コード例 #1
0
        public HgRevlogBasedStorage(HgRevlog revlog, HgRevlogReader revlogReader)
        {
            log = LogManager.GetLogger(GetType().FullName);

            Revlog = revlog;
            this.revlogReader = revlogReader;
        }
コード例 #2
0
        public HgRevlogWriter(HgRevlog revlog, HgFileSystem fileSystem)
        {
            this.revlog = revlog;
            this.fileSystem = fileSystem;

            revlogReader = new HgRevlogReader(revlog, fileSystem);
        }
コード例 #3
0
 public HgLargefilesEnabledRevlog(HgRevlog standinRevlog, HgRevlogReader standinRevlogReader, string storeBasePath) :
     base(standinRevlog.IndexPath, standinRevlog.DataPath, standinRevlog.Version, standinRevlog.InlineData, standinRevlog.Entries)
 {
     this.standinRevlog = standinRevlog;
     this.standinRevlogReader = standinRevlogReader;
     this.storeBasePath = storeBasePath;
 }
コード例 #4
0
        public override IHgRevlogReader CreateRevlogReader(HgRevlog hgRevlog)
        {
            var hgRevlogReader = base.CreateRevlogReader(hgRevlog);
            if(!(hgRevlog is HgLargefilesEnabledRevlog)) return hgRevlogReader;

            //
            // We need to do a dirty little trick here. Since HgLargefilesEnabledRevlog essentially
            // "lies" about UncompressedLength, we need to "unwrap" it back
            var standinRevlog = ((HgLargefilesEnabledRevlog)hgRevlog).StandinRevlog;

            return new HgLargefilesEnabledRevlogReader(StoreBasePath, standinRevlog, base.CreateRevlogReader(standinRevlog));

        }
コード例 #5
0
ファイル: HgStore.cs プロジェクト: cornelius90/InnovatorAdmin
 public virtual IHgRevlogReader CreateRevlogReader(HgRevlog hgRevlog)
 {
     return new HgRevlogReader(hgRevlog, fileSystem);
 }
コード例 #6
0
ファイル: HgStore.cs プロジェクト: cornelius90/InnovatorAdmin
        protected virtual HgRevlog CreateRevlog(string revlogIndexPath, string revlogDataPath)
        {
            log.Trace("creating revlog at {0} and {1}", revlogIndexPath, revlogDataPath);

            var i = Path.Combine(storeBasePath, revlogIndexPath);
            var d = Path.Combine(storeBasePath, revlogDataPath);

            var revlog = new HgRevlog(i, d, HgRevlogReader.NG, false, new HgRevlogEntry[] { });
            return revlog;
        }
コード例 #7
0
 public HgManifest(HgRevlog hgRevlog, HgRevlogReader revlogReader, HgEncoder hgEncoder) :
     base(hgRevlog, revlogReader)
 {
     this.hgEncoder = hgEncoder;
     hgManifestReader = new HgManifestReader(this.hgEncoder);
 }
コード例 #8
0
        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;
        }
コード例 #9
0
        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;
                    });
        }
コード例 #10
0
        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;
        }
コード例 #11
0
 public HgLargefilesEnabledRevlogReader(string storeBasePath, HgRevlog standinRevlog, IHgRevlogReader standinRevlogReader)
 {
     this.storeBasePath = storeBasePath;
     this.standinRevlog = standinRevlog;
     this.standinRevlogReader = standinRevlogReader;
 }
コード例 #12
0
 public HgChangelog(HgRevlog revlog, HgRevlogReader revlogReader, HgEncoder hgEncoder) :
     base(revlog, revlogReader)
 {
     this.hgEncoder = hgEncoder;
     hgChangelogReader = new HgChangelogReader(this.hgEncoder);
 }
コード例 #13
0
 /// <summary>
 /// Verifies <paramref name="hgRevlog"/> for inconsistencies with the main format.
 /// </summary>
 /// <param name="hgRevlog"></param>
 private void VerifyRevlog(HgRevlog hgRevlog)
 {
     //throw new NotImplementedException();
 }
コード例 #14
0
        private IEnumerable<HgChunk> BuildBundleGroup(HgRepository hgRepository, HgRevlog hgRevlog, HgRevset hgRevset, Action<HgRevlogEntryData> callback = null)
        {
            var hgRevlogReader = new HgRevlogReader(hgRevlog, fileSystem);
            
            //
            // See http://stackoverflow.com/a/10359273/60188. Pure magic
            var revisionChunks =
                hgRevset.
                    Select(hre => hre.Revision).
                    OrderBy(r => r).
                    Select((r, i) => new { r, i }).
                    GroupBy(x => x.r - x.i). 
                    Select(x => x.Select(xx => xx.r)).
                    Select(c => c.ToArray()).
                    ToArray();

            if(revisionChunks.Length == 0) yield break;

            byte[] prev = null;
            uint prevRev = uint.MaxValue;
            var prediff = false;
            var hgRevlogEntry = hgRevlog[revisionChunks[0][0]];
            if(hgRevlogEntry.FirstParentRevisionNodeID != HgNodeID.Null)
            {
                prev = hgRevlogReader.ReadRevlogEntry(hgRevlogEntry.FirstParentRevision).Data;
                prediff = true;
            }
            
            foreach(var revisionChunk in revisionChunks)
            {
                foreach(var revision in revisionChunk)
                {
                    hgRevlogEntry = hgRevlog[revision];
                    var hgChangeset = hgRepository.Changelog.Revlog[hgRevlogEntry.LinkRevision];
                
                    byte[] data = null;

                    if(prev == null || hgRevlogEntry.BaseRevision == hgRevlogEntry.Revision || prediff || (prevRev != UInt32.MaxValue && prevRev + 1 != revision))
                    {
                        var hgRevlogEntryData = hgRevlogReader.ReadRevlogEntry(revision);

                        if(prev == null)
                        {   
                            //
                            // Trivial case
                            var buffer = new byte[hgRevlogEntryData.Data.Length + 12];
                            using(var stream = new MemoryStream(buffer))
                            using(var binaryWriter = new BigEndianBinaryWriter(stream))
                            {
                                binaryWriter.Write((uint)0);
                                binaryWriter.Write((uint)0);
                                binaryWriter.Write((uint)hgRevlogEntryData.Data.Length);
                                binaryWriter.Write(hgRevlogEntryData.Data);
                            } // using

                            data = buffer;
                        } // if
                        else
                        {
                            data = BDiff.Diff(prev, hgRevlogEntryData.Data);
                            if(prediff)
                                prediff = false;
                        } // else

                        prev = hgRevlogEntryData.Data;
                    } // if
                    else
                    {
                        data = hgRevlogReader.ReadRevlogEntryDataRaw(revision);
                        prev = MPatch.Patch(prev, new List<byte[]> { data });
                    } // else

                    if(callback != null) callback(new HgRevlogEntryData(hgRevlogEntry, prev));

                    if(performIntegrityChecks)
                    {
                        var expectedNodeID = GetRevlogEntryDataNodeID(hgRevlogEntry.FirstParentRevisionNodeID, hgRevlogEntry.SecondParentRevisionNodeID, prev);
                        if(expectedNodeID != hgRevlogEntry.NodeID)
                        {
                            // TODO: Exception class
                            throw new ApplicationException("integrity violation for " + hgRevlogEntry.NodeID.Short);
                        } // if
                    } // if

                    var hgChunk = new HgChunk(hgRevlogEntry.NodeID, hgRevlogEntry.FirstParentRevisionNodeID, hgRevlogEntry.SecondParentRevisionNodeID,
                        hgChangeset.NodeID, data);

                    yield return hgChunk;

                    prevRev = revision;
                } // foreach
            } // foreach
        }