public HgRevlogBasedStorage(HgRevlog revlog, HgRevlogReader revlogReader) { log = LogManager.GetLogger(GetType().FullName); Revlog = revlog; this.revlogReader = revlogReader; }
public HgRevlogWriter(HgRevlog revlog, HgFileSystem fileSystem) { this.revlog = revlog; this.fileSystem = fileSystem; revlogReader = new HgRevlogReader(revlog, fileSystem); }
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; }
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)); }
public virtual IHgRevlogReader CreateRevlogReader(HgRevlog hgRevlog) { return new HgRevlogReader(hgRevlog, fileSystem); }
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; }
public HgManifest(HgRevlog hgRevlog, HgRevlogReader revlogReader, HgEncoder hgEncoder) : base(hgRevlog, revlogReader) { this.hgEncoder = hgEncoder; hgManifestReader = new HgManifestReader(this.hgEncoder); }
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 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 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; }
public HgLargefilesEnabledRevlogReader(string storeBasePath, HgRevlog standinRevlog, IHgRevlogReader standinRevlogReader) { this.storeBasePath = storeBasePath; this.standinRevlog = standinRevlog; this.standinRevlogReader = standinRevlogReader; }
public HgChangelog(HgRevlog revlog, HgRevlogReader revlogReader, HgEncoder hgEncoder) : base(revlog, revlogReader) { this.hgEncoder = hgEncoder; hgChangelogReader = new HgChangelogReader(this.hgEncoder); }
/// <summary> /// Verifies <paramref name="hgRevlog"/> for inconsistencies with the main format. /// </summary> /// <param name="hgRevlog"></param> private void VerifyRevlog(HgRevlog hgRevlog) { //throw new NotImplementedException(); }
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 }