Commits

Sergey Antonov committed 1b15801

Added additional logging for cmdserver

Comments (0)

Files changed (3)

HgSccHelper/CommandServer/HgClient.cs

 		//-----------------------------------------------------------------------------
 		private bool ReadHello()
 		{
+			Logger.WriteLine("Reading hello message");
+
 			var msg = new Message();
 			server.ReadChannel(ref msg);
 
 			capabilities = new List<string>(caps_list);
 			if (!capabilities.Contains("runcommand"))
 				return false;
-			
+
+			Logger.WriteLine("Hello message is ok");
 			return true;
 		}
 

HgSccHelper/CommandServer/HgCmdServer.cs

 			info.CreateSuspended = true;
 			info.EnvironmentVariables["HGPLAIN"] = "1";
 
+			Logger.WriteLine("Creating new process:");
+			Logger.WriteLine("- Filename         = {0}", info.FileName);
+			Logger.WriteLine("- WorkingDirectory = {0}", work_dir);
+			Logger.WriteLine("- Arguments        = {0}", info.Arguments);
+
 			if (Hg.UseUtf8)
 				info.EnvironmentVariables["HGENCODING"] = "utf8";
 

HgSccHelper/HgScc.cs

 		//-----------------------------------------------------------------------------
 		public SccErrors OpenProject(string local_proj_path, SccOpenProjectFlags flags)
 		{
+			Logger.WriteLine("OpenProject: {0}, flags {1}", local_proj_path, flags);
+
 			var hg = new Hg();
 			string root = hg.Root(local_proj_path);
 			bool is_root_exist = !String.IsNullOrEmpty(root);
 
 			if (!is_root_exist)
 			{
+				Logger.WriteLine("Root not exists");
+
 				if ((flags & SccOpenProjectFlags.CreateIfNew) == SccOpenProjectFlags.CreateIfNew)
 				{
+					Logger.WriteLine("Creating a repository: {0}", local_proj_path);
+
 					if (!hg.CreateRepository(local_proj_path))
 						return SccErrors.CouldNotCreateProject;
 
+					Logger.WriteLine("Repository created");
 					root = local_proj_path;
 				}
 				else
 			string hgsubPath = Path.Combine(root, ".hgsub");
 			if (File.Exists(hgsubPath))
 			{
+				Logger.WriteLine("Found .hgsub");
 				using (StreamReader reader = new StreamReader(hgsubPath))
 				{
 					while (!reader.EndOfStream)
 				}
 			}
 
-			if (!hg_client.Open(WorkingDir))
+			try
 			{
-				Logger.WriteLine("Unable to connect to command server: {0}", WorkingDir);
-				hg_client.Dispose();
+				Logger.WriteLine("Opening a command server client: {0}", local_proj_path);
+				if (!hg_client.Open(WorkingDir))
+				{
+					Logger.WriteLine("Unable to connect to command server: {0}", WorkingDir);
+					hg_client.Dispose();
 
-				return SccErrors.NonSpecificError;
+					return SccErrors.NonSpecificError;
+				}
+			}
+			catch (Exception ex)
+			{
+				Logger.WriteLine("Exception : {0}", ex.Message);
+				Logger.WriteLine("StackTrace: {0}", ex.StackTrace);
+				throw;
 			}
 
 			return SccErrors.Ok;