コード例 #1
0
		void SolutionCreated(object sender, SolutionEventArgs e)
		{
			if (!AddInOptions.AutomaticallyAddFiles) return;
			string solutionFileName = e.Solution.FileName;
			string solutionDirectory = e.Solution.Directory;
			
			if (!CanBeVersionControlledFile(solutionDirectory)) return;
			
			try {
				using (SvnClientWrapper client = new SvnClientWrapper()) {
					SvnMessageView.HandleNotifications(client);
					
					Status status = client.SingleStatus(solutionDirectory);
					if (status.TextStatus == StatusKind.Unversioned) {
						client.Add(solutionDirectory, Recurse.None);
					}
					status = client.SingleStatus(solutionFileName);
					if (status.TextStatus == StatusKind.Unversioned) {
						client.Add(solutionFileName, Recurse.None);
						client.AddToIgnoreList(solutionDirectory, Path.GetFileName(solutionFileName) + ".cache");
					}
				}
				foreach (IProject p in e.Solution.Projects) {
					ProjectCreated(null, new ProjectEventArgs(p));
				}
			} catch (SvnClientException ex) {
				MessageService.ShowError(ex.Message);
			} catch (Exception ex) {
				MessageService.ShowError(ex, "Solution add exception");
			}
		}
コード例 #2
0
        void FileRenaming(object sender, FileRenamingEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }
            if (!AddInOptions.AutomaticallyRenameFiles)
            {
                return;
            }
            string fullSource = Path.GetFullPath(e.SourceFile);

            if (!CanBeVersionControlledFile(fullSource))
            {
                return;
            }
            if (!FileHelpers.CheckRenameOrReplacePossible(e))
            {
                e.Cancel = true;
                return;
            }
            try {
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    Status status = client.SingleStatus(fullSource);
                    switch (status.TextStatus)
                    {
                    case StatusKind.Unversioned:
                    case StatusKind.None:
                    case StatusKind.Ignored:
                        return;                                 // nothing to do

                    case StatusKind.Normal:
                    case StatusKind.Modified:
                    case StatusKind.Replaced:
                    case StatusKind.Added:
                        // rename without problem
                        break;

                    default:
                        MessageService.ShowErrorFormatted("${res:AddIns.Subversion.CannotMoveError}", status.TextStatus.ToString());
                        e.Cancel = true;
                        return;
                    }
                    e.OperationAlreadyDone = true;
                    client.Move(fullSource,
                                Path.GetFullPath(e.TargetFile),
                                true
                                );
                }
            } catch (Exception ex) {
                MessageService.ShowError("File renamed exception: " + ex);
            }
        }
コード例 #3
0
        void ProjectCreated(object sender, ProjectEventArgs e)
        {
            if (!AddInOptions.AutomaticallyAddFiles)
            {
                return;
            }
            if (!CanBeVersionControlledFile(e.Project.Directory))
            {
                return;
            }

            string projectDir = Path.GetFullPath(e.Project.Directory);

            try {
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    Status status = client.SingleStatus(projectDir);
                    if (status.TextStatus != StatusKind.Unversioned)
                    {
                        return;
                    }
                    client.Add(projectDir, Recurse.None);
                    if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "bin"), e.Project.OutputAssemblyFullPath))
                    {
                        client.AddToIgnoreList(projectDir, "bin");
                    }
                    CompilableProject compilableProject = e.Project as CompilableProject;
                    if (compilableProject != null)
                    {
                        if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "obj"), compilableProject.IntermediateOutputFullPath))
                        {
                            client.AddToIgnoreList(projectDir, "obj");
                        }
                    }
                    foreach (ProjectItem item in e.Project.Items)
                    {
                        FileProjectItem fileItem = item as FileProjectItem;
                        if (fileItem != null)
                        {
                            if (FileUtility.IsBaseDirectory(projectDir, fileItem.FileName))
                            {
                                AddFileWithParentDirectoriesToSvn(client, fileItem.FileName);
                            }
                        }
                    }
                    AddFileWithParentDirectoriesToSvn(client, e.Project.FileName);
                }
            } catch (SvnClientException ex) {
                MessageService.ShowError(ex.Message);
            } catch (Exception ex) {
                MessageService.ShowException(ex, "Project add exception");
            }
        }
コード例 #4
0
 private static void AddFileWithParentDirectoriesToSvn(SvnClientWrapper client, string fileName)
 {
     if (!LocalHelper.CanBeVersionControlledFile(fileName))
     {
         AddFileWithParentDirectoriesToSvn(client, FileUtility.GetAbsolutePath(fileName, ".."));
     }
     var status = client.SingleStatus(fileName);
     if (status.TextStatus != StatusKind.Unversioned)
         return;
     client.Add(fileName, Recurse.None);
 }
コード例 #5
0
        void SolutionCreated(object sender, SolutionEventArgs e)
        {
            if (!AddInOptions.AutomaticallyAddFiles)
            {
                return;
            }
            string solutionFileName  = e.Solution.FileName;
            string solutionDirectory = e.Solution.Directory;

            if (!CanBeVersionControlledFile(solutionDirectory))
            {
                return;
            }

            try {
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    Status status = client.SingleStatus(solutionDirectory);
                    if (status.TextStatus == StatusKind.Unversioned)
                    {
                        client.Add(solutionDirectory, Recurse.None);
                    }
                    status = client.SingleStatus(solutionFileName);
                    if (status.TextStatus == StatusKind.Unversioned)
                    {
                        client.Add(solutionFileName, Recurse.None);
                        client.AddToIgnoreList(solutionDirectory, Path.GetFileName(solutionFileName) + ".cache");
                    }
                }
                foreach (IProject p in e.Solution.Projects)
                {
                    ProjectCreated(null, new ProjectEventArgs(p));
                }
            } catch (SvnClientException ex) {
                MessageService.ShowError(ex.Message);
            } catch (Exception ex) {
                MessageService.ShowException(ex, "Solution add exception");
            }
        }
コード例 #6
0
        void AddFileWithParentDirectoriesToSvn(SvnClientWrapper client, string fileName)
        {
            if (!CanBeVersionControlledFile(fileName))
            {
                AddFileWithParentDirectoriesToSvn(client, FileUtility.GetAbsolutePath(fileName, ".."));
            }
            Status status = client.SingleStatus(fileName);

            if (status.TextStatus != StatusKind.Unversioned)
            {
                return;
            }
            client.Add(fileName, Recurse.None);
        }
コード例 #7
0
        private static void FileCopying(object sender, FileRenamingEventArgs e)
        {
            if (e.Cancel)
                return;
            if (!AddInOptions.AutomaticallyRenameFiles)
                return;
            var fullSource = Path.GetFullPath(e.SourceFile);
            if (!LocalHelper.CanBeVersionControlledFile(fullSource))
                return;
            var fullTarget = Path.GetFullPath(e.TargetFile);
            if (!LocalHelper.CanBeVersionControlledFile(fullTarget))
                return;
            try
            {
                using (var client = new SvnClientWrapper())
                {
                    SvnMessageView.HandleNotifications(client);

                    var status = client.SingleStatus(fullSource);
                    switch (status.TextStatus)
                    {
                        case StatusKind.Unversioned:
                        case StatusKind.None:
                            return; // nothing to do
                        case StatusKind.Normal:
                        case StatusKind.Modified:
                        case StatusKind.Replaced:
                        case StatusKind.Added:

                            // copy without problem
                            break;

                        default:
                            MessageService.ShowErrorFormatted("${res:AddIns.Subversion.CannotCopyError}", status.TextStatus.ToString());
                            e.Cancel = true;
                            return;
                    }
                    e.OperationAlreadyDone = true;
                    client.Copy(fullSource, fullTarget);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError("File renamed exception: " + ex);
            }
        }
コード例 #8
0
        /// <summary>
        /// Adds the newly created file to the repository.
        /// </summary>
        /// <param name="sender">Not used.</param>
        /// <param name="e">The name of the file and whether it is a directory or not.</param>
        void FileCreated(object sender, FileEventArgs e)
        {
            if (!AddInOptions.AutomaticallyAddFiles)
            {
                return;
            }
            if (!Path.IsPathRooted(e.FileName))
            {
                return;
            }

            string fullName = Path.GetFullPath(e.FileName);

            if (!CanBeVersionControlledFile(fullName))
            {
                return;
            }
            try {
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    Status status = client.SingleStatus(fullName);
                    switch (status.TextStatus)
                    {
                    case StatusKind.Unversioned:
                    case StatusKind.Deleted:
                        using (SharpDevelop.Gui.AsynchronousWaitDialog.ShowWaitDialog("svn add")) {
                            client.Add(fullName, Recurse.None);
                        }
                        break;
                    }
                }
            } catch (SvnClientException ex) {
                MessageService.ShowError(ex.Message);
            }
        }
コード例 #9
0
        void FileRemoving(object sender, FileCancelEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }
            string fullName = Path.GetFullPath(e.FileName);

            if (!CanBeVersionControlledFile(fullName))
            {
                return;
            }

            if (e.IsDirectory)
            {
                // show "cannot delete directories" message even if
                // AutomaticallyDeleteFiles (see below) is off!
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    try {
                        Status status = client.SingleStatus(fullName);
                        switch (status.TextStatus)
                        {
                        case StatusKind.None:
                        case StatusKind.Unversioned:
                        case StatusKind.Ignored:
                            break;

                        default:
                            // must be done using the subversion client, even if
                            // AutomaticallyDeleteFiles is off, because we don't want to corrupt the
                            // working copy
                            e.OperationAlreadyDone = true;
                            try {
                                client.Delete(new string[] { fullName }, false);
                            } catch (SvnClientException ex) {
                                LoggingService.Warn("SVN Error" + ex);
                                LoggingService.Warn(ex);

                                if (ex.IsKnownError(KnownError.CannotDeleteFileWithLocalModifications) ||
                                    ex.IsKnownError(KnownError.CannotDeleteFileNotUnderVersionControl))
                                {
                                    if (MessageService.ShowCustomDialog("${res:AddIns.Subversion.DeleteDirectory}",
                                                                        StringParser.Parse("${res:AddIns.Subversion.ErrorDelete}:\n",
                                                                                           new StringTagPair("File", fullName)) +
                                                                        ex.Message, 0, 1,
                                                                        "${res:AddIns.Subversion.ForceDelete}", "${res:Global.CancelButtonText}")
                                        == 0)
                                    {
                                        try {
                                            client.Delete(new string[] { fullName }, true);
                                        } catch (SvnClientException ex2) {
                                            e.Cancel = true;
                                            MessageService.ShowError(ex2.Message);
                                        }
                                    }
                                    else
                                    {
                                        e.Cancel = true;
                                    }
                                }
                                else
                                {
                                    e.Cancel = true;
                                    MessageService.ShowError(ex.Message);
                                }
                            }
                            break;
                        }
                    } catch (SvnClientException ex3) {
                        e.Cancel = true;
                        MessageService.ShowError(ex3.Message);
                    }
                }
                return;
            }
            // not a directory, but a file:

            if (!AddInOptions.AutomaticallyDeleteFiles)
            {
                return;
            }
            try {
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    Status status = client.SingleStatus(fullName);
                    switch (status.TextStatus)
                    {
                    case StatusKind.None:
                    case StatusKind.Unversioned:
                    case StatusKind.Ignored:
                    case StatusKind.Deleted:
                        return;                                 // nothing to do

                    case StatusKind.Normal:
                        // remove without problem
                        break;

                    case StatusKind.Modified:
                    case StatusKind.Replaced:
                        if (MessageService.AskQuestion("${res:AddIns.Subversion.RevertLocalModifications}"))
                        {
                            // modified files cannot be deleted, so we need to revert the changes first
                            client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None);
                        }
                        else
                        {
                            e.Cancel = true;
                            return;
                        }
                        break;

                    case StatusKind.Added:
                        if (status.Copied)
                        {
                            if (!MessageService.AskQuestion("${res:AddIns.Subversion.RemoveMovedFile}"))
                            {
                                e.Cancel = true;
                                return;
                            }
                        }
                        client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None);
                        return;

                    default:
                        MessageService.ShowErrorFormatted("${res:AddIns.Subversion.CannotRemoveError}", status.TextStatus.ToString());
                        e.Cancel = true;
                        return;
                    }
                    e.OperationAlreadyDone = true;
                    client.Delete(new string [] { fullName }, true);
                }
            } catch (Exception ex) {
                MessageService.ShowError("File removed exception: " + ex);
            }
        }
コード例 #10
0
		void ProjectCreated(object sender, ProjectEventArgs e)
		{
			if (!AddInOptions.AutomaticallyAddFiles) return;
			if (!CanBeVersionControlledFile(e.Project.Directory)) return;
			
			string projectDir = Path.GetFullPath(e.Project.Directory);
			try {
				using (SvnClientWrapper client = new SvnClientWrapper()) {
					SvnMessageView.HandleNotifications(client);
					
					Status status = client.SingleStatus(projectDir);
					if (status.TextStatus != StatusKind.Unversioned)
						return;
					client.Add(projectDir, Recurse.None);
					if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "bin"), e.Project.OutputAssemblyFullPath)) {
						client.AddToIgnoreList(projectDir, "bin");
					}
					CompilableProject compilableProject = e.Project as CompilableProject;
					if (compilableProject != null) {
						if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "obj"), compilableProject.IntermediateOutputFullPath)) {
							client.AddToIgnoreList(projectDir, "obj");
						}
					}
					foreach (ProjectItem item in e.Project.Items) {
						FileProjectItem fileItem = item as FileProjectItem;
						if (fileItem != null) {
							if (FileUtility.IsBaseDirectory(projectDir, fileItem.FileName)) {
								AddFileWithParentDirectoriesToSvn(client, fileItem.FileName);
							}
						}
					}
					AddFileWithParentDirectoriesToSvn(client, e.Project.FileName);
				}
			} catch (SvnClientException ex) {
				MessageService.ShowError(ex.Message);
			} catch (Exception ex) {
				MessageService.ShowError(ex, "Project add exception");
			}
		}
コード例 #11
0
		void FileRemoving(object sender, FileCancelEventArgs e)
		{
			if (e.Cancel) return;
			string fullName = Path.GetFullPath(e.FileName);
			if (!CanBeVersionControlledFile(fullName)) return;
			
			if (e.IsDirectory) {
				
				// show "cannot delete directories" message even if
				// AutomaticallyDeleteFiles (see below) is off!
				using (SvnClientWrapper client = new SvnClientWrapper()) {
					SvnMessageView.HandleNotifications(client);
					
					Status status = client.SingleStatus(fullName);
					switch (status.TextStatus) {
						case StatusKind.None:
						case StatusKind.Unversioned:
						case StatusKind.Ignored:
							break;
						default:
							// must be done using the subversion client, even if
							// AutomaticallyDeleteFiles is off, because we don't want to corrupt the
							// working copy
							e.OperationAlreadyDone = true;
							try {
								client.Delete(new string[] { fullName }, false);
							} catch (SvnClientException ex) {
								LoggingService.Warn("SVN Error" + ex);
								LoggingService.Warn(ex);
								
								if (ex.IsKnownError(KnownError.CannotDeleteFileWithLocalModifications)
								    || ex.IsKnownError(KnownError.CannotDeleteFileNotUnderVersionControl))
								{
									if (MessageService.ShowCustomDialog("${res:AddIns.Subversion.DeleteDirectory}",
									                                    StringParser.Parse("${res:AddIns.Subversion.ErrorDelete}:\n", new string[,] { { "File", fullName } }) +
									                                    ex.Message, 0, 1,
									                                    "${res:AddIns.Subversion.ForceDelete}", "${res:Global.CancelButtonText}")
									    == 0)
									{
										try {
											client.Delete(new string[] { fullName }, true);
										} catch (SvnClientException ex2) {
											e.Cancel = true;
											MessageService.ShowError(ex2.Message);
										}
									} else {
										e.Cancel = true;
									}
								} else {
									e.Cancel = true;
									MessageService.ShowError(ex.Message);
								}
							}
							break;
					}
				}
				return;
			}
			// not a directory, but a file:
			
			if (!AddInOptions.AutomaticallyDeleteFiles) return;
			try {
				using (SvnClientWrapper client = new SvnClientWrapper()) {
					SvnMessageView.HandleNotifications(client);
					
					Status status = client.SingleStatus(fullName);
					switch (status.TextStatus) {
						case StatusKind.None:
						case StatusKind.Unversioned:
						case StatusKind.Ignored:
						case StatusKind.Deleted:
							return; // nothing to do
						case StatusKind.Normal:
							// remove without problem
							break;
						case StatusKind.Modified:
						case StatusKind.Replaced:
							if (MessageService.AskQuestion("${res:AddIns.Subversion.RevertLocalModifications}")) {
								// modified files cannot be deleted, so we need to revert the changes first
								client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None);
							} else {
								e.Cancel = true;
								return;
							}
							break;
						case StatusKind.Added:
							if (status.Copied) {
								if (!MessageService.AskQuestion("${res:AddIns.Subversion.RemoveMovedFile}")) {
									e.Cancel = true;
									return;
								}
							}
							client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None);
							return;
						default:
							MessageService.ShowErrorFormatted("${res:AddIns.Subversion.CannotRemoveError}", status.TextStatus.ToString());
							e.Cancel = true;
							return;
					}
					e.OperationAlreadyDone = true;
					client.Delete(new string [] { fullName }, true);
				}
			} catch (Exception ex) {
				MessageService.ShowError("File removed exception: " + ex);
			}
		}
コード例 #12
0
		/// <summary>
		/// Adds the newly created file to the repository.
		/// </summary>
		/// <param name="sender">Not used.</param>
		/// <param name="e">The name of the file and whether it is a directory or not.</param>
		void FileCreated(object sender, FileEventArgs e)
		{
			if (!AddInOptions.AutomaticallyAddFiles) return;
			if (!Path.IsPathRooted(e.FileName)) return;
			
			string fullName = Path.GetFullPath(e.FileName);
			if (!CanBeVersionControlledFile(fullName)) return;
			try {
				using (SvnClientWrapper client = new SvnClientWrapper()) {
					SvnMessageView.HandleNotifications(client);
					
					Status status = client.SingleStatus(fullName);
					switch (status.TextStatus) {
						case StatusKind.Unversioned:
						case StatusKind.Deleted:
							using (SharpDevelop.Gui.AsynchronousWaitDialog.ShowWaitDialog("svn add")) {
								client.Add(fullName, Recurse.None);
							}
							break;
					}
				}
			} catch (Exception ex) {
				MessageService.ShowError("File add exception: " + ex);
			}
		}
コード例 #13
0
        void FileRenaming(object sender, FileRenamingEventArgs e)
        {
            if (e.Cancel) return;
            if (!AddInOptions.AutomaticallyRenameFiles) return;
            string fullSource = Path.GetFullPath(e.SourceFile);
            if (!CanBeVersionControlledFile(fullSource)) return;
            if (!FileHelpers.CheckRenameOrReplacePossible(e)) {
                e.Cancel = true;
                return;
            }
            try {
                using (SvnClientWrapper client = new SvnClientWrapper()) {
                    SvnMessageView.HandleNotifications(client);

                    Status status = client.SingleStatus(fullSource);
                    switch (status.TextStatus) {
                        case StatusKind.Unversioned:
                        case StatusKind.None:
                        case StatusKind.Ignored:
                            return; // nothing to do
                        case StatusKind.Normal:
                        case StatusKind.Modified:
                        case StatusKind.Replaced:
                        case StatusKind.Added:
                            // rename without problem
                            break;
                        default:
                            MessageService.ShowErrorFormatted("${res:AddIns.Subversion.CannotMoveError}", status.TextStatus.ToString());
                            e.Cancel = true;
                            return;
                    }
                    e.OperationAlreadyDone = true;
                    client.Move(fullSource,
                                Path.GetFullPath(e.TargetFile),
                                true
                               );
                }
            } catch (Exception ex) {
                MessageService.ShowError("File renamed exception: " + ex);
            }
        }