history: fix some edge cases and general improvements
This commit is contained in:
parent
651033b9b8
commit
3c74466898
|
@ -555,6 +555,7 @@ namespace SparkleLib.Git {
|
||||||
throw new ArgumentNullException ("revision");
|
throw new ArgumentNullException ("revision");
|
||||||
|
|
||||||
path = path.Replace ("\\", "/");
|
path = path.Replace ("\\", "/");
|
||||||
|
|
||||||
SparkleLogger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")");
|
SparkleLogger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")");
|
||||||
|
|
||||||
// FIXME: git-show doesn't decrypt objects, so we can't use it to retrieve
|
// FIXME: git-show doesn't decrypt objects, so we can't use it to retrieve
|
||||||
|
@ -581,9 +582,7 @@ namespace SparkleLib.Git {
|
||||||
|
|
||||||
// The correct way
|
// The correct way
|
||||||
} else {
|
} else {
|
||||||
path = path.Replace (" ", "\\ ");
|
SparkleGit git = new SparkleGit (LocalPath, "show " + revision + ":\"" + path + "\"");
|
||||||
|
|
||||||
SparkleGit git = new SparkleGit (LocalPath, "show " + revision + ":" + path + "");
|
|
||||||
git.Start ();
|
git.Start ();
|
||||||
|
|
||||||
FileStream stream = File.OpenWrite (target_file_path);
|
FileStream stream = File.OpenWrite (target_file_path);
|
||||||
|
|
|
@ -220,9 +220,8 @@ namespace SparkleLib {
|
||||||
"Any files you add or change in this folder will be automatically synced to " + n +
|
"Any files you add or change in this folder will be automatically synced to " + n +
|
||||||
uri_builder.ToString () + " and everyone connected to it." + n +
|
uri_builder.ToString () + " and everyone connected to it." + n +
|
||||||
n +
|
n +
|
||||||
"SparkleShare is an Open Source software program that helps people " + n +
|
"SparkleShare is an Open Source software program that helps people collaborate and " + n +
|
||||||
"collaborate and share files. If you like what we do, please consider a small " + n +
|
"share files. If you like what we do, consider buying us a beer: http://www.sparkleshare.org/" + n +
|
||||||
"donation to support the project: http://www.sparkleshare.org/" + n +
|
|
||||||
n +
|
n +
|
||||||
"Have fun! :)" + n;
|
"Have fun! :)" + n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@
|
||||||
|
|
||||||
td.name {
|
td.name {
|
||||||
width: 45%;
|
width: 45%;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.time {
|
td.time {
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
private string selected_folder;
|
private string selected_folder;
|
||||||
private RevisionInfo restore_revision_info;
|
private RevisionInfo restore_revision_info;
|
||||||
|
private bool history_view_active;
|
||||||
|
|
||||||
|
|
||||||
public bool WindowIsOpen { get; private set; }
|
public bool WindowIsOpen { get; private set; }
|
||||||
|
@ -62,10 +63,10 @@ namespace SparkleShare {
|
||||||
ContentLoadingEvent ();
|
ContentLoadingEvent ();
|
||||||
UpdateSizeInfoEvent ("…", "…");
|
UpdateSizeInfoEvent ("…", "…");
|
||||||
|
|
||||||
|
new Thread (() => {
|
||||||
Stopwatch watch = new Stopwatch ();
|
Stopwatch watch = new Stopwatch ();
|
||||||
watch.Start ();
|
watch.Start ();
|
||||||
|
|
||||||
new Thread (() => {
|
|
||||||
string html = HTML;
|
string html = HTML;
|
||||||
watch.Stop ();
|
watch.Stop ();
|
||||||
|
|
||||||
|
@ -85,6 +86,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string HTML {
|
public string HTML {
|
||||||
get {
|
get {
|
||||||
|
this.history_view_active = false;
|
||||||
|
|
||||||
List<SparkleChangeSet> change_sets = GetLog (this.selected_folder);
|
List<SparkleChangeSet> change_sets = GetLog (this.selected_folder);
|
||||||
string html = GetHTMLLog (change_sets);
|
string html = GetHTMLLog (change_sets);
|
||||||
|
|
||||||
|
@ -178,6 +181,9 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.Controller.OnIdle += delegate {
|
Program.Controller.OnIdle += delegate {
|
||||||
|
if (this.history_view_active)
|
||||||
|
return;
|
||||||
|
|
||||||
ContentLoadingEvent ();
|
ContentLoadingEvent ();
|
||||||
UpdateSizeInfoEvent ("…", "…");
|
UpdateSizeInfoEvent ("…", "…");
|
||||||
|
|
||||||
|
@ -228,18 +234,21 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
} else if (url.StartsWith ("restore://") && this.restore_revision_info == null) {
|
} else if (url.StartsWith ("restore://") && this.restore_revision_info == null) {
|
||||||
Regex regex = new Regex ("restore://(.+)/([a-f0-9]+)/(.+)", RegexOptions.Compiled);
|
Regex regex = new Regex ("restore://(.+)/([a-f0-9]+)/(.+)/(.{3} [0-9]+ [0-9]+h[0-9]+)/(.+)", RegexOptions.Compiled);
|
||||||
Match match = regex.Match (url);
|
Match match = regex.Match (url);
|
||||||
|
|
||||||
if (match.Success) {
|
if (match.Success) {
|
||||||
|
string author_name = match.Groups [3].Value;
|
||||||
|
string timestamp = match.Groups [4].Value;
|
||||||
|
|
||||||
this.restore_revision_info = new RevisionInfo () {
|
this.restore_revision_info = new RevisionInfo () {
|
||||||
Folder = new SparkleFolder (match.Groups [1].Value),
|
Folder = new SparkleFolder (match.Groups [1].Value),
|
||||||
Revision = match.Groups [2].Value,
|
Revision = match.Groups [2].Value,
|
||||||
FilePath = match.Groups [3].Value
|
FilePath = match.Groups [5].Value
|
||||||
};
|
};
|
||||||
|
|
||||||
string file_name = Path.GetFileNameWithoutExtension (this.restore_revision_info.FilePath) +
|
string file_name = Path.GetFileNameWithoutExtension (this.restore_revision_info.FilePath) +
|
||||||
" (restored)" + Path.GetExtension (this.restore_revision_info.FilePath);
|
" (" + author_name + " " + timestamp + ")" + Path.GetExtension (this.restore_revision_info.FilePath);
|
||||||
|
|
||||||
string target_folder_path = Path.Combine (this.restore_revision_info.Folder.FullPath,
|
string target_folder_path = Path.Combine (this.restore_revision_info.Folder.FullPath,
|
||||||
Path.GetDirectoryName (this.restore_revision_info.FilePath));
|
Path.GetDirectoryName (this.restore_revision_info.FilePath));
|
||||||
|
@ -253,6 +262,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
} else if (url.StartsWith ("history://")) {
|
} else if (url.StartsWith ("history://")) {
|
||||||
|
this.history_view_active = true;
|
||||||
|
|
||||||
|
ContentLoadingEvent ();
|
||||||
UpdateSizeInfoEvent ("…", "…");
|
UpdateSizeInfoEvent ("…", "…");
|
||||||
|
|
||||||
string html = "";
|
string html = "";
|
||||||
|
@ -263,12 +275,24 @@ namespace SparkleShare {
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||||
if (repo.Name.Equals (folder)) {
|
if (repo.Name.Equals (folder)) {
|
||||||
|
|
||||||
|
new Thread (() => {
|
||||||
|
Stopwatch watch = new Stopwatch ();
|
||||||
|
|
||||||
|
watch.Start ();
|
||||||
|
|
||||||
List<SparkleChangeSet> change_sets = repo.GetChangeSets (path, 30);
|
List<SparkleChangeSet> change_sets = repo.GetChangeSets (path, 30);
|
||||||
|
|
||||||
html += "<div class='day-entry-header'>Revisions for “"
|
if (change_sets.Count > 1) {
|
||||||
+ Path.GetFileName (path) + "”</div>";
|
html += "<div class='day-entry-header'>Revisions for “";
|
||||||
|
html += Path.GetFileName (path) + "”</div>";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
html += "<div class='day-entry-header'>No revisions yet for “";
|
||||||
|
html += Path.GetFileName (path) + "”</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
html += "<b>« Back</b>";
|
||||||
html += "<table>";
|
html += "<table>";
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -277,11 +301,6 @@ namespace SparkleShare {
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (SparkleChange change in change_set.Changes) {
|
|
||||||
if (change.Type == SparkleChangeType.Deleted && change.Path.Equals (path))
|
|
||||||
continue; // TODO: in repo?
|
|
||||||
}
|
|
||||||
|
|
||||||
string change_set_avatar = Program.Controller.GetAvatar (change_set.User.Email, 24);
|
string change_set_avatar = Program.Controller.GetAvatar (change_set.User.Email, 24);
|
||||||
|
|
||||||
if (change_set_avatar != null)
|
if (change_set_avatar != null)
|
||||||
|
@ -291,23 +310,33 @@ namespace SparkleShare {
|
||||||
|
|
||||||
html += "<tr>" +
|
html += "<tr>" +
|
||||||
"<td class='avatar'><img src='" + change_set_avatar + "'></td>" +
|
"<td class='avatar'><img src='" + change_set_avatar + "'></td>" +
|
||||||
"<td class='name'><b>" + change_set.User.Name + "</b></td>" +
|
"<td class='name'>" + change_set.User.Name + "</td>" +
|
||||||
"<td class='date'>" + change_set.Timestamp.ToString ("d MMM yyyy") + "</td>" +
|
"<td class='date'>" + change_set.Timestamp.ToString ("d MMM yyyy") + "</td>" +
|
||||||
"<td class='time'>" + change_set.Timestamp.ToString ("HH:mm") + "</td>" +
|
"<td class='time'>" + change_set.Timestamp.ToString ("HH:mm") + "</td>" +
|
||||||
"<td class='restore'><a href='restore://" + change_set.Folder.Name + "/" + change_set.Revision + "/" + path + "' title='restore://" + change_set.Folder.Name + "/" + change_set.Revision + "/" + path + "'>Restore...</a></td>" +
|
"<td class='restore'>" +
|
||||||
|
"<a href='restore://" + change_set.Folder.Name + "/" +
|
||||||
|
change_set.Revision + "/" + change_set.User.Name + "/" +
|
||||||
|
change_set.Timestamp.ToString ("MMM d H\\hmm") + "/" +
|
||||||
|
path + "'>Restore…</a></td>" +
|
||||||
"</tr>";
|
"</tr>";
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html += "</table>";
|
html += "</table>";
|
||||||
|
watch.Stop ();
|
||||||
|
|
||||||
|
int delay = 500;
|
||||||
|
|
||||||
|
if (watch.ElapsedMilliseconds < delay)
|
||||||
|
Thread.Sleep (delay - (int) watch.ElapsedMilliseconds);
|
||||||
|
|
||||||
|
UpdateContentEvent (Program.Controller.EventLogHTML.Replace ("<!-- $event-log-content -->", html));
|
||||||
|
}).Start ();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateContentEvent (Program.Controller.EventLogHTML.Replace ("<!-- $event-log-content -->", html));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue