Exemplo n.º 1
0
 internal WalkPushConnection(WalkTransport walkTransport, WalkRemoteObjectDatabase
                             w)
 {
     transport = (NGit.Transport.Transport)walkTransport;
     local     = transport.local;
     uri       = transport.GetURI();
     dest      = w;
 }
Exemplo n.º 2
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 private bool DownloadLooseObject(AnyObjectId id, string looseName, WalkRemoteObjectDatabase
                                  remote)
 {
     try
     {
         byte[] compressed = remote.Open(looseName).ToArray();
         VerifyAndInsertLooseObject(id, compressed);
         return(true);
     }
     catch (FileNotFoundException e)
     {
         // Not available in a loose format from this alternate?
         // Try another strategy to get the object.
         //
         RecordError(id, e);
         return(false);
     }
     catch (IOException e)
     {
         throw new TransportException(MessageFormat.Format(JGitText.Get().cannotDownload,
                                                           id.Name), e);
     }
 }
Exemplo n.º 3
0
            internal RemotePack(WalkFetchConnection _enclosing, WalkRemoteObjectDatabase c, string
                                pn)
            {
                this._enclosing = _enclosing;
                this.connection = c;
                this.packName   = pn;
                this.idxName    = Sharpen.Runtime.Substring(this.packName, 0, this.packName.Length -
                                                            5) + ".idx";
                string tn = this.idxName;

                if (tn.StartsWith("pack-"))
                {
                    tn = Sharpen.Runtime.Substring(tn, 5);
                }
                if (tn.EndsWith(".idx"))
                {
                    tn = Sharpen.Runtime.Substring(tn, 0, tn.Length - 4);
                }
                if (this._enclosing.local.ObjectDatabase is ObjectDirectory)
                {
                    this.tmpIdx = new FilePath(((ObjectDirectory)this._enclosing.local.ObjectDatabase
                                                ).GetDirectory(), "walk-" + tn + ".walkidx");
                }
            }
Exemplo n.º 4
0
			internal RemotePack(WalkFetchConnection _enclosing, WalkRemoteObjectDatabase c, string
				 pn)
			{
				this._enclosing = _enclosing;
				this.connection = c;
				this.packName = pn;
				this.idxName = Sharpen.Runtime.Substring(this.packName, 0, this.packName.Length -
					 5) + ".idx";
				string tn = this.idxName;
				if (tn.StartsWith("pack-"))
				{
					tn = Sharpen.Runtime.Substring(tn, 5);
				}
				if (tn.EndsWith(".idx"))
				{
					tn = Sharpen.Runtime.Substring(tn, 0, tn.Length - 4);
				}
				if (this._enclosing.local.ObjectDatabase is ObjectDirectory)
				{
					this.tmpIdx = new FilePath(((ObjectDirectory)this._enclosing.local.ObjectDatabase
						).GetDirectory(), "walk-" + tn + ".walkidx");
				}
			}
Exemplo n.º 5
0
		/// <exception cref="NGit.Errors.TransportException"></exception>
		private bool DownloadLooseObject(AnyObjectId id, string looseName, WalkRemoteObjectDatabase
			 remote)
		{
			try
			{
				byte[] compressed = remote.Open(looseName).ToArray();
				VerifyAndInsertLooseObject(id, compressed);
				return true;
			}
			catch (FileNotFoundException e)
			{
				// Not available in a loose format from this alternate?
				// Try another strategy to get the object.
				//
				RecordError(id, e);
				return false;
			}
			catch (IOException e)
			{
				throw new TransportException(MessageFormat.Format(JGitText.Get().cannotDownload, 
					id.Name), e);
			}
		}
Exemplo n.º 6
0
		internal WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)
		{
			NGit.Transport.Transport wt = (NGit.Transport.Transport)t;
			local = wt.local;
			objCheck = wt.IsCheckFetchedObjects() ? new ObjectChecker() : null;
			inserter = local.NewObjectInserter();
			reader = local.NewObjectReader();
			remotes = new AList<WalkRemoteObjectDatabase>();
			remotes.AddItem(w);
			unfetchedPacks = new List<WalkFetchConnection.RemotePack>();
			packsConsidered = new HashSet<string>();
			noPacksYet = new List<WalkRemoteObjectDatabase>();
			noPacksYet.AddItem(w);
			noAlternatesYet = new List<WalkRemoteObjectDatabase>();
			noAlternatesYet.AddItem(w);
			fetchErrors = new Dictionary<ObjectId, IList<Exception>>();
			packLocks = new AList<PackLock>(4);
			revWalk = new RevWalk(reader);
			revWalk.SetRetainBody(false);
			treeWalk = new TreeWalk(reader);
			COMPLETE = revWalk.NewFlag("COMPLETE");
			IN_WORK_QUEUE = revWalk.NewFlag("IN_WORK_QUEUE");
			LOCALLY_SEEN = revWalk.NewFlag("LOCALLY_SEEN");
			localCommitQueue = new DateRevQueue();
			workQueue = new List<ObjectId>();
		}
Exemplo n.º 7
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 private void DownloadObject(ProgressMonitor pm, AnyObjectId id)
 {
     if (AlreadyHave(id))
     {
         return;
     }
     for (; ;)
     {
         // Try a pack file we know about, but don't have yet. Odds are
         // that if it has this object, it has others related to it so
         // getting the pack is a good bet.
         //
         if (DownloadPackedObject(pm, id))
         {
             return;
         }
         // Search for a loose object over all alternates, starting
         // from the one we last successfully located an object through.
         //
         string idStr     = id.Name;
         string subdir    = Sharpen.Runtime.Substring(idStr, 0, 2);
         string file      = Sharpen.Runtime.Substring(idStr, 2);
         string looseName = subdir + "/" + file;
         for (int i = lastRemoteIdx; i < remotes.Count; i++)
         {
             if (DownloadLooseObject(id, looseName, remotes[i]))
             {
                 lastRemoteIdx = i;
                 return;
             }
         }
         for (int i_1 = 0; i_1 < lastRemoteIdx; i_1++)
         {
             if (DownloadLooseObject(id, looseName, remotes[i_1]))
             {
                 lastRemoteIdx = i_1;
                 return;
             }
         }
         // Try to obtain more pack information and search those.
         //
         while (!noPacksYet.IsEmpty())
         {
             WalkRemoteObjectDatabase wrr = noPacksYet.RemoveFirst();
             ICollection <string>     packNameList;
             try
             {
                 pm.BeginTask("Listing packs", ProgressMonitor.UNKNOWN);
                 packNameList = wrr.GetPackNames();
             }
             catch (IOException e)
             {
                 // Try another repository.
                 //
                 RecordError(id, e);
                 continue;
             }
             finally
             {
                 pm.EndTask();
             }
             if (packNameList == null || packNameList.IsEmpty())
             {
                 continue;
             }
             foreach (string packName in packNameList)
             {
                 if (packsConsidered.AddItem(packName))
                 {
                     unfetchedPacks.AddItem(new WalkFetchConnection.RemotePack(this, wrr, packName));
                 }
             }
             if (DownloadPackedObject(pm, id))
             {
                 return;
             }
         }
         // Try to expand the first alternate we haven't expanded yet.
         //
         ICollection <WalkRemoteObjectDatabase> al = ExpandOneAlternate(id, pm);
         if (al != null && !al.IsEmpty())
         {
             foreach (WalkRemoteObjectDatabase alt in al)
             {
                 remotes.AddItem(alt);
                 noPacksYet.AddItem(alt);
                 noAlternatesYet.AddItem(alt);
             }
             continue;
         }
         // We could not obtain the object. There may be reasons why.
         //
         IList <Exception>  failures = fetchErrors.Get((ObjectId)id);
         TransportException te;
         te = new TransportException(MessageFormat.Format(JGitText.Get().cannotGet, id.Name
                                                          ));
         if (failures != null && !failures.IsEmpty())
         {
             if (failures.Count == 1)
             {
                 Sharpen.Extensions.InitCause(te, failures[0]);
             }
             else
             {
                 Sharpen.Extensions.InitCause(te, new CompoundException(failures));
             }
         }
         throw te;
     }
 }
Exemplo n.º 8
0
		internal WalkPushConnection(WalkTransport walkTransport, WalkRemoteObjectDatabase
			 w)
		{
			transport = (NGit.Transport.Transport)walkTransport;
			local = transport.local;
			uri = transport.GetURI();
			dest = w;
		}