Пример #1
0
 public SideBandInputStream(PacketLineIn aPckIn, Stream aIns, ProgressMonitor aProgress)
 {
     pckIn = aPckIn;
     ins = aIns;
     monitor = aProgress;
     currentTask = "";
 }
Пример #2
0
		public SideBandInputStream(Stream @in, ProgressMonitor progress)
		{
			rawIn = @in;
			pckIn = new PacketLineIn(rawIn);
			monitor = progress;
			currentTask = string.Empty;
			progressBuffer = string.Empty;
		}
		internal AggregatedProgressMonitor (ProgressMonitor leaderMonitor, CancellationTokenSource cancelSource, params ProgressMonitor[] followerMonitors)
		{
			CancellationTokenSource = cancelSource ?? new CancellationTokenSource ();
			this.leaderMonitor = leaderMonitor;
			AddFollowerMonitor (leaderMonitor, MonitorAction.All);
			foreach (ProgressMonitor mon in followerMonitors)
				AddFollowerMonitor (mon);
		}
        public ComputeRelativeTimesProgressMonitor(ProgressMonitor next, Action<string> writer = null)
        {
            if (writer == null)
                writer = s => Debug.WriteLine(s);

            this.next = next;
            this.writer = writer;
        }
Пример #5
0
 public SideBandInputStream(PacketLineIn aPckIn, Stream aIns, ProgressMonitor aProgress)
 {
     pckIn = aPckIn;
     ins = aIns;
     monitor = aProgress;
     currentTask = string.Empty;
     progressBuffer = string.Empty;
 }
		internal AggregatedProgressMonitor (ProgressMonitor masterMonitor, CancellationTokenSource cancelSource, params ProgressMonitor[] slaveMonitors)
		{
			CancellationTokenSource = cancelSource ?? new CancellationTokenSource ();
			this.masterMonitor = masterMonitor;
			AddSlaveMonitor (masterMonitor, MonitorAction.All);
			foreach (ProgressMonitor mon in slaveMonitors)
				AddSlaveMonitor (mon);
		}
Пример #7
0
        internal virtual void execute(ProgressMonitor monitor, FetchResult result)
        {
            _askFor.Clear();
            _localUpdates.Clear();
            _fetchHeadUpdates.Clear();
            _packLocks.Clear();

            try
            {
                executeImp(monitor, result);
            }
            finally
            {
                foreach (PackLock @lock in _packLocks)
                {
                    @lock.Unlock();
                }
            }
        }
Пример #8
0
        public PushResult execute(ProgressMonitor monitor)
        {
            monitor.BeginTask(PROGRESS_OPENING_CONNECTION, -1);
            connection = transport.openPush();
            try
            {
                monitor.EndTask();

                Dictionary<string, RemoteRefUpdate> preprocessed = prepareRemoteUpdates();
                if (transport.DryRun)
                    modifyUpdatesForDryRun();
                else if (preprocessed.Count != 0)
                    connection.Push(monitor, preprocessed);
            }
            finally
            {
                connection.Close();
            }
            if (!transport.DryRun)
                updateTrackingRefs();
            return prepareOperationResult();
        }
Пример #9
0
 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);
     }
 }
Пример #10
0
        protected override void doFetch(ProgressMonitor monitor, List<Ref> want, List<ObjectId> have)
        {
            MarkLocalRefsComplete(have);
            QueueWants(want);

            while (!monitor.IsCancelled && _workQueue.Count > 0)
            {
                ObjectId id = _workQueue.First.Value;
                _workQueue.RemoveFirst();
                if (!(id is RevObject) || !((RevObject)id).has(COMPLETE))
                {
                    DownloadObject(monitor, id);
                }
                Process(id);
            }
        }
Пример #11
0
        private bool DownloadPackedObject(ProgressMonitor monitor, AnyObjectId id)
        {
            IEnumerator<RemotePack> packItr = _unfetchedPacks.GetEnumerator();
            while (packItr.MoveNext() && !monitor.IsCancelled)
            {
                RemotePack pack = packItr.Current;
                try
                {
                    pack.OpenIndex(monitor);
                }
                catch (IOException err)
                {
                    RecordError(id, err);
                    _unfetchedPacks.Remove(pack);
                    continue;
                }

                if (monitor.IsCancelled)
                    return false;

                if (!pack.Index.HasObject(id))
                    continue;

                try
                {
                    pack.DownloadPack(monitor);
                }
                catch (IOException err)
                {
                    RecordError(id, err);
                    continue;
                }
                finally
                {
                    pack.TmpIdx.Delete();
                    _unfetchedPacks.Remove(pack);
                }

                if (!_local.HasObject(id))
                {
                    RecordError(id,
                                new FileNotFoundException("Object " + id.Name + " not found in " + pack.PackName + "."));
                    continue;
                }

                IEnumerator<ObjectId> pending = SwapFetchQueue();
                while (pending.MoveNext())
                {
                    ObjectId p = pending.Current;
                    if (pack.Index.HasObject(p))
                    {
                        _workQueue.Remove(p);
                        Process(p);
                    }
                    else
                        _workQueue.AddLast(p);
                }
                return true;
            }
            return false;
        }
Пример #12
0
        protected override bool OnBuild(ProgressMonitor monitor, DeployContext ctx)
        {
            string             tmpFolder = FileService.CreateTempDirectory();
            Solution           solution  = null;
            SolutionFolderItem entry     = RootSolutionItem;

            try {
                if (generateFiles)
                {
                    List <string> childEntries = new List <string> ();
                    if (entry is SolutionFolder)
                    {
                        SolutionFolderItem[] ents = GetChildEntries();
                        foreach (SolutionFolderItem it in ents)
                        {
                            childEntries.Add(it.ItemId);
                        }
                    }
                    else
                    {
                        // If the entry is not a combine, use the parent combine as base combine
                        childEntries.Add(entry.ItemId);
                        entry = entry.ParentFolder;
                    }

                    string sourceFile;
                    if (entry is SolutionFolder)
                    {
                        sourceFile = entry.ParentSolution.FileName;
                    }
                    else
                    {
                        sourceFile = ((SolutionItem)entry).FileName;
                    }

                    string efile = Services.ProjectService.Export(new FilteredProgressMonitor(monitor), sourceFile, childEntries.ToArray(), tmpFolder, null).Result;
                    if (efile == null)
                    {
                        monitor.ReportError(GettextCatalog.GetString("The project could not be exported."), null);
                        return(false);
                    }
                    solution = Services.ProjectService.ReadWorkspaceItem(new ProgressMonitor(), efile).Result as Solution;
                }
                else
                {
                    solution = entry.ParentSolution;
                }

                var res = solution.Build(monitor, (SolutionConfigurationSelector)defaultConfig).Result;
                if (res.HasErrors || monitor.CancellationToken.IsCancellationRequested)
                {
                    return(false);
                }

                SolutionDeployer deployer = new SolutionDeployer(generateAutotools);
                deployer.AddSwitches(switchs);

                if (!deployer.Deploy(ctx, solution, DefaultConfiguration, TargetDir, generateFiles, monitor))
                {
                    return(false);
                }
            } finally {
                if (solution != null)
                {
                    solution.Dispose();
                }
                Directory.Delete(tmpFolder, true);
            }
            return(true);
        }
Пример #13
0
        protected override void OnWriteProject(ProgressMonitor monitor, MSBuildProject msproject)
        {
            base.OnWriteProject(monitor, msproject);

            dotNetCoreMSBuildProject.WriteProject(msproject, Project.TargetFramework.Id);
        }
Пример #14
0
        ///	<summary>
        /// Perform push operation between local and remote repository - set remote
        /// refs appropriately, send needed objects and update local tracking refs.
        /// <para />
        /// When <seealso cref="Transport.DryRun"/> is true, result of this operation is
        /// just estimation of real operation result, no real action is performed.
        /// </summary>
        /// <param name="monitor">
        /// Progress monitor used for feedback about operation.
        /// </param>
        /// <returns> result of push operation with complete status description. </returns>
        /// <exception cref="NotSupportedException">
        /// When push operation is not supported by provided transport.
        /// </exception>
        /// <exception cref="TransportException">
        /// When some error occurred during operation, like I/O, protocol
        /// error, or local database consistency error.
        /// </exception>
        public PushResult execute(ProgressMonitor monitor)
        {
            if (monitor == null)
                throw new ArgumentNullException("monitor");

            monitor.BeginTask(PROGRESS_OPENING_CONNECTION, ProgressMonitor.UNKNOWN);
            _connection = _transport.openPush();

            try
            {
                monitor.EndTask();

                IDictionary<string, RemoteRefUpdate> preprocessed = PrepareRemoteUpdates();
                if (_transport.DryRun)
                {
                    ModifyUpdatesForDryRun();
                }
                else if (preprocessed.Count != 0)
                {
                    _connection.Push(monitor, preprocessed);
                }
            }
            finally
            {
                _connection.Close();
            }

            if (!_transport.DryRun)
            {
                UpdateTrackingRefs();
            }

            return PrepareOperationResult();
        }
Пример #15
0
 public void Push(ProgressMonitor monitor, IDictionary<string, RemoteRefUpdate> refUpdates)
 {
     markStartedOperation();
     doPush(monitor, refUpdates);
 }
Пример #16
0
 public abstract void PerformChange(ProgressMonitor monitor, RefactoringOptions rctx);
Пример #17
0
        internal ComponentIndex GetComponentIndex(ProgressMonitor monitor)
        {
            // Returns an index of all components that can be added to the toolbox.

            ComponentIndex index = ComponentIndex.Load();

            // Get the list of assemblies that need to be updated

            HashSet <string>          files    = new HashSet <string> ();
            List <ComponentIndexFile> toupdate = new List <ComponentIndexFile> ();
            List <ComponentIndexFile> todelete = new List <ComponentIndexFile> ();

            foreach (ComponentIndexFile ia in index.Files)
            {
                files.Add(ia.FileName);
                if (!File.Exists(ia.FileName))
                {
                    todelete.Add(ia);
                }
                if (ia.NeedsUpdate)
                {
                    toupdate.Add(ia);
                }
                if (monitor.CancellationToken.IsCancellationRequested)
                {
                    return(index);
                }
            }

            // Look for new assemblies

            foreach (TargetRuntime runtime in Runtime.SystemAssemblyService.GetTargetRuntimes())
            {
                foreach (SystemAssembly asm in runtime.AssemblyContext.GetAssemblies())
                {
                    if (files.Add(asm.Location))
                    {
                        ComponentIndexFile c = new ComponentIndexFile(asm.Location);
                        index.Files.Add(c);
                        toupdate.Add(c);
                    }
                    if (monitor.CancellationToken.IsCancellationRequested)
                    {
                        return(index);
                    }
                }
            }

            foreach (ComponentIndexFile ia in todelete)
            {
                index.Files.Remove(ia);
            }

            if (toupdate.Count > 0)
            {
                monitor.BeginTask(GettextCatalog.GetString("Looking for components..."), toupdate.Count);
                LoaderContext ctx = new LoaderContext();
                try {
                    foreach (ComponentIndexFile ia in toupdate)
                    {
                        ia.Update(ctx);
                        monitor.Step(1);
                        if (monitor.CancellationToken.IsCancellationRequested)
                        {
                            return(index);
                        }
                    }
                } finally {
                    ctx.Dispose();
                    monitor.EndTask();
                }
            }

            if (toupdate.Count > 0 || todelete.Count > 0)
            {
                index.Save();
            }

            return(index);
        }
Пример #18
0
 public override void PerformChange(ProgressMonitor monitor, RefactoringOptions rctx)
 {
     IdeApp.Workbench.OpenDocument(FileName);
 }
Пример #19
0
 public override void PerformChange(ProgressMonitor monitor, RefactoringOptions rctx)
 {
     IdeApp.ProjectOperations.SaveAsync(this.Project);
 }
Пример #20
0
 public override void PerformChange(ProgressMonitor monitor, RefactoringOptions rctx)
 {
     File.WriteAllText(FileName, Content);
     rctx.DocumentContext.Project.AddFile(FileName);
     IdeApp.ProjectOperations.SaveAsync(rctx.DocumentContext.Project);
 }
Пример #21
0
        protected override async Task OnReevaluateProject(ProgressMonitor monitor)
        {
            await base.OnReevaluateProject(monitor);

            UpdateHiddenFiles(Project.Files);
        }
Пример #22
0
        protected override async Task <ProjectFile[]> OnGetSourceFiles(ProgressMonitor monitor, ConfigurationSelector configuration)
        {
            var sourceFiles = await base.OnGetSourceFiles(monitor, configuration);

            return(AddMissingProjectFiles(sourceFiles));
        }
Пример #23
0
 internal protected virtual Task PrepareExecution(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
 {
     return(next.PrepareExecution(monitor, context, configuration, (SolutionRunConfiguration)context.RunConfiguration));
 }
Пример #24
0
        static bool UpdateCompleted(ProgressMonitor monitor,
                                    ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result,
                                    bool runMultipleFiles)
        {
            monitor.EndTask();

            if (monitor.CancellationToken.IsCancellationRequested)
            {
                monitor.ReportError(GettextCatalog.GetString("Cancelled"), null);
                monitor.Dispose();
                return(false);
            }

            string genFileName;

            try {
                bool broken = false;

                if (result.UnhandledException != null)
                {
                    broken = true;
                    string msg = GettextCatalog.GetString("The '{0}' code generator crashed", file.Generator);
                    result.Errors.Add(new CompilerError(file.Name, 0, 0, "",
                                                        msg +
                                                        ": " +
                                                        result.UnhandledException.Message +
                                                        Environment.NewLine +
                                                        result.UnhandledException.StackTrace));
                    monitor.ReportError(msg, result.UnhandledException);
                    LoggingService.LogError(msg, result.UnhandledException);
                }

                genFileName = result.GeneratedFilePath.IsNullOrEmpty?
                              null : result.GeneratedFilePath.ToRelative(file.FilePath.ParentDirectory);

                if (!string.IsNullOrEmpty(genFileName))
                {
                    bool validName = genFileName.IndexOfAny(new [] { '/', '\\' }) < 0 &&
                                     FileService.IsValidFileName(genFileName);

                    if (!broken && !validName)
                    {
                        broken = true;
                        string msg = GettextCatalog.GetString("The '{0}' code generator output invalid filename '{1}'",
                                                              file.Generator, result.GeneratedFilePath);
                        result.Errors.Add(new CompilerError(file.Name, 0, 0, "", msg));
                        monitor.ReportError(msg, null);
                    }
                }

                if (result.Errors.Count > 0)
                {
                    Runtime.RunInMainThread(delegate {
                        foreach (CompilerError err in result.Errors)
                        {
                            TaskService.Errors.Add(new TaskListEntry(file.FilePath, err.ErrorText, err.Column, err.Line,
                                                                     err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error,
                                                                     TaskPriority.Normal, file.Project.ParentSolution, file));
                        }
                    });
                }

                if (broken)
                {
                    return(true);
                }

                if (!runMultipleFiles)
                {
                    if (result.Success)
                    {
                        monitor.ReportSuccess("Generated file successfully.");
                    }
                    else if (result.SuccessWithWarnings)
                    {
                        monitor.ReportSuccess("Warnings in file generation.");
                    }
                    else
                    {
                        monitor.ReportError("Errors in file generation.", null);
                    }
                }
            } finally {
                if (!runMultipleFiles)
                {
                    monitor.Dispose();
                }
            }

            if (result.GeneratedFilePath.IsNullOrEmpty || !File.Exists(result.GeneratedFilePath))
            {
                return(true);
            }

            // broadcast a change event so text editors etc reload the file
            FileService.NotifyFileChanged(result.GeneratedFilePath);

            // add file to project, update file properties, etc
            Gtk.Application.Invoke(async(o, args) => {
                bool projectChanged = false;
                if (genFile == null)
                {
                    genFile        = file.Project.AddFile(result.GeneratedFilePath, result.OverrideBuildAction);
                    projectChanged = true;
                }
                else if (result.GeneratedFilePath != genFile.FilePath)
                {
                    genFile.Name   = result.GeneratedFilePath;
                    projectChanged = true;
                }

                if (file.LastGenOutput != genFileName)
                {
                    file.LastGenOutput = genFileName;
                    projectChanged     = true;
                }

                if (genFile.DependsOn != file.FilePath.FileName)
                {
                    genFile.DependsOn = file.FilePath.FileName;
                    projectChanged    = true;
                }

                if (projectChanged)
                {
                    await IdeApp.ProjectOperations.SaveAsync(file.Project);
                }
            });

            return(true);
        }
		public FilteredProgressMonitor (ProgressMonitor targetMonitor)
			: this (targetMonitor, MonitorAction.WriteLog | MonitorAction.ReportError | MonitorAction.ReportWarning | MonitorAction.ReportSuccess | MonitorAction.Cancel | MonitorAction.SlaveCancel)
		{
		}
Пример #26
0
 public CleanEventArgs(ProgressMonitor monitor)
 {
     this.monitor = monitor;
 }
Пример #27
0
        public PushResult push(ProgressMonitor monitor, ICollection<RemoteRefUpdate> toPush)
        {
            if (toPush == null || toPush.Count == 0)
            {
                try
                {
                    toPush = findRemoteRefUpdatesFor(_pushSpecs);
                }
                catch (IOException e)
                {
                    throw new TransportException("Problem with resolving push ref specs locally: " + e.Message, e);
                }

                if (toPush.Count == 0)
                {
                    throw new TransportException("Nothing to push");
                }
            }

            var pushProcess = new PushProcess(this, toPush);
            return pushProcess.execute(monitor);
        }
Пример #28
0
 internal protected virtual Task <BuildResult> Clean(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
 {
     return(next.Clean(monitor, configuration, operationContext));
 }
Пример #29
0
        private void WriteCommands(IEnumerable<RemoteRefUpdate> refUpdates, ProgressMonitor monitor)
        {
            string capabilities = EnableCapabilities();
            foreach (RemoteRefUpdate rru in refUpdates)
            {
                if (!_capableDeleteRefs && rru.IsDelete)
                {
                    rru.Status = RemoteRefUpdate.UpdateStatus.REJECTED_NODELETE;
                    continue;
                }

                var sb = new StringBuilder();
                Ref advertisedRef = GetRef(rru.RemoteName);
                ObjectId oldId = (advertisedRef == null ? ObjectId.ZeroId : advertisedRef.ObjectId);
                sb.Append(oldId.Name);
                sb.Append(' ');
                sb.Append(rru.NewObjectId.Name);
                sb.Append(' ');
                sb.Append(rru.RemoteName);
                if (!_sentCommand)
                {
                    _sentCommand = true;
                    sb.Append(capabilities);
                }

                pckOut.WriteString(sb.ToString());
                rru.Status = RemoteRefUpdate.UpdateStatus.AWAITING_REPORT;
                if (!rru.IsDelete)
                    _shouldWritePack = true;
            }

            if (monitor.IsCancelled)
                throw new TransportException(uri, "push cancelled");
            pckOut.End();
            outNeedsEnd = false;
        }
Пример #30
0
 public Stream sideband(ProgressMonitor pm)
 {
     return new SideBandInputStream(this, ins, pm);
 }
Пример #31
0
 internal protected virtual void OnWriteSolutionFolderItemData(ProgressMonitor monitor, SlnPropertySet properties, SolutionFolderItem item)
 {
     next.OnWriteSolutionFolderItemData(monitor, properties, item);
 }
Пример #32
0
 PackageManagementEventsMonitor CreateEventMonitor(ProgressMonitor monitor, TaskCompletionSource <bool> taskCompletionSource)
 {
     return(CreateEventMonitor(monitor, packageManagementEvents, taskCompletionSource));
 }
Пример #33
0
 public void Fetch(ProgressMonitor monitor, ICollection<Ref> want, IList<ObjectId> have)
 {
     markStartedOperation();
     doFetch(monitor, want, have);
 }
Пример #34
0
 internal protected virtual void OnWriteConfigurationData(ProgressMonitor monitor, SlnPropertySet properties, SolutionConfiguration configuration)
 {
     next.OnWriteConfigurationData(monitor, properties, configuration);
 }
Пример #35
0
 internal protected virtual Task <TargetEvaluationResult> OnRunTarget(ProgressMonitor monitor, string target, ConfigurationSelector configuration, TargetEvaluationContext context)
 {
     return(next.OnRunTarget(monitor, target, configuration, context));
 }
Пример #36
0
        /// <exception cref="System.NotSupportedException"></exception>
        /// <exception cref="NGit.Errors.TransportException"></exception>
        private void ExecuteImp(ProgressMonitor monitor, FetchResult result)
        {
            conn = transport.OpenFetch();
            try
            {
                result.SetAdvertisedRefs(transport.GetURI(), conn.GetRefsMap());
                ICollection <Ref> matched = new HashSet <Ref>();
                foreach (RefSpec spec in toFetch)
                {
                    if (spec.GetSource() == null)
                    {
                        throw new TransportException(MessageFormat.Format(JGitText.Get().sourceRefNotSpecifiedForRefspec
                                                                          , spec));
                    }
                    if (spec.IsWildcard())
                    {
                        ExpandWildcard(spec, matched);
                    }
                    else
                    {
                        ExpandSingle(spec, matched);
                    }
                }
                ICollection <Ref> additionalTags = Sharpen.Collections.EmptyList <Ref>();
                TagOpt            tagopt         = transport.GetTagOpt();
                if (tagopt == TagOpt.AUTO_FOLLOW)
                {
                    additionalTags = ExpandAutoFollowTags();
                }
                else
                {
                    if (tagopt == TagOpt.FETCH_TAGS)
                    {
                        ExpandFetchTags();
                    }
                }
                bool includedTags;
                if (!askFor.IsEmpty() && !AskForIsComplete())
                {
                    FetchObjects(monitor);
                    includedTags = conn.DidFetchIncludeTags();
                    // Connection was used for object transfer. If we
                    // do another fetch we must open a new connection.
                    //
                    CloseConnection(result);
                }
                else
                {
                    includedTags = false;
                }
                if (tagopt == TagOpt.AUTO_FOLLOW && !additionalTags.IsEmpty())
                {
                    // There are more tags that we want to follow, but
                    // not all were asked for on the initial request.
                    //
                    Sharpen.Collections.AddAll(have, askFor.Keys);
                    askFor.Clear();
                    foreach (Ref r in additionalTags)
                    {
                        ObjectId id = r.GetPeeledObjectId();
                        if (id == null)
                        {
                            id = r.GetObjectId();
                        }
                        if (transport.local.HasObject(id))
                        {
                            WantTag(r);
                        }
                    }
                    if (!askFor.IsEmpty() && (!includedTags || !AskForIsComplete()))
                    {
                        ReopenConnection();
                        if (!askFor.IsEmpty())
                        {
                            FetchObjects(monitor);
                        }
                    }
                }
            }
            finally
            {
                CloseConnection(result);
            }
            BatchRefUpdate batch = transport.local.RefDatabase.NewBatchUpdate().SetAllowNonFastForwards
                                       (true).SetRefLogMessage("fetch", true);
            RevWalk walk = new RevWalk(transport.local);

            try
            {
                if (monitor is BatchingProgressMonitor)
                {
                    ((BatchingProgressMonitor)monitor).SetDelayStart(250, TimeUnit.MILLISECONDS);
                }
                if (transport.IsRemoveDeletedRefs())
                {
                    DeleteStaleTrackingRefs(result, batch);
                }
                foreach (TrackingRefUpdate u in localUpdates)
                {
                    result.Add(u);
                    batch.AddCommand(u.AsReceiveCommand());
                }
                foreach (ReceiveCommand cmd in batch.GetCommands())
                {
                    cmd.UpdateType(walk);
                    if (cmd.GetType() == ReceiveCommand.Type.UPDATE_NONFASTFORWARD && cmd is TrackingRefUpdate.Command &&
                        !((TrackingRefUpdate.Command)cmd).CanForceUpdate())
                    {
                        cmd.SetResult(ReceiveCommand.Result.REJECTED_NONFASTFORWARD);
                    }
                }
                if (transport.IsDryRun())
                {
                    foreach (ReceiveCommand cmd_1 in batch.GetCommands())
                    {
                        if (cmd_1.GetResult() == ReceiveCommand.Result.NOT_ATTEMPTED)
                        {
                            cmd_1.SetResult(ReceiveCommand.Result.OK);
                        }
                    }
                }
                else
                {
                    batch.Execute(walk, monitor);
                }
            }
            catch (IOException err)
            {
                throw new TransportException(MessageFormat.Format(JGitText.Get().failureUpdatingTrackingRef
                                                                  , GetFirstFailedRefName(batch), err.Message), err);
            }
            finally
            {
                walk.Release();
            }
            if (!fetchHeadUpdates.IsEmpty())
            {
                try
                {
                    UpdateFETCH_HEAD(result);
                }
                catch (IOException err)
                {
                    throw new TransportException(MessageFormat.Format(JGitText.Get().failureUpdatingFETCH_HEAD
                                                                      , err.Message), err);
                }
            }
        }
Пример #37
0
 private void ResolveDeltas(ProgressMonitor progress)
 {
     progress.BeginTask(PROGRESS_RESOLVE_DELTA, _deltaCount);
     int last = _entryCount;
     for (int i = 0; i < last; i++)
     {
         int before = _entryCount;
         ResolveDeltas(_entries[i]);
         progress.Update(_entryCount - before);
         if (progress.IsCancelled)
         {
             throw new IOException("Download cancelled during indexing");
         }
     }
     progress.EndTask();
 }
Пример #38
0
 internal protected virtual void OnReadProjectHeader(ProgressMonitor monitor, MSBuildProject msproject)
 {
     next.OnReadProjectHeader(monitor, msproject);
 }
Пример #39
0
 /// <summary>
 /// Implementation of <see cref="Fetch"/>
 /// without checking for multiple fetch.
 /// </summary>
 /// <param name="monitor">as in <see cref="Fetch"/></param>
 /// <param name="want">as in <see cref="Fetch"/></param>
 /// <param name="have">as in <see cref="Fetch"/></param>
 protected abstract void doFetch(ProgressMonitor monitor, ICollection<Ref> want, IList<ObjectId> have);
Пример #40
0
 internal protected virtual void OnReadProject(ProgressMonitor monitor, MSBuildProject msproject)
 {
     next.OnReadProject(monitor, msproject);
     msproject.EvaluatedProperties.ReadObjectProperties(this, GetType(), true);
     msproject.ReadExternalProjectProperties(this, GetType(), true);
 }
Пример #41
0
 public BundleWriter(Repository repo, ProgressMonitor monitor)
 {
     packWriter = new PackWriter(repo, monitor);
     includeObjects = new Dictionary<string, ObjectId>();
     assumeCommits = new List<RevCommit>();
 }
Пример #42
0
 internal protected virtual void OnWriteProject(ProgressMonitor monitor, MSBuildProject msproject)
 {
     next.OnWriteProject(monitor, msproject);
     msproject.GetGlobalPropertyGroup().WriteObjectProperties(this, GetType(), true);
     msproject.WriteExternalProjectProperties(this, GetType(), true);
 }
Пример #43
0
        private void DownloadObject(ProgressMonitor pm, AnyObjectId id)
        {
            if (_local.HasObject(id)) return;

            while (true)
            {
                if (DownloadPackedObject(pm, id))
                    return;

                string idStr = id.Name;
                string subdir = idStr.Slice(0, 2);
                string file = idStr.Substring(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 = 0; i < _lastRemoteIdx; i++)
                {
                    if (DownloadLooseObject(id, looseName, _remotes[i]))
                    {
                        _lastRemoteIdx = i;
                        return;
                    }
                }

                while (_noPacksYet.Count > 0)
                {
                    WalkRemoteObjectDatabase wrr = _noPacksYet.First.Value;
                    _noPacksYet.RemoveFirst();
                    List<string> packNameList;
                    try
                    {
                        pm.BeginTask("Listing packs", ProgressMonitor.UNKNOWN);
                        packNameList = wrr.getPackNames();
                    }
                    catch (IOException e)
                    {
                        RecordError(id, e);
                        continue;
                    }
                    finally
                    {
                        pm.EndTask();
                    }

                    if (packNameList == null || packNameList.Count == 0)
                        continue;
                    foreach (string packName in packNameList)
                    {
                        if (!_packsConsidered.Contains(packName))
                        {
                            _packsConsidered.Add(packName);
                            _unfetchedPacks.AddLast(new RemotePack(_lockMessage, _packLocks, _objCheck, _local, wrr, packName));
                        }
                    }
                    if (DownloadPackedObject(pm, id))
                        return;
                }

                List<WalkRemoteObjectDatabase> al = ExpandOneAlternate(id, pm);
                if (al != null && al.Count > 0)
                {
                    foreach (WalkRemoteObjectDatabase alt in al)
                    {
                        _remotes.Add(alt);
                        _noPacksYet.AddLast(alt);
                        _noAlternatesYet.AddLast(alt);
                    }
                    continue;
                }

                List<Exception> failures = null;
                if (_fetchErrors.ContainsKey(id.Copy()))
                {
                    failures = _fetchErrors[id.Copy()];
                }

                TransportException te = null;
                if (failures != null && failures.Count > 0)
                {
                    te = failures.Count == 1 ?
                        new TransportException("Cannot get " + id.Name + ".", failures[0]) :
                        new TransportException("Cannot get " + id.Name + ".", new CompoundException(failures));
                }

                if (te == null)
                {
                    te = new TransportException("Cannot get " + id.Name + ".");
                }

                throw te;
            }
        }
Пример #44
0
 internal protected virtual void OnWriteConfiguration(ProgressMonitor monitor, ProjectConfiguration config, IPropertySet pset)
 {
     next.OnWriteConfiguration(monitor, config, pset);
 }
Пример #45
0
 private List<WalkRemoteObjectDatabase> ExpandOneAlternate(AnyObjectId id, ProgressMonitor pm)
 {
     while (_noAlternatesYet.Count > 0)
     {
         WalkRemoteObjectDatabase wrr = _noAlternatesYet.First.Value;
         _noAlternatesYet.RemoveFirst();
         try
         {
             pm.BeginTask("Listing alternates", ProgressMonitor.UNKNOWN);
             List<WalkRemoteObjectDatabase> altList = wrr.getAlternates();
             if (altList != null && altList.Count > 0)
                 return altList;
         }
         catch (IOException e)
         {
             RecordError(id, e);
         }
         finally
         {
             pm.EndTask();
         }
     }
     return null;
 }
Пример #46
0
 internal protected virtual Task OnReevaluateProject(ProgressMonitor monitor)
 {
     return(next.OnReevaluateProject(monitor));
 }
Пример #47
0
            public void OpenIndex(ProgressMonitor pm)
            {
                if (Index != null) return;

                try
                {
                    Index = PackIndex.Open(TmpIdx);
                    return;
                }
                catch (FileNotFoundException)
                {

                }

                Stream s = _connection.open("pack/" + _idxName);
                pm.BeginTask("Get " + _idxName.Slice(0, 12) + "..idx", s.Length < 0 ? -1 : (int)(s.Length / 1024));
                try
                {
                    var fos = new FileStream(TmpIdx.ToString(), System.IO.FileMode.Open, FileAccess.ReadWrite);
                    try
                    {
                        var buf = new byte[2048];
                        int cnt;
                        while (!pm.IsCancelled && (cnt = s.Read(buf, 0, buf.Length)) >= 0)
                        {
                            fos.Write(buf, 0, cnt);
                            pm.Update(cnt / 1024);
                        }
                    }
                    finally
                    {
                        fos.Close();
                    }
                }
                catch (IOException)
                {
                    TmpIdx.Delete();
                    throw;
                }
                finally
                {
                    s.Close();
                }
                pm.EndTask();

                if (pm.IsCancelled)
                {
                    TmpIdx.Delete();
                    return;
                }

                try
                {
                    Index = PackIndex.Open(TmpIdx);
                }
                catch (IOException)
                {
                    TmpIdx.Delete();
                    throw;
                }
            }
Пример #48
0
 internal protected virtual Task <ProjectFile []> OnGetSourceFiles(ProgressMonitor monitor, ConfigurationSelector configuration)
 {
     return(next.OnGetSourceFiles(monitor, configuration));
 }
Пример #49
0
        private void writePack(IDictionary<string, RemoteRefUpdate> refUpdates, ProgressMonitor monitor)
        {
            PackWriter writer = new PackWriter(local, monitor);
            List<ObjectId> remoteObjects = new List<ObjectId>(Refs.Count);
            List<ObjectId> newObjects = new List<ObjectId>(refUpdates.Count);

            foreach (Ref r in Refs)
                remoteObjects.Add(r.ObjectId);

            remoteObjects.AddRange(additionalHaves);
            foreach (RemoteRefUpdate r in refUpdates.Values)
            {
                if (!ObjectId.ZeroId.Equals(r.NewObjectId))
                    newObjects.Add(r.NewObjectId);
            }

            writer.Thin = _thinPack;
            writer.DeltaBaseAsOffset = _capableOfsDelta;
            writer.preparePack(newObjects, remoteObjects);
            writer.writePack(stream);
        }
Пример #50
0
 internal protected virtual void OnWriteRunConfiguration(ProgressMonitor monitor, ProjectRunConfiguration config, IPropertySet properties)
 {
     next.OnWriteRunConfiguration(monitor, config, properties);
 }
		public FilteredProgressMonitor (ProgressMonitor targetMonitor, MonitorAction actionMask)
		{
			AddSlaveMonitor (targetMonitor, actionMask);
		}
 public FigmaAggregatedProgressMonitor(ProgressMonitor monitor, string successMessage)
     : base(monitor)
 {
     this.successMessage = successMessage;
     ExtensionLoggingService.AddProgressMonitor(this);
 }
Пример #53
0
        public FetchResult fetch(ProgressMonitor monitor, List<RefSpec> toFetch)
        {
            if (toFetch == null || toFetch.Count == 0)
            {
                if (_fetchSpecs.Count == 0)
                {
                    throw new TransportException("Nothing to fetch.");
                }
                toFetch = _fetchSpecs;
            }
            else if (_fetchSpecs.Count != 0)
            {
                var tmp = new List<RefSpec>(toFetch);
                foreach (RefSpec requested in toFetch)
                {
                    string reqSrc = requested.Source;
                    foreach (RefSpec configured in _fetchSpecs)
                    {
                        string cfgSrc = configured.Source;
                        string cfgDst = configured.Destination;
                        if (cfgSrc.Equals(reqSrc) && cfgDst != null)
                        {
                            tmp.Add(configured);
                            break;
                        }
                    }
                }
                toFetch = tmp;
            }

            var result = new FetchResult();
            new FetchProcess(this, toFetch).execute(monitor, result);
            return result;
        }
Пример #54
0
 public Task SaveAsync(FilePath fileName, ProgressMonitor monitor)
 {
     AssertMainThread();
     FileName = fileName;
     return(SaveAsync(monitor));
 }
Пример #55
0
 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);
     }
 }
Пример #56
0
 protected internal virtual Task OnSave(ProgressMonitor monitor)
 {
     return(Task.FromResult(0));
 }
Пример #57
0
 protected void doPush(ProgressMonitor monitor, IDictionary<string, RemoteRefUpdate> refUpdates)
 {
     try
     {
         WriteCommands(refUpdates.Values, monitor);
         if (_shouldWritePack)
             writePack(refUpdates, monitor);
         if (_sentCommand && _capableReport)
             readStatusReport(refUpdates);
     }
     catch (TransportException)
     {
         throw;
     }
     catch (Exception e)
     {
         throw new TransportException(uri, e.Message, e);
     }
     finally
     {
         Dispose();
     }
 }
Пример #58
0
 internal protected override Task Save(ProgressMonitor monitor)
 {
     return(Item.OnSave(monitor));
 }
Пример #59
0
        private void writePack(IDictionary<string, RemoteRefUpdate> refUpdates, ProgressMonitor monitor)
        {
            PackWriter writer = new PackWriter(local, monitor);
            List<ObjectId> remoteObjects = new List<ObjectId>(Refs.Count);
            List<ObjectId> newObjects = new List<ObjectId>(refUpdates.Count);

            foreach (Ref r in Refs)
                remoteObjects.Add(r.ObjectId);

            remoteObjects.AddRange(additionalHaves);
            foreach (RemoteRefUpdate r in refUpdates.Values)
            {
                if (!ObjectId.ZeroId.Equals(r.NewObjectId))
                    newObjects.Add(r.NewObjectId);
            }

            writer.Thin = _thinPack;
            writer.DeltaBaseAsOffset = _capableOfsDelta;
            writer.preparePack(newObjects, remoteObjects);
            long start = SystemReader.getInstance().getCurrentTime();
            writer.writePack(outStream);
            packTransferTime = SystemReader.getInstance().getCurrentTime() - start;
        }
Пример #60
0
        protected override bool OnBuild(ProgressMonitor monitor, DeployContext ctx)
        {
            string tmpFolder = null;

            try {
                SolutionConfigurationSelector conf = (SolutionConfigurationSelector)configuration;
                var bt = RootSolutionItem as IBuildTarget;
                if (bt != null)
                {
                    BuildResult res = bt.Build(monitor, conf).Result;
                    if (res.ErrorCount > 0)
                    {
                        foreach (BuildError e in res.Errors)
                        {
                            monitor.ReportError(e.ToString(), null);
                        }
                        monitor.ReportError(GettextCatalog.GetString("The source project failed to build."), null);
                        return(false);
                    }
                }

                tmpFolder = FileService.CreateTempDirectory();

                string tf = Path.GetFileNameWithoutExtension(targetFile);
                if (tf.EndsWith(".tar"))
                {
                    tf = Path.GetFileNameWithoutExtension(tf);
                }
                string folder = FileService.GetFullPath(Path.Combine(tmpFolder, tf));

                // Export the binary files
                DeployFileCollection deployFiles = GetDeployFiles(ctx, conf);
                foreach (DeployFile file in deployFiles)
                {
                    string tfile = Path.Combine(folder, file.ResolvedTargetFile);
                    string tdir  = FileService.GetFullPath(Path.GetDirectoryName(tfile));
                    if (!Directory.Exists(tdir))
                    {
                        Directory.CreateDirectory(tdir);
                    }
                    File.Copy(file.SourcePath, tfile, true);
                }

                // Create the archive
                string td = Path.GetDirectoryName(targetFile);
                if (!Directory.Exists(td))
                {
                    Directory.CreateDirectory(td);
                }
                DeployService.CreateArchive(monitor, tmpFolder, targetFile);
            }
            catch (Exception ex) {
                monitor.ReportError("Package creation failed", ex);
                LoggingService.LogError("Package creation failed", ex);
                return(false);
            }
            finally {
                if (tmpFolder != null)
                {
                    Directory.Delete(tmpFolder, true);
                }
            }
            monitor.Log.WriteLine(GettextCatalog.GetString("Created file: {0}", targetFile));
            return(true);
        }