コード例 #1
0
		// NOTE: This is called separately for the file and its meta.
		private static void OnWillCreateAsset(string path)
		{
			if (!Enabled || TemporaryDisabled)
				return;

			var pathStatusData = GetStatus(path);
			if (pathStatusData.Status == VCFileStatus.Deleted) {

				var isMeta = path.EndsWith(".meta");

				if (!isMeta && !Silent) {
					EditorUtility.DisplayDialog(
						"Deleted file",
						$"The desired location\n\"{path}\"\nis marked as deleted in SVN. The file will be replaced in SVN with the new one.\n\nIf this is an automated change, consider adding this file to the exclusion list in the project preferences:\n\"{WiseSVNProjectPreferencesWindow.PROJECT_PREFERENCES_MENU}\"\n...or change your tool to silence the integration.",
						"Replace");
				}

				using (var reporter = CreateLogger()) {
					// File isn't still created, so we need to improvise.
					reporter.Result = ShellUtils.ExecuteCommand(SVN_Command, $"revert \"{SVNFormatPath(path)}\"", COMMAND_TIMEOUT, reporter);
					File.Delete(path);
				}
			}
		}
コード例 #2
0
		// Ask the repository server for lock details of the specified file.
		public static LockDetails FetchLockDetails(string path, int timeout = COMMAND_TIMEOUT, bool raiseError = false)
		{
			string url;
			LockDetails lockDetails = LockDetails.Empty;

			//
			// Find the repository url of the path.
			// We need to call "svn info [repo-url]" in order to get up to date repository information.
			// NOTE: Project url can be cached and prepended to path, but externals may have different base url.
			//
			{
				var result = ShellUtils.ExecuteCommand(SVN_Command, $"info \"{SVNFormatPath(path)}\"", timeout);

				url = ExtractLineValue("URL:", result.output);

				if (!string.IsNullOrEmpty(result.error) || string.IsNullOrEmpty(url)) {

					if (!raiseError || Silent)
						return lockDetails;

					var displayMessage = $"Failed to get info for \"{path}\".\n{result.output}\n{result.error}";
					if (m_LastDisplayedError != displayMessage) {
						Debug.LogError($"{displayMessage}\n\n{result.error}");
						m_LastDisplayedError = displayMessage;
						EditorUtility.DisplayDialog("SVN Error", displayMessage, "I will!");
					}


					return lockDetails;
				}
			}

			//
			// Get the actual owner from the repository (using the url).
			//
			{
				var result = ShellUtils.ExecuteCommand(SVN_Command, $"info \"{SVNFormatPath(url)}\"", timeout);

				lockDetails.Owner = ExtractLineValue("Lock Owner:", result.output);

				if (!string.IsNullOrEmpty(result.error) || string.IsNullOrEmpty(lockDetails.Owner)) {

					// Owner will be missing if there is no lock. If true, just find something familiar to confirm it was not an error.
					if (result.output.IndexOf("URL:", StringComparison.OrdinalIgnoreCase) != -1) {
						lockDetails.Path = path;	// LockDetails is still valid, just no lock.
						return lockDetails;
					}

					if (!raiseError || Silent)
						return lockDetails;

					var displayMessage = $"Failed to get lock details for \"{path}\".\n{result.output}\n{result.error}";
					if (m_LastDisplayedError != displayMessage) {
						Debug.LogError($"{displayMessage}\n\n{result.error}");
						m_LastDisplayedError = displayMessage;
						EditorUtility.DisplayDialog("SVN Error", displayMessage, "I will!");
					}

					return lockDetails;
				}

				lockDetails.Path = path;
				lockDetails.Date = ExtractLineValue("Lock Created:", result.output);

				// Locked message looks like this:
				// Lock Comment (4 lines):
				// Foo
				// Bar
				// ...
				// The number of lines is arbitrary. If there is no comment, this section is omitted.
				var lockMessageLineIndex = result.output.IndexOf("Lock Comment", StringComparison.OrdinalIgnoreCase);
				if (lockMessageLineIndex != -1) {
					var lockMessageStart = result.output.IndexOf("\n", lockMessageLineIndex, StringComparison.OrdinalIgnoreCase) + 1;
					lockDetails.Message = result.output.Substring(lockMessageStart).Replace("\r", "");
					// F**k '\r'
				}
			}

			return lockDetails;
		}