// TODO: testWritePackDeltasCycle() // TODO: testWritePackDeltasDepth() private void WriteVerifyPack1() { var interestings = new LinkedList <ObjectId>(); interestings.AddLast(ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7")); CreateVerifyOpenPack(interestings, EMPTY_LIST_OBJECT, false, false); var expectedOrder = new[] { ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7"), ObjectId.FromString("c59759f143fb1fe21c197981df75a7ee00290799"), ObjectId.FromString("540a36d136cf413e4b064c2b0e0a4db60f77feab"), ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035"), ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327"), ObjectId.FromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904"), ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"), ObjectId.FromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") }; Assert.AreEqual(expectedOrder.Length, _writer.getObjectsNumber()); VerifyObjectsOrder(expectedOrder); Assert.AreEqual("34be9032ac282b11fa9babdc2b2a93ca996c9c2f", _writer.computeName().Name); }
private FileInfo[] Pack(Core.Repository src, params RevObject[] list) { var pw = new PackWriter(src, NullProgressMonitor.Instance); foreach (RevObject o in list) { pw.addObject(o); } ObjectId name = pw.computeName(); FileInfo packFile = FullPackFileName(name); FileInfo idxFile = FullIndexFileName(name); var files = new[] { packFile, idxFile }; Write(files, pw); return(files); }
private void Sendpack(IEnumerable <RemoteRefUpdate> updates, ProgressMonitor monitor) { string pathPack = null; string pathIdx = null; try { var pw = new PackWriter(_local, monitor); var need = new List <ObjectId>(); var have = new List <ObjectId>(); foreach (RemoteRefUpdate r in updates) { need.Add(r.NewObjectId); } foreach (Ref r in Refs) { have.Add(r.ObjectId); if (r.PeeledObjectId != null) { have.Add(r.PeeledObjectId); } } pw.preparePack(need, have); // We don't have to continue further if the pack will // be an empty pack, as the remote has all objects it // needs to complete this change. // if (pw.getObjectsNumber() == 0) { return; } _packNames = new Dictionary <string, string>(); foreach (string n in _dest.getPackNames()) { _packNames.put(n, n); } string b = "pack-" + pw.computeName().Name; string packName = b + IndexPack.PackSuffix; pathPack = "pack/" + packName; pathIdx = "pack/" + b + IndexPack.IndexSuffix; if (_packNames.remove(packName) != null) { // The remote already contains this pack. We should // remove the index before overwriting to prevent bad // offsets from appearing to clients. // _dest.writeInfoPacks(_packNames.Keys); _dest.deleteFile(pathIdx); } // Write the pack file, then the index, as readers look the // other direction (index, then pack file). // string wt = "Put " + b.Slice(0, 12); using (Stream os = _dest.writeFile(pathPack, monitor, wt + "." + IndexPack.PackSuffix)) { pw.writePack(os); } using (Stream os = _dest.writeFile(pathIdx, monitor, wt + "." + IndexPack.IndexSuffix)) { pw.writeIndex(os); } // Record the pack at the start of the pack info list. This // way clients are likely to consult the newest pack first, // and discover the most recent objects there. // var infoPacks = new List <string> { packName }; infoPacks.AddRange(_packNames.Keys); _dest.writeInfoPacks(infoPacks); } catch (IOException err) { SafeDelete(pathIdx); SafeDelete(pathPack); throw new TransportException(_uri, "cannot store objects", err); } }
private void Sendpack(IEnumerable<RemoteRefUpdate> updates, ProgressMonitor monitor) { string pathPack = null; string pathIdx = null; try { var pw = new PackWriter(_local, monitor); var need = new List<ObjectId>(); var have = new List<ObjectId>(); foreach (RemoteRefUpdate r in updates) { need.Add(r.NewObjectId); } foreach (Ref r in Refs) { have.Add(r.ObjectId); if (r.PeeledObjectId != null) { have.Add(r.PeeledObjectId); } } pw.preparePack(need, have); // We don't have to continue further if the pack will // be an empty pack, as the remote has all objects it // needs to complete this change. // if (pw.getObjectsNumber() == 0) return; _packNames = new Dictionary<string, string>(); foreach (string n in _dest.getPackNames()) { _packNames.put(n, n); } string b = "pack-" + pw.computeName().Name; string packName = b + IndexPack.PackSuffix; pathPack = "pack/" + packName; pathIdx = "pack/" + b + IndexPack.IndexSuffix; if (_packNames.remove(packName) != null) { // The remote already contains this pack. We should // remove the index before overwriting to prevent bad // offsets from appearing to clients. // _dest.writeInfoPacks(_packNames.Keys); _dest.deleteFile(pathIdx); } // Write the pack file, then the index, as readers look the // other direction (index, then pack file). // string wt = "Put " + b.Slice(0, 12); using (Stream os = _dest.writeFile(pathPack, monitor, wt + "." + IndexPack.PackSuffix)) { pw.writePack(os); } using (Stream os = _dest.writeFile(pathIdx, monitor, wt + "." + IndexPack.IndexSuffix)) { pw.writeIndex(os); } // Record the pack at the start of the pack info list. This // way clients are likely to consult the newest pack first, // and discover the most recent objects there. // var infoPacks = new List<string> { packName }; infoPacks.AddRange(_packNames.Keys); _dest.writeInfoPacks(infoPacks); } catch (IOException err) { SafeDelete(pathIdx); SafeDelete(pathPack); throw new TransportException(_uri, "cannot store objects", err); } }
private FileInfo[] Pack(Core.Repository src, params RevObject[] list) { var pw = new PackWriter(src, NullProgressMonitor.Instance); foreach (RevObject o in list) { pw.addObject(o); } ObjectId name = pw.computeName(); FileInfo packFile = FullPackFileName(name); FileInfo idxFile = FullIndexFileName(name); var files = new[] { packFile, idxFile }; Write(files, pw); return files; }
private void Sendpack(IEnumerable<RemoteRefUpdate> updates, ProgressMonitor monitor) { string pathPack = null; string pathIdx = null; try { var pw = new PackWriter(_local, monitor); var need = new List<ObjectId>(); var have = new List<ObjectId>(); foreach (RemoteRefUpdate r in updates) { need.Add(r.NewObjectId); } foreach (Ref r in Refs) { have.Add(r.ObjectId); if (r.PeeledObjectId != null) { have.Add(r.PeeledObjectId); } } pw.preparePack(need, have); if (pw.getObjectsNumber() == 0) return; _packNames = new Dictionary<string, string>(); foreach (string n in _dest.getPackNames()) { _packNames.Add(n, n); } string b = "pack-" + pw.computeName().Name; string packName = b + IndexPack.PackSuffix; pathPack = "pack/" + packName; pathIdx = "pack/" + b + IndexPack.IndexSuffix; if (_packNames.Remove(packName)) { _dest.writeInfoPacks(new List<string>(_packNames.Keys)); _dest.deleteFile(pathIdx); } string wt = "Put " + b.Slice(0, 12); Stream os = _dest.writeFile(pathPack, monitor, wt + "." + IndexPack.PackSuffix); try { pw.writePack(os); } finally { os.Close(); } os = _dest.writeFile(pathIdx, monitor, wt + "..idx"); try { pw.writeIndex(os); } finally { os.Close(); } var infoPacks = new List<string> {packName}; infoPacks.AddRange(_packNames.Keys); _dest.writeInfoPacks(infoPacks); } catch (IOException err) { SafeDelete(pathIdx); SafeDelete(pathPack); throw new TransportException(_uri, "cannot store objects", err); } }
private void Sendpack(IEnumerable <RemoteRefUpdate> updates, ProgressMonitor monitor) { string pathPack = null; string pathIdx = null; try { var pw = new PackWriter(_local, monitor); var need = new List <ObjectId>(); var have = new List <ObjectId>(); foreach (RemoteRefUpdate r in updates) { need.Add(r.NewObjectId); } foreach (Ref r in Refs) { have.Add(r.ObjectId); if (r.PeeledObjectId != null) { have.Add(r.PeeledObjectId); } } pw.preparePack(need, have); if (pw.getObjectsNumber() == 0) { return; } _packNames = new Dictionary <string, string>(); foreach (string n in _dest.getPackNames()) { _packNames.Add(n, n); } string b = "pack-" + pw.computeName().Name; string packName = b + IndexPack.PackSuffix; pathPack = "pack/" + packName; pathIdx = "pack/" + b + IndexPack.IndexSuffix; if (_packNames.Remove(packName)) { _dest.writeInfoPacks(new List <string>(_packNames.Keys)); _dest.deleteFile(pathIdx); } string wt = "Put " + b.Slice(0, 12); Stream os = _dest.writeFile(pathPack, monitor, wt + "." + IndexPack.PackSuffix); try { pw.writePack(os); } finally { os.Close(); } os = _dest.writeFile(pathIdx, monitor, wt + "..idx"); try { pw.writeIndex(os); } finally { os.Close(); } var infoPacks = new List <string> { packName }; infoPacks.AddRange(_packNames.Keys); _dest.writeInfoPacks(infoPacks); } catch (IOException err) { SafeDelete(pathIdx); SafeDelete(pathPack); throw new TransportException(_uri, "cannot store objects", err); } }