Ejemplo n.º 1
0
		static bool CanShow (VersionControlItem item)
		{
			return !item.IsDirectory
				// FIXME: Review appending of Annotate support and use it.
				&& item.VersionInfo.IsVersioned
				&& AddinManager.GetExtensionObjects<IBlameViewHandler> (BlameViewHandlers).Any (h => h.CanHandle (item, null));
		}
Ejemplo n.º 2
0
		static async Task<bool> CanShowAsync (VersionControlItem item)
		{
			var controller = IdeApp.Workbench.GetDocument (item.Path)?.DocumentController;
			return !item.IsDirectory
				&& (await item.GetVersionInfoAsync()).IsVersioned
				&& AddinManager.GetExtensionObjects<IVersionControlViewHandler> (DiffViewHandlers).Any (h => h.CanHandle (item, controller));
		}
Ejemplo n.º 3
0
 static bool CanShow(VersionControlItem item)
 {
     // We want directories to be able to view the log for an entire directory
     // by selecting it from the solution pane
     return(item.VersionInfo.IsVersioned &&
            AddinManager.GetExtensionObjects <ILogViewHandler> (LogViewHandlers).Any(h => h.CanHandle(item, null)));
 }
Ejemplo n.º 4
0
        public static bool Commit(VersionControlItemList items, bool test)
        {
            if (items.Count != 1)
            {
                return(false);
            }

            VersionControlItem item = items [0];

            if (item.Repository.CanCommit(item.Path))
            {
                if (test)
                {
                    return(true);
                }
                ChangeSet cset = item.Repository.CreateChangeSet(item.Path);
                foreach (VersionInfo vi in item.Repository.GetDirectoryVersionInfo(item.Path, false, true))
                {
                    if (vi.HasLocalChanges)
                    {
                        cset.AddFile(vi);
                    }
                }
                if (!cset.IsEmpty)
                {
                    Commit(item.Repository, cset, false);
                }
                else
                {
                    MessageService.ShowMessage(GettextCatalog.GetString("There are no changes to be committed."));
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
 static async Task <bool> CanShowAsync(VersionControlItem item)
 {
     // We want directories to be able to view the log for an entire directory
     // by selecting it from the solution pane
     return((await item.GetVersionInfoAsync()).IsVersioned &&
            AddinManager.GetExtensionObjects <IVersionControlViewHandler> (LogViewHandlers).Any(h => h.CanHandle(item, null)));
 }
Ejemplo n.º 6
0
 static bool CanShow(VersionControlItem item)
 {
     return(!item.IsDirectory
            // FIXME: Review appending of Annotate support and use it.
            && item.VersionInfo.IsVersioned &&
            AddinManager.GetExtensionObjects <IBlameViewHandler> (BlameViewHandlers).Any(h => h.CanHandle(item, null)));
 }
Ejemplo n.º 7
0
		static bool CanShow (VersionControlItem item)
		{
			// We want directories to be able to view the log for an entire directory
			// by selecting it from the solution pane
			return item.VersionInfo.IsVersioned
				&& AddinManager.GetExtensionObjects<ILogViewHandler> (LogViewHandlers).Any (h => h.CanHandle (item, null));
		}
Ejemplo n.º 8
0
        static bool CanShow(VersionControlItem item)
        {
            var controller = IdeApp.Workbench.GetDocument(item.Path)?.DocumentController;

            return(!item.IsDirectory &&
                   item.VersionInfo.IsVersioned &&
                   AddinManager.GetExtensionObjects <IVersionControlViewHandler> (DiffViewHandlers).Any(h => h.CanHandle(item, controller)));
        }
Ejemplo n.º 9
0
        public static bool DefaultVCSViewCanHandle(VersionControlItem item, DocumentController controller)
        {
            if (controller == null)
            {
                return(item.Repository.GetFileIsText(item.Path));
            }

            return(controller is TextEditorViewContent || controller.GetContent <ITextBuffer> () != null);
        }
Ejemplo n.º 10
0
        static bool CanShow(VersionControlItem item)
        {
            var controller = IdeApp.Workbench.GetDocument(item.Path)?.DocumentController;

            return(!item.IsDirectory
                   // FIXME: Review appending of Annotate support and use it.
                   && item.VersionInfo.IsVersioned &&
                   AddinManager.GetExtensionObjects <IVersionControlViewHandler> (BlameViewHandlers).Any(h => h.CanHandle(item, controller)));
        }
Ejemplo n.º 11
0
        protected static VersionControlItemList GetItems()
        {
            VersionControlItemList list = new VersionControlItemList();
            VersionControlItem     it   = GetItem();

            if (it != null)
            {
                list.Add(it);
            }
            return(list);
        }
Ejemplo n.º 12
0
        protected internal override async Task <DocumentView> OnInitializeView()
        {
            mainView = await base.OnInitializeView();

            var controller = (FileDocumentController)Controller;
            var item       = new VersionControlItem(repo, project, controller.FilePath, false, null);

            vcInfo = new VersionControlDocumentInfo(this, Controller, item, item.Repository);
            await UpdateSubviewsAsync();

            VersionControlService.FileStatusChanged += VersionControlService_FileStatusChanged;
            return(mainView);
        }
        protected override async Task <DocumentView> OnInitializeView()
        {
            var mainView = await base.OnInitializeView();

            var controller = (FileDocumentController)Controller;
            var item       = new VersionControlItem(repo, project, controller.FilePath, false, null);

            vcInfo          = new VersionControlDocumentInfo(this, Controller, item, item.Repository);
            vcInfo.Document = Controller.Document;

            diffView = await TryAttachView(mainView, vcInfo, DiffCommand.DiffViewHandlers, GettextCatalog.GetString("Changes"), GettextCatalog.GetString("Shows the differences in the code between the current code and the version in the repository"));

            blameView = await TryAttachView(mainView, vcInfo, BlameCommand.BlameViewHandlers, GettextCatalog.GetString("Authors"), GettextCatalog.GetString("Shows the authors of the current file"));

            logView = await TryAttachView(mainView, vcInfo, LogCommand.LogViewHandlers, GettextCatalog.GetString("Log"), GettextCatalog.GetString("Shows the source control log for the current file"));

            mergeView = await TryAttachView(mainView, vcInfo, MergeCommand.MergeViewHandlers, GettextCatalog.GetString("Merge"), GettextCatalog.GetString("Shows the merge view for the current file"));

            return(mainView);
        }
		static void HandleDocumentChanged (object sender, EventArgs e)
		{
			var document = Ide.IdeApp.Workbench.ActiveDocument;
			try {
				if (document == null || !document.IsFile || document.Window.FindView<ILogView> () >= 0)
					return;

				WorkspaceObject project = document.Project;
				if (project == null) {
					// Fix for broken .csproj and .sln files not being seen as having a project.
					foreach (var projItem in Ide.IdeApp.Workspace.GetAllItems<UnknownSolutionItem> ()) {
						if (projItem.FileName == document.FileName) {
							project = projItem;
						}
					}

					if (project == null)
						return;
				}
				
				var repo = VersionControlService.GetRepository (project);
				if (repo == null)
					return;

				var versionInfo = repo.GetVersionInfo (document.FileName, VersionInfoQueryFlags.IgnoreCache);
				if (!versionInfo.IsVersioned)
					return;

				var item = new VersionControlItem (repo, project, document.FileName, false, null);
				var vcInfo = new VersionControlDocumentInfo (document.PrimaryView, item, item.Repository);
				TryAttachView (document, vcInfo, DiffCommand.DiffViewHandlers);
				TryAttachView (document, vcInfo, BlameCommand.BlameViewHandlers);
				TryAttachView (document, vcInfo, LogCommand.LogViewHandlers);
				TryAttachView (document, vcInfo, MergeCommand.MergeViewHandlers);
			} catch (Exception ex) {
				// If a user is hitting this, it will show a dialog box every time they
				// switch to a document or open a document, so suppress the crash dialog
				// This bug *should* be fixed already, but it's hard to tell.
				LoggingService.LogInternalError (ex);
			}
		}
        public VersionControlItemList GetItems(bool projRecurse = true)
        {
            // Cached items are used only in the status view, not in the project pad.
            if (items != null)
            {
                return(items);
            }

            // Don't cache node items because they can change
            VersionControlItemList nodeItems = new VersionControlItemList();

            foreach (ITreeNavigator node in CurrentNodes)
            {
                VersionControlItem item = CreateItem(node.DataItem, projRecurse);
                if (item != null)
                {
                    nodeItems.Add(item);
                }
            }
            return(nodeItems);
        }
		public bool CanHandle (VersionControlItem item, DocumentView primaryView)
		{
			return (primaryView == null || primaryView.GetContent <ITextFile> () != null)
				&& DesktopService.GetMimeTypeIsText (DesktopService.GetMimeTypeForUri (item.Path));
		}
Ejemplo n.º 17
0
		public bool CanHandle (VersionControlItem item, DocumentView primaryView)
		{
			return (primaryView == null || primaryView.GetContent <ITextFile> () != null)
				&& item.Repository.GetFileIsText (item.Path);
		}
Ejemplo n.º 18
0
		public bool CanHandle (VersionControlItem item)
		{
			return true;
		}
		public bool CanHandle (VersionControlItem item, DocumentView primaryView)
		{
			return (primaryView == null || primaryView.GetContent <MonoDevelop.SourceEditor.SourceEditorView> () != null)
				&& item.Repository.GetFileIsText (item.Path);
		}
Ejemplo n.º 20
0
		static bool CanShow (VersionControlItem item)
		{
			return !item.IsDirectory
				&& item.VersionInfo.IsVersioned
				&& AddinManager.GetExtensionObjects<IMergeViewHandler> (MergeViewHandlers).Any (h => h.CanHandle (item, null));
		}
 public bool CanHandle(VersionControlItem item)
 {
     return(DesktopService.GetMimeTypeIsText(DesktopService.GetMimeTypeForUri(item.Path)));
 }
        private async Task <TestResult> RunCommandAsync(Commands cmd, bool test, bool projRecurse = true, CancellationToken cancellationToken = default)
        {
            VersionControlItemList items = GetItems(projRecurse);

            foreach (VersionControlItem it in items)
            {
                if (it.Repository == null)
                {
                    if (cmd != Commands.Publish)
                    {
                        return(TestResult.NoVersionControl);
                    }
                }
                else if (it.Repository.VersionControlSystem != null && !it.Repository.VersionControlSystem.IsInstalled)
                {
                    return(TestResult.Disable);
                }
            }

            bool res = false;

            try {
                switch (cmd)
                {
                case Commands.Update:
                    res = await UpdateCommand.UpdateAsync(items, test, cancellationToken);

                    break;

                case Commands.Diff:
                    res = await DiffCommand.Show(items, test);

                    break;

                case Commands.Log:
                    res = await LogCommand.Show(items, test);

                    break;

                case Commands.Status:
                    res = await StatusView.ShowAsync(items, test, false);

                    break;

                case Commands.Add:
                    res = await AddCommand.AddAsync(items, test, cancellationToken);

                    break;

                case Commands.Remove:
                    res = await RemoveCommand.RemoveAsync(items, test, cancellationToken);

                    break;

                case Commands.Revert:
                    res = await RevertCommand.RevertAsync(items, test, cancellationToken);

                    break;

                case Commands.Lock:
                    res = await LockCommand.LockAsync(items, test, cancellationToken);

                    break;

                case Commands.Unlock:
                    res = await UnlockCommand.UnlockAsync(items, test, cancellationToken);

                    break;

                case Commands.Publish:
                    VersionControlItem it = items [0];
                    if (items.Count == 1 && it.IsDirectory && it.WorkspaceObject != null)
                    {
                        res = PublishCommand.Publish(it.WorkspaceObject, it.Path, test);
                    }
                    break;

                case Commands.Annotate:
                    res = await BlameCommand.Show(items, test);

                    break;

                case Commands.CreatePatch:
                    res = await CreatePatchCommand.CreatePatchAsync(items, test, cancellationToken);

                    break;

                case Commands.Ignore:
                    res = await IgnoreCommand.IgnoreAsync(items, test, cancellationToken);

                    break;

                case Commands.Unignore:
                    res = await UnignoreCommand.UnignoreAsync(items, test, cancellationToken);

                    break;

                case Commands.ResolveConflicts:
                    res = await ResolveConflictsCommand.ResolveConflicts(items, test);

                    break;
                }
            } catch (OperationCanceledException) {
                return(TestResult.Disable);
            } catch (Exception ex) {
                if (test)
                {
                    LoggingService.LogError(ex.ToString());
                }
                else
                {
                    MessageService.ShowError(GettextCatalog.GetString("Version control command failed."), ex);
                }
                return(TestResult.Disable);
            }

            return(res ? TestResult.Enable : TestResult.Disable);
        }
Ejemplo n.º 23
0
 public bool CanHandle(VersionControlItem item, DocumentView primaryView)
 {
     return((primaryView == null || primaryView.GetContent <ITextFile> () != null) &&
            item.Repository.GetFileIsText(item.Path));
 }
Ejemplo n.º 24
0
		public bool CanHandle (VersionControlItem item)
		{
			return DesktopService.GetMimeTypeIsText (DesktopService.GetMimeTypeForUri (item.Path));
		}
Ejemplo n.º 25
0
		static bool CanShow (VersionControlItem item)
		{
			return !item.IsDirectory && AddinManager.GetExtensionObjects<IBlameViewHandler> (BlameViewHandlers).Any (h => h.CanHandle (item));
		}
Ejemplo n.º 26
0
 static bool CanShow(VersionControlItem item)
 {
     return(!item.IsDirectory &&
            item.VersionInfo.IsVersioned &&
            AddinManager.GetExtensionObjects <IDiffViewHandler> (DiffViewHandlers).Any(h => h.CanHandle(item, null)));
 }
Ejemplo n.º 27
0
		public bool CanHandle (VersionControlItem item, IViewContent primaryView)
		{
			return (primaryView == null || primaryView.GetContent<ITextFile> () != null)
				&& !item.IsDirectory
				&& item.Path.HasExtension (".plist");
		}
Ejemplo n.º 28
0
 public bool CanHandle(VersionControlItem item, IViewContent primaryView)
 {
     return(true);
 }
Ejemplo n.º 29
0
 public bool CanHandle(VersionControlItem item)
 {
     return(true);
 }
Ejemplo n.º 30
0
 public ILogView CreateView(VersionControlItem item, IViewContent primaryView)
 {
     return(new LogView(new VersionControlDocumentInfo(primaryView, item, item.Repository)));
 }
Ejemplo n.º 31
0
		public IDiffView CreateView (VersionControlItem item, IViewContent primaryView)
		{
			return CreateView (new VersionControlDocumentInfo (primaryView, item, item.Repository));
		}
Ejemplo n.º 32
0
 public bool CanHandle(VersionControlItem item, DocumentController controller) => DefaultVCSViewCanHandle(item, controller);
Ejemplo n.º 33
0
 public bool CanHandle(VersionControlItem item, DocumentView primaryView)
 {
     return((primaryView == null || primaryView.GetContent <ITextFile> () != null) &&
            DesktopService.GetMimeTypeIsText(DesktopService.GetMimeTypeForUri(item.Path)));
 }
Ejemplo n.º 34
0
		public bool CanHandle (VersionControlItem item, DocumentView primaryView)
		{
			return true;
		}
Ejemplo n.º 35
0
		public bool CanHandle (VersionControlItem item)
		{
			return !item.IsDirectory && item.Path.HasExtension (".plist");
		}
Ejemplo n.º 36
0
 public bool CanHandle(VersionControlItem item, DocumentView primaryView)
 {
     return(true);
 }
Ejemplo n.º 37
0
 public bool CanHandle(VersionControlItem item, DocumentController controller)
 {
     return((controller is FileDocumentController || controller == null) && item.Repository.GetFileIsText(item.Path));
 }
        private TestResult RunCommand(Commands cmd, bool test)
        {
            VersionControlItemList items = GetItems();

            foreach (VersionControlItem it in items)
            {
                if (it.Repository == null)
                {
                    if (cmd != Commands.Publish)
                    {
                        return(TestResult.NoVersionControl);
                    }
                }
                else if (it.Repository.VersionControlSystem != null && !it.Repository.VersionControlSystem.IsInstalled)
                {
                    return(TestResult.Disable);
                }
            }

            bool res = false;

            try {
                switch (cmd)
                {
                case Commands.Update:
                    res = UpdateCommand.Update(items, test);
                    break;

                case Commands.Diff:
                    res = DiffCommand.Show(items, test);
                    break;

                case Commands.Log:
                    res = LogCommand.Show(items, test);
                    break;

                case Commands.Status:
                    res = StatusView.Show(items, test);
                    break;

                case Commands.Commit:
                    res = CommitCommand.Commit(items, test);
                    break;

                case Commands.Add:
                    res = AddCommand.Add(items, test);
                    break;

                case Commands.Remove:
                    res = RemoveCommand.Remove(items, test);
                    break;

                case Commands.Revert:
                    res = RevertCommand.Revert(items, test);
                    break;

                case Commands.Lock:
                    res = LockCommand.Lock(items, test);
                    break;

                case Commands.Unlock:
                    res = UnlockCommand.Unlock(items, test);
                    break;

                case Commands.Publish:
                    VersionControlItem it = items [0];
                    if (items.Count == 1 && it.IsDirectory && it.WorkspaceObject != null)
                    {
                        res = PublishCommand.Publish(it.WorkspaceObject, it.Path, test);
                    }
                    break;

                case Commands.Annotate:
                    res = BlameCommand.Show(items, test);
                    break;

                case Commands.CreatePatch:
                    res = CreatePatchCommand.CreatePatch(items, test);
                    break;
                }
            }
            catch (Exception ex) {
                if (test)
                {
                    LoggingService.LogError(ex.ToString());
                }
                else
                {
                    MessageService.ShowException(ex, GettextCatalog.GetString("Version control command failed."));
                }
                return(TestResult.Disable);
            }

            return(res ? TestResult.Enable : TestResult.Disable);
        }
Ejemplo n.º 39
0
 public static bool DefaultVCSViewCanHandle(VersionControlItem item, DocumentController controller)
 {
     return(item.Repository.GetFileIsText(item.Path));
 }
 public bool CanHandle(VersionControlItem item, DocumentView primaryView)
 {
     return((primaryView == null || primaryView.GetContent <MonoDevelop.SourceEditor.SourceEditorView> () != null) &&
            item.Repository.GetFileIsText(item.Path));
 }
Ejemplo n.º 41
0
 static bool CanShow(VersionControlItem item)
 {
     return(!item.IsDirectory && AddinManager.GetExtensionObjects <IBlameViewHandler> (BlameViewHandlers).Any(h => h.CanHandle(item)));
 }
		public bool CanHandle (VersionControlItem item, IViewContent primaryView)
		{
			return true;
		}