public RemotePack(string lockMessage, List <PackLock> packLocks, ObjectChecker oC, Repository r, WalkRemoteObjectDatabase c, string pn) { _lockMessage = lockMessage; _packLocks = packLocks; _objCheck = oC; _local = r; DirectoryInfo objdir = _local.ObjectsDirectory; _connection = c; PackName = pn; _idxName = IndexPack.GetIndexFileName(PackName.Slice(0, PackName.Length - 5)); string tn = _idxName; if (tn.StartsWith("pack-")) { tn = tn.Substring(5); } if (tn.EndsWith(IndexPack.IndexSuffix)) { tn = tn.Slice(0, tn.Length - 4); } TmpIdx = new FileInfo(Path.Combine(objdir.ToString(), "walk-" + tn + ".walkidx")); }
public void test1() { FileInfo packFile = GetPack("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack"); using (Stream @is = packFile.Open(System.IO.FileMode.Open, FileAccess.Read)) { var tmppack = new FileInfo(Path.Combine(trash.FullName, "tmp_pack1")); var pack = new IndexPack(db, @is, tmppack); pack.index(new TextProgressMonitor()); var idxFile = new FileInfo(Path.Combine(trash.FullName, "tmp_pack1.idx")); var tmpPackFile = new FileInfo(Path.Combine(trash.FullName, "tmp_pack1.pack")); //return; using (var file = new PackFile(idxFile, tmpPackFile)) { Assert.IsTrue(file.HasObject(ObjectId.FromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("540a36d136cf413e4b064c2b0e0a4db60f77feab"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("902d5476fa249b7abc9d84c611577a81381f0327"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("c59759f143fb1fe21c197981df75a7ee00290799"))); } } }
private IndexPack newIndexPack() { IndexPack ip = IndexPack.Create(_transport.Local, _bin); ip.setFixThin(true); ip.setObjectChecking(_transport.CheckFetchedObjects); return(ip); }
private void ReceivePack(ProgressMonitor monitor) { IndexPack ip = IndexPack.Create(local, _sideband ? pckIn.sideband(monitor) : inStream); ip.setFixThin(_thinPack); ip.setObjectChecking(transport.CheckFetchedObjects); ip.index(monitor); _packLock = ip.renameAndOpenPack(_lockMessage); }
/// <summary> /// Create an index pack instance to load a new pack into a repository. /// <para/> /// The received pack data and generated index will be saved to temporary /// files within the repository's <code>objects</code> directory. To use the /// data contained within them call <see cref="renameAndOpenPack()"/> once the /// indexing is complete. /// </summary> /// <param name="db">the repository that will receive the new pack.</param> /// <param name="stream"> /// stream to read the pack data from. If the stream is buffered /// use <see cref="BUFFER_SIZE"/> as the buffer size for the stream. /// </param> /// <returns>a new index pack instance.</returns> internal static IndexPack Create(Repository db, Stream stream) { DirectoryInfo objdir = db.ObjectsDirectory; FileInfo tmp = CreateTempFile("incoming_", PackSuffix, objdir); string n = tmp.Name; var basef = PathUtil.CombineFilePath(objdir, n.Slice(0, n.Length - PackSuffix.Length)); var ip = new IndexPack(db, stream, basef); ip.setIndexVersion(db.Config.getCore().getPackIndexVersion()); return(ip); }
public void DownloadPack(ProgressMonitor monitor) { Stream s = _connection.open("pack/" + PackName); IndexPack ip = IndexPack.Create(_local, s); ip.setFixThin(false); ip.setObjectChecker(_objCheck); ip.index(monitor); PackLock keep = ip.renameAndOpenPack(_lockMessage); if (keep != null) { _packLocks.Add(keep); } }
protected override void doFetch(ProgressMonitor monitor, List <Ref> want, List <ObjectId> have) { verifyPrerequisites(); try { IndexPack ip = newIndexPack(); ip.index(monitor); packLock = ip.renameAndOpenPack(lockMessage); } catch (IOException err) { Close(); throw new TransportException(transport.Uri, err.Message, err); } }
private void ReceivePack(ProgressMonitor monitor) { Stream input = inStream; if (_sideband) { input = new SideBandInputStream(input, monitor); } IndexPack ip = IndexPack.Create(local, input); ip.setFixThin(_thinPack); ip.setObjectChecking(transport.CheckFetchedObjects); ip.index(monitor); _packLock = ip.renameAndOpenPack(_lockMessage); }
public override List <string> getPackNames() { var packs = new List <string>(); try { var list = new List <ChannelSftp.LsEntry>(); foreach (object o in _ftp.ls("pack")) { list.Add((ChannelSftp.LsEntry)o); } var files = new Dictionary <string, ChannelSftp.LsEntry>(); var mtimes = new Dictionary <string, int>(); foreach (ChannelSftp.LsEntry ent in list) { files.Add(ent.getFilename(), ent); } foreach (ChannelSftp.LsEntry ent in list) { string n = ent.getFilename(); if (!n.StartsWith("pack-") || n.EndsWith(IndexPack.PackSuffix)) { continue; } string @in = IndexPack.GetIndexFileName(n.Slice(0, n.Length - 5)); if (!files.ContainsKey(@in)) { continue; } mtimes.Add(n, ent.getAttrs().getMTime()); packs.Add(n); } packs.Sort((a, b) => mtimes[a] - mtimes[b]); } catch (SftpException je) { throw new TransportException("Can't ls " + _objectsPath + "/pack: " + je.message, je); } return(packs); }
private void receivePack() { IndexPack ip = IndexPack.Create(db, raw); ip.setFixThin(true); ip.setObjectChecking(isCheckReceivedObjects()); ip.index(new NullProgressMonitor()); // [caytchen] TODO: reflect gitsharp string lockMsg = "jgit receive-pack"; if (getRefLogIdent() != null) { lockMsg += " from " + getRefLogIdent().ToExternalString(); } packLock = ip.renameAndOpenPack(lockMsg); }
private void receivePack() { indexPack = IndexPack.Create(db, rawInput); indexPack.setFixThin(true); indexPack.setNeedNewObjectIds(needNewObjectIds); indexPack.setNeedBaseObjectIds(needBaseObjectIds); indexPack.setObjectChecking(isCheckReceivedObjects()); indexPack.index(NullProgressMonitor.Instance); // TODO: [caytchen] reflect gitsharp string lockMsg = "jgit receive-pack"; if (getRefLogIdent() != null) { lockMsg += " from " + getRefLogIdent().ToExternalString(); } packLock = indexPack.renameAndOpenPack(lockMsg); }
internal static IndexPack Create(Repository db, Stream stream) { DirectoryInfo objdir = db.ObjectsDirectory; FileInfo tmp = CreateTempFile("incoming_", PackSuffix, objdir); string n = tmp.Name; var basef = new FileInfo(Path.Combine(objdir.FullName, n.Slice(0, n.Length - PackSuffix.Length))); var ip = new IndexPack(db, stream, basef); ip.setIndexVersion(db.Config.getCore().getPackIndexVersion()); return ip; }
public void test2() { FileInfo packFile = GetPack("pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack"); using (Stream @is = packFile.Open(System.IO.FileMode.Open, FileAccess.Read)) { var tmppack = new FileInfo(Path.Combine(trash.FullName, "tmp_pack2")); var pack = new IndexPack(db, @is, tmppack); pack.index(new TextProgressMonitor()); var idxFile = new FileInfo(Path.Combine(trash.FullName, "tmp_pack2.idx")); var tmpPackFile = new FileInfo(Path.Combine(trash.FullName, "tmp_pack2.pack")); using (var file = new PackFile(idxFile, tmpPackFile)) { Assert.IsTrue(file.HasObject(ObjectId.FromString("02ba32d3649e510002c21651936b7077aa75ffa9"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("0966a434eb1a025db6b71485ab63a3bfbea520b6"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("09efc7e59a839528ac7bda9fa020dc9101278680"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("0a3d7772488b6b106fb62813c4d6d627918d9181"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("1004d0d7ac26fbf63050a234c9b88a46075719d3"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("10da5895682013006950e7da534b705252b03be6"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("1203b03dc816ccbb67773f28b3c19318654b0bc8"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("15fae9e651043de0fd1deef588aa3fbf5a7a41c6"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("16f9ec009e5568c435f473ba3a1df732d49ce8c3"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("1fd7d579fb6ae3fe942dc09c2c783443d04cf21e"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("20a8ade77639491ea0bd667bf95de8abf3a434c8"))); Assert.IsTrue(file.HasObject(ObjectId.FromString("2675188fd86978d5bc4d7211698b2118ae3bf658"))); // and lots more... } } }
private void VerifyOpenPack(bool thin) { IndexPack indexer; Stream @is; if (thin) { @is = new MemoryStream(_os.ToArray()); indexer = new IndexPack(db, @is, _packBase); try { indexer.index(new TextProgressMonitor()); Assert.Fail("indexer should grumble about missing object"); } catch (IOException) { // expected } } @is = new MemoryStream(_os.ToArray()); indexer = new IndexPack(db, @is, _packBase); indexer.setKeepEmpty(true); indexer.setFixThin(thin); indexer.setIndexVersion(2); indexer.index(new TextProgressMonitor()); _pack = new PackFile(_indexFile, _packFile); }