Fehlerbehebung
This commit is contained in:
parent
c5f7243285
commit
1dd219dc40
@ -12,7 +12,9 @@ namespace svnsync.Controllers
|
||||
{
|
||||
private static ViewsTray viewTray;
|
||||
private static ControllersWindow controllerWindow;
|
||||
private string args;
|
||||
//private string args;
|
||||
public delegate void _enableLoopRun();
|
||||
public event _enableLoopRun StartLoop;
|
||||
|
||||
/// <summary>
|
||||
/// Controlls a Tray.
|
||||
@ -28,13 +30,24 @@ namespace svnsync.Controllers
|
||||
viewTray.ShowSuccess();
|
||||
System.Threading.Thread.Sleep(5000);
|
||||
viewTray.Dispose();
|
||||
return;
|
||||
} else {
|
||||
this.StartLoop();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
controllerWindow.execute();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
if(viewTray != null) {
|
||||
viewTray.Dispose();
|
||||
}
|
||||
if(controllerWindow != null) {
|
||||
controllerWindow.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private bool cronJob(int run, bool readyToCommit) {
|
||||
if(viewTray.Model.Svn == null) {
|
||||
return HandleError(Handles.SvnType.NotInit, "");
|
||||
@ -48,7 +61,7 @@ namespace svnsync.Controllers
|
||||
try {
|
||||
viewTray.Model.Svn.CheckStatus();
|
||||
} catch(NotImplementedException e) {
|
||||
return HandleError(Handles.SvnType.UnexpectedError, e.Message);
|
||||
return HandleError(Handles.SvnType.UnexpectedError, e.Message, e.StackTrace);
|
||||
} catch(Helpers.SvnLockedException e) {
|
||||
return HandleError(Handles.SvnType.LockedFile, e.Message);
|
||||
}
|
||||
@ -91,7 +104,7 @@ namespace svnsync.Controllers
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool HandleError(Handles.SvnType svnType, string p) {
|
||||
private bool HandleError(Handles.SvnType svnType, string p, string p1 = "") {
|
||||
viewTray.ShowError(svnType, p);
|
||||
switch(svnType) {
|
||||
case Handles.SvnType.ToMutchChronRuns:
|
||||
@ -102,7 +115,7 @@ namespace svnsync.Controllers
|
||||
break;
|
||||
case Handles.SvnType.UnexpectedError:
|
||||
controllerWindow.setAction(Handles.FormType.Error);
|
||||
controllerWindow.setMessage(p);
|
||||
controllerWindow.setMessage(p+" "+p1);
|
||||
break;
|
||||
case Handles.SvnType.ExternDeletedFiles:
|
||||
controllerWindow.setAction(Handles.FormType.DeletedFiles);
|
||||
|
@ -24,6 +24,11 @@ namespace svnsync.Controllers {
|
||||
viewWindow.Model.FormType = initAction;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
if(viewWindow != null)
|
||||
viewWindow.Dispose();
|
||||
}
|
||||
|
||||
public static void FormClosed(object sender, FormClosedEventArgs e) {
|
||||
viewWindow.Dispose();
|
||||
}
|
||||
|
@ -4,225 +4,182 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace svnsync.Libraries
|
||||
{
|
||||
class Svn
|
||||
{
|
||||
private string dir;
|
||||
private Process p = new Process();
|
||||
private List<String> modified;
|
||||
private List<String> noversion;
|
||||
private List<String> wasdeleted;
|
||||
private List<String> added;
|
||||
private string SvnError = "";
|
||||
private string SvnOutput = "";
|
||||
private List<string> isdeleted;
|
||||
private List<string> external;
|
||||
private static Svn instances;
|
||||
namespace svnsync.Libraries {
|
||||
class Svn {
|
||||
private string dir;
|
||||
private Process p = new Process();
|
||||
private List<String> modified;
|
||||
private List<String> noversion;
|
||||
private List<String> wasdeleted;
|
||||
private List<String> added;
|
||||
private string SvnError = "";
|
||||
private string SvnOutput = "";
|
||||
private List<string> isdeleted;
|
||||
private List<string> external;
|
||||
private static Svn instances;
|
||||
|
||||
private Svn() { }
|
||||
private Svn() { }
|
||||
|
||||
public void setDirectory(string dir)
|
||||
{
|
||||
this.dir = dir;
|
||||
this.Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
p.StartInfo.FileName = "svn";
|
||||
p.StartInfo.WorkingDirectory = this.dir;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.RedirectStandardError = true;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
}
|
||||
|
||||
internal void CheckStatus()
|
||||
{
|
||||
modified = new List<string>();
|
||||
noversion = new List<string>();
|
||||
wasdeleted = new List<string>();
|
||||
isdeleted = new List<string>();
|
||||
added = new List<string>();
|
||||
external = new List<string>();
|
||||
this.runner("st");
|
||||
string[] lines = this.SvnOutput.Split('\n');
|
||||
foreach (String line in lines)
|
||||
{
|
||||
if (line.Length < 7)
|
||||
break;
|
||||
Char[] handles = line.Substring(0, 7).ToCharArray();
|
||||
String file = line.Substring(8).Trim(new Char[] {'\r','\n',' ','\t'});
|
||||
if (handles[0] == ' ')
|
||||
{
|
||||
if(handles[2] == 'L') {
|
||||
throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!");
|
||||
} else {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '");
|
||||
}
|
||||
}
|
||||
else if (handles[0] == 'A')
|
||||
{
|
||||
added.Add(file);
|
||||
}
|
||||
else if (handles[0] == 'D')
|
||||
{
|
||||
isdeleted.Add(file);
|
||||
}
|
||||
else if (handles[0] == 'M')
|
||||
{
|
||||
modified.Add(file);
|
||||
}
|
||||
else if (handles[0] == 'R')
|
||||
{
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'R'");
|
||||
}
|
||||
else if (handles[0] == 'C')
|
||||
{
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'");
|
||||
}
|
||||
else if (handles[0] == 'X')
|
||||
{
|
||||
external.Add(file);
|
||||
}
|
||||
else if (handles[0] == 'I')
|
||||
{
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'");
|
||||
}
|
||||
else if (handles[0] == '?')
|
||||
{
|
||||
noversion.Add(file);
|
||||
}
|
||||
else if (handles[0] == '!')
|
||||
{
|
||||
wasdeleted.Add(file);
|
||||
}
|
||||
else if (handles[0] == '~')
|
||||
{
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNotOnlyModified()
|
||||
{
|
||||
if (this.noversion.Count != 0)
|
||||
return true;
|
||||
if (this.wasdeleted.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void SetArgCheckIn(string message)
|
||||
{
|
||||
String arg = "ci -m \"" + message + "\"";
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
internal void AddFiles(List<String> files)
|
||||
{
|
||||
String arg = "add";
|
||||
foreach (String item in files)
|
||||
{
|
||||
arg += " \"" + item+"\"";
|
||||
}
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
private void runner(string arg)
|
||||
{
|
||||
this.SvnOutput = "";
|
||||
this.SvnError = "";
|
||||
p.StartInfo.Arguments = arg;
|
||||
p.Start();
|
||||
this.SvnOutput = p.StandardOutput.ReadToEnd();
|
||||
this.SvnError = p.StandardError.ReadToEnd();
|
||||
p.WaitForExit();
|
||||
}
|
||||
|
||||
internal bool IsUncheckedFiles()
|
||||
{
|
||||
if (this.noversion.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool IsExternDeletedFiles()
|
||||
{
|
||||
if (this.wasdeleted.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool IsError()
|
||||
{
|
||||
if (this.SvnError != "")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal string getError()
|
||||
{
|
||||
return this.SvnError;
|
||||
}
|
||||
|
||||
internal void DeleteFiles(List<String> files)
|
||||
{
|
||||
String arg = "del";
|
||||
foreach (String item in files)
|
||||
{
|
||||
arg += " \"" + item + "\"";
|
||||
}
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
internal List<String> getWasDeletedFiles()
|
||||
{
|
||||
return this.wasdeleted;
|
||||
}
|
||||
|
||||
internal List<String> getNoVersionFiles()
|
||||
{
|
||||
return this.noversion;
|
||||
}
|
||||
|
||||
internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l)
|
||||
{
|
||||
List<String> s = new List<string>();
|
||||
foreach (System.Windows.Forms.TreeNode item in l)
|
||||
{
|
||||
s.Add(item.FullPath);
|
||||
}
|
||||
this.DeleteFiles(s);
|
||||
}
|
||||
|
||||
internal void AddFiles(List<System.Windows.Forms.TreeNode> l)
|
||||
{
|
||||
List<String> s = new List<string>();
|
||||
foreach (System.Windows.Forms.TreeNode item in l)
|
||||
{
|
||||
s.Add(item.FullPath);
|
||||
}
|
||||
this.AddFiles(s);
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
this.runner("up");
|
||||
}
|
||||
|
||||
public static Svn getInstance()
|
||||
{
|
||||
if (instances == null)
|
||||
{
|
||||
instances = new Svn();
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
public void setDirectory(string dir) {
|
||||
this.dir = dir;
|
||||
this.Init();
|
||||
}
|
||||
|
||||
private void Init() {
|
||||
p.StartInfo.FileName = "svn";
|
||||
p.StartInfo.WorkingDirectory = this.dir;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.RedirectStandardError = true;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
}
|
||||
|
||||
internal void CheckStatus() {
|
||||
modified = new List<string>();
|
||||
noversion = new List<string>();
|
||||
wasdeleted = new List<string>();
|
||||
isdeleted = new List<string>();
|
||||
added = new List<string>();
|
||||
external = new List<string>();
|
||||
this.runner("st");
|
||||
string[] lines = this.SvnOutput.Split('\n');
|
||||
foreach(String line in lines) {
|
||||
if(line.Length < 7)
|
||||
break;
|
||||
Char[] handles = line.Substring(0, 7).ToCharArray();
|
||||
String file = line.Substring(8).Trim(new Char[] { '\r', '\n', ' ', '\t' });
|
||||
if(handles[0] == ' ') {
|
||||
if(handles[2] == 'L') {
|
||||
throw new svnsync.Helpers.SvnLockedException("Datei: " + file + " ist gelockt!");
|
||||
}
|
||||
//Modifizierte Eigenschaft
|
||||
else if(handles[1] == 'M') {
|
||||
modified.Add(file);
|
||||
} else {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] ' '");
|
||||
}
|
||||
} else if(handles[0] == 'A') {
|
||||
added.Add(file);
|
||||
} else if(handles[0] == 'D') {
|
||||
isdeleted.Add(file);
|
||||
}
|
||||
// Modifizierte Datei
|
||||
else if(handles[0] == 'M') {
|
||||
modified.Add(file);
|
||||
} else if(handles[0] == 'R') {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'R'");
|
||||
} else if(handles[0] == 'C') {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'C'");
|
||||
} else if(handles[0] == 'X') {
|
||||
external.Add(file);
|
||||
} else if(handles[0] == 'I') {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] 'I'");
|
||||
} else if(handles[0] == '?') {
|
||||
noversion.Add(file);
|
||||
} else if(handles[0] == '!') {
|
||||
wasdeleted.Add(file);
|
||||
} else if(handles[0] == '~') {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: SVN Line[0] '~'");
|
||||
} else {
|
||||
throw new NotImplementedException("NOT IMPLEMENTED in SvnClass: Unexpected Symbol! [0]: \"" + handles[0] + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNotOnlyModified() {
|
||||
if(this.noversion.Count != 0)
|
||||
return true;
|
||||
if(this.wasdeleted.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void SetArgCheckIn(string message) {
|
||||
String arg = "ci -m \"" + message + "\"";
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
internal void AddFiles(List<String> files) {
|
||||
String arg = "add";
|
||||
foreach(String item in files) {
|
||||
arg += " \"" + item + "\"";
|
||||
}
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
private void runner(string arg) {
|
||||
this.SvnOutput = "";
|
||||
this.SvnError = "";
|
||||
p.StartInfo.Arguments = arg;
|
||||
p.Start();
|
||||
this.SvnOutput = p.StandardOutput.ReadToEnd();
|
||||
this.SvnError = p.StandardError.ReadToEnd();
|
||||
p.WaitForExit();
|
||||
}
|
||||
|
||||
internal bool IsUncheckedFiles() {
|
||||
if(this.noversion.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool IsExternDeletedFiles() {
|
||||
if(this.wasdeleted.Count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool IsError() {
|
||||
if(this.SvnError != "")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal string getError() {
|
||||
return this.SvnError;
|
||||
}
|
||||
|
||||
internal void DeleteFiles(List<String> files) {
|
||||
String arg = "del";
|
||||
foreach(String item in files) {
|
||||
arg += " \"" + item + "\"";
|
||||
}
|
||||
this.runner(arg);
|
||||
}
|
||||
|
||||
internal List<String> getWasDeletedFiles() {
|
||||
return this.wasdeleted;
|
||||
}
|
||||
|
||||
internal List<String> getNoVersionFiles() {
|
||||
return this.noversion;
|
||||
}
|
||||
|
||||
internal void DeleteFiles(List<System.Windows.Forms.TreeNode> l) {
|
||||
List<String> s = new List<string>();
|
||||
foreach(System.Windows.Forms.TreeNode item in l) {
|
||||
s.Add(item.FullPath);
|
||||
}
|
||||
this.DeleteFiles(s);
|
||||
}
|
||||
|
||||
internal void AddFiles(List<System.Windows.Forms.TreeNode> l) {
|
||||
List<String> s = new List<string>();
|
||||
foreach(System.Windows.Forms.TreeNode item in l) {
|
||||
s.Add(item.FullPath);
|
||||
}
|
||||
this.AddFiles(s);
|
||||
}
|
||||
|
||||
internal void Update() {
|
||||
this.runner("up");
|
||||
}
|
||||
|
||||
public static Svn getInstance() {
|
||||
if(instances == null) {
|
||||
instances = new Svn();
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace svnsync
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
private static bool LoopStarted = false;
|
||||
/// <summary>
|
||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||
/// </summary>
|
||||
@ -22,6 +23,7 @@ namespace svnsync
|
||||
try {
|
||||
Svn.getInstance().setDirectory(CmdArgs.getInstance().GetArgumentData("-d"));
|
||||
t = new ControllersTray();
|
||||
t.StartLoop += t_StartLoop;
|
||||
t.execute();
|
||||
} catch(Exception e) {
|
||||
t.hideToolTip();
|
||||
@ -32,20 +34,28 @@ namespace svnsync
|
||||
return;
|
||||
}
|
||||
if(!CmdArgs.getInstance().HasArgumentType("-cron")) {
|
||||
Application.Run();
|
||||
t_StartLoop();
|
||||
}
|
||||
return;
|
||||
/*Application.Run();*/
|
||||
Application.EnableVisualStyles();
|
||||
/*Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
try {
|
||||
Application.Run(new Form1(args));
|
||||
} catch(NotImplementedException e) {
|
||||
System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
} catch(Exception /*e*/) {
|
||||
} catch(Exception e) {
|
||||
//System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}*/
|
||||
}
|
||||
|
||||
static void t_StartLoop() {
|
||||
if(!LoopStarted) {
|
||||
LoopStarted = true;
|
||||
Application.Run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static bool cmd(string[] args)
|
||||
|
@ -11,7 +11,7 @@ using System.Resources;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("BlubbFish")]
|
||||
[assembly: AssemblyProduct("SvnSync")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 - 2014")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 - 03.12.2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -33,6 +33,6 @@ using System.Resources;
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
[assembly: AssemblyVersion("1.0.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.2.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("de-DE")]
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user