mal weiter gemacht
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user