Commit MetaInfo

Revision0ae212efee4d30d047156bdc3042d03c7b7e8b1c (tree)
Time2009-08-28 04:03:07
AuthorFace
CommiterFace

Log Message

Made application updatable.

Change Summary

Incremental Difference

diff -r 3dbb52a83a98 -r 0ae212efee4d COIClient.exe
Binary file COIClient.exe has changed
diff -r 3dbb52a83a98 -r 0ae212efee4d src/COIClient/ClientForm.cs
--- a/src/COIClient/ClientForm.cs Thu Aug 27 20:01:35 2009 +0200
+++ b/src/COIClient/ClientForm.cs Thu Aug 27 21:03:07 2009 +0200
@@ -1,5 +1,6 @@
11 using System;
22 using System.Collections.Generic;
3+using System.Diagnostics;
34 using System.IO;
45 using System.Windows.Forms;
56 using System.Xml.Serialization;
@@ -243,10 +244,10 @@
243244 statusLabel.Text = "Loading database";
244245 statusLabel.Visible = true;
245246
246- new MethodInvoker(ExamineLocal).BeginInvoke(click_Ready, Caller.ExamineLocal);
247+ new MethodInvoker(ExamineLocal).BeginInvoke(ClickReady, Caller.ExamineLocal);
247248 }
248249
249- private void click_Ready(IAsyncResult ar)
250+ private void ClickReady(IAsyncResult ar)
250251 {
251252 if (ar.AsyncState is Caller) ClickFinisher((Caller) ar.AsyncState);
252253 }
@@ -274,11 +275,11 @@
274275 case Caller.Download:
275276 localModel.Clear();
276277 database.Clear();
277- new MethodInvoker(ExamineLocal).BeginInvoke(click_Ready, Caller.DownloadExamineLocal);
278+ new MethodInvoker(ExamineLocal).BeginInvoke(ClickReady, Caller.DownloadExamineLocal);
278279 break;
279280 case Caller.DownloadExamineLocal:
280281 remoteModel.Clear();
281- new MethodInvoker(GetRemoteList).BeginInvoke(click_Ready, Caller.DownloadExamineLocalExamineRemote);
282+ new MethodInvoker(GetRemoteList).BeginInvoke(ClickReady, Caller.DownloadExamineLocalExamineRemote);
282283 break;
283284 case Caller.DownloadExamineLocalExamineRemote:
284285 localTree.Model = null;
@@ -503,7 +504,7 @@
503504 else
504505 {
505506 prepare.Invoke();
506- if (ok) method.BeginInvoke(click_Ready, Caller.ExamineRemote);
507+ if (ok) method.BeginInvoke(ClickReady, Caller.ExamineRemote);
507508 else ClickFinisher(Caller.ExamineRemote);
508509 }
509510 }
@@ -521,7 +522,8 @@
521522 "Remote COI", MessageBoxButtons.OK, MessageBoxIcon.Error)));
522523 return;
523524 }
524- var revision = call.StandardOutput.ReadLine();
525+ string revision=null;
526+ while (!call.StandardOutput.EndOfStream) revision = call.StandardOutput.ReadLine();
525527
526528 //Pull from repo
527529 call = new Executor("pull -r " + revision + " \"" + remoteDatabaseRepo + '"', databaseRepo, handle);
@@ -654,7 +656,7 @@
654656 statusLabel.Text = "Checking selection";
655657 statusLabel.Visible = true;
656658
657- new MethodInvoker(Process).BeginInvoke(click_Ready, Caller.Process);
659+ new MethodInvoker(Process).BeginInvoke(ClickReady, Caller.Process);
658660 }
659661
660662 private void Process()
@@ -727,6 +729,29 @@
727729 return;
728730 }
729731
732+ if (localPath==Path.GetDirectoryName(Application.ExecutablePath))
733+ { //Special behaviour processing COIClient's own COI
734+
735+ //Create temporary batchfile
736+ var batchfile = Path.GetTempFileName();
737+ File.Delete(batchfile);
738+ batchfile += ".bat";
739+ using (var batchStream = new StreamWriter(batchfile, false))
740+ batchStream.WriteLine("@echo off\nping 127.0.0.1 -n 2 -w 1000 > nul\nhg update -C "+selection[0].Revision+"\nstart COIClient.exe");
741+
742+ //Call batchfile and quit
743+ var updater = new Process
744+ {
745+ StartInfo = new ProcessStartInfo(batchfile)
746+ {
747+ UseShellExecute = true,
748+ WorkingDirectory = localPath
749+ }
750+ };
751+ updater.Start();
752+ Close();
753+ }
754+
730755 //Just one top-level addon
731756 call = new Executor("update -vC " + selection[0].Revision, localPath, handle);
732757 call.OutputLineRead += status;
@@ -891,7 +916,7 @@
891916 statusLabel.Text = "Downloading selection";
892917 statusLabel.Visible = true;
893918
894- new MethodInvoker(Download).BeginInvoke(click_Ready, Caller.Download);
919+ new MethodInvoker(Download).BeginInvoke(ClickReady, Caller.Download);
895920 }
896921
897922 private void Download()
@@ -1061,7 +1086,7 @@
10611086 statusLabel.Text = "";
10621087 statusLabel.Visible = true;
10631088
1064- new MethodInvoker(AddAddon).BeginInvoke(click_Ready, Caller.ExamineLocal);
1089+ new MethodInvoker(AddAddon).BeginInvoke(ClickReady, Caller.ExamineLocal);
10651090 }
10661091
10671092 private void AddAddon()
Show on old repository browser