config: add url as part of the folder config xml

This commit is contained in:
Hylke Bons 2011-05-26 23:41:55 +01:00
parent 15073bb5b3
commit 10ac5cbe5c
6 changed files with 21 additions and 44 deletions

View file

@ -29,18 +29,6 @@ namespace SparkleLib {
base (path, backend) { }
public override string Url {
get {
SparkleGit git = new SparkleGit (LocalPath, "config --get remote.origin.url");
git.Start ();
git.WaitForExit ();
string output = git.StandardOutput.ReadToEnd ();
return output.TrimEnd ();
}
}
public override string Identifier {
get {

View file

@ -29,23 +29,6 @@ namespace SparkleLib {
base (path, backend) { }
public override string Url {
get {
string repo_config_file_path = SparkleHelpers.CombineMore (LocalPath, ".hg", "hgrc");
Regex regex = new Regex (@"default = (.+)");
foreach (string line in File.ReadAllLines (repo_config_file_path)) {
Match match = regex.Match (line);
if (match.Success)
return match.Groups [1].Value.TrimEnd ();
}
return null;
}
}
public override string Identifier {
get {
SparkleHg hg = new SparkleHg (LocalPath, "log -r : --limit 1 --template \"{node}\"");

View file

@ -29,13 +29,6 @@ namespace SparkleLib {
base (path, backend) { }
public override string Url {
get {
return "";
}
}
public override string Identifier {
get {
return "sparkles";

View file

@ -121,17 +121,20 @@ namespace SparkleLib {
}
public void AddFolder (string name, string backend)
public void AddFolder (string name, string url, string backend)
{
XmlNode node_folder = CreateNode (XmlNodeType.Element, "folder", null);
XmlNode node_name = CreateElement ("name");
node_name.InnerText = name;
XmlNode node_url = CreateElement ("url");
node_url.InnerText = url;
XmlNode node_backend = CreateElement ("backend");
node_backend.InnerText = backend;
XmlNode node_folder = CreateNode (XmlNodeType.Element, "folder", null);
node_folder.AppendChild (node_name);
node_folder.AppendChild (node_url);
node_folder.AppendChild (node_backend);
XmlNode node_root = SelectSingleNode ("/sparkleshare");
@ -174,6 +177,17 @@ namespace SparkleLib {
}
public string GetUrlForFolder (string name)
{
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
if (node_folder ["name"].InnerText.Equals (name))
return node_folder ["url"].InnerText;
}
return null;
}
public string GetConfigOption (string name)
{
XmlNode node = SelectSingleNode ("/sparkleshare/" + name);

View file

@ -51,7 +51,6 @@ namespace SparkleLib {
private bool has_changed = false;
private Object change_lock = new Object ();
public abstract string Url { get; }
public abstract bool AnyDifferences { get; }
public abstract string Identifier { get; }
public abstract string CurrentRevision { get; }
@ -72,7 +71,6 @@ namespace SparkleLib {
public event ChangesDetectedEventHandler ChangesDetected;
// TODO: constructor (path, url, backend)
public SparkleRepoBase (string path, SparkleBackend backend)
{
LocalPath = path;
@ -154,7 +152,7 @@ namespace SparkleLib {
public string Domain {
get {
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)(/|:)");
Match match = regex.Match (Url);
Match match = regex.Match (SparkleConfig.DefaultConfig.GetUrlForFolder (Name));
if (match.Success)
return match.Groups [2].Value;
@ -193,7 +191,8 @@ namespace SparkleLib {
public string RemoteName {
get {
return Path.GetFileNameWithoutExtension (Url);
string url = SparkleConfig.DefaultConfig.GetUrlForFolder (Name);
return Path.GetFileNameWithoutExtension (url);
}
}

View file

@ -970,7 +970,7 @@ namespace SparkleShare {
}
SparkleConfig.DefaultConfig.AddFolder (target_folder_name, backend);
SparkleConfig.DefaultConfig.AddFolder (target_folder_name, url, backend);
AddRepository (target_folder_path);
if (FolderFetched != null)