mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
refactor: change the way to refresh repository's data.
* mark dirty instead of calling refresh method directly * force mark branches data dirty after remotes changed
This commit is contained in:
parent
3eb8a82005
commit
a89760c7a5
6 changed files with 33 additions and 17 deletions
|
@ -53,8 +53,12 @@ namespace SourceGit.Models {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MarkWorkingCopyRefreshed() {
|
public void MarkBranchDirtyManually() {
|
||||||
_updateWC = 0;
|
_updateBranch = DateTime.Now.ToFileTime() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MarkWorkingCopyDirtyManually() {
|
||||||
|
_updateWC = DateTime.Now.ToFileTime() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
|
|
@ -70,7 +70,10 @@ namespace SourceGit.ViewModels {
|
||||||
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", SSHKey);
|
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", SSHKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
CallUIThread(() => {
|
||||||
|
_repo.MarkBranchesDirtyManually();
|
||||||
|
_repo.SetWatcherEnabled(true);
|
||||||
|
});
|
||||||
return succ;
|
return succ;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,10 @@ namespace SourceGit.ViewModels {
|
||||||
|
|
||||||
return Task.Run(() => {
|
return Task.Run(() => {
|
||||||
var succ = new Commands.Remote(_repo.FullPath).Delete(Remote.Name);
|
var succ = new Commands.Remote(_repo.FullPath).Delete(Remote.Name);
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
CallUIThread(() => {
|
||||||
|
_repo.MarkBranchesDirtyManually();
|
||||||
|
_repo.SetWatcherEnabled(true);
|
||||||
|
});
|
||||||
return succ;
|
return succ;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,6 +306,14 @@ namespace SourceGit.ViewModels {
|
||||||
if (_watcher != null) _watcher.SetEnabled(enabled);
|
if (_watcher != null) _watcher.SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MarkBranchesDirtyManually() {
|
||||||
|
if (_watcher != null) _watcher.MarkBranchDirtyManually();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MarkWorkingCopyDirtyManually() {
|
||||||
|
if (_watcher != null) _watcher.MarkWorkingCopyDirtyManually();
|
||||||
|
}
|
||||||
|
|
||||||
public void NavigateToCommit(string sha) {
|
public void NavigateToCommit(string sha) {
|
||||||
if (_histories != null) {
|
if (_histories != null) {
|
||||||
SelectedViewIndex = 0;
|
SelectedViewIndex = 0;
|
||||||
|
@ -357,7 +365,7 @@ namespace SourceGit.ViewModels {
|
||||||
} else if (File.Exists(otherMerge)) {
|
} else if (File.Exists(otherMerge)) {
|
||||||
mode = "merge";
|
mode = "merge";
|
||||||
} else {
|
} else {
|
||||||
await Task.Run(RefreshWorkingCopyChanges);
|
MarkWorkingCopyDirtyManually();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +402,7 @@ namespace SourceGit.ViewModels {
|
||||||
} else if (File.Exists(Path.Combine(_gitDir, "MERGE_HEAD"))) {
|
} else if (File.Exists(Path.Combine(_gitDir, "MERGE_HEAD"))) {
|
||||||
cmd.Args = "merge --abort";
|
cmd.Args = "merge --abort";
|
||||||
} else {
|
} else {
|
||||||
await Task.Run(RefreshWorkingCopyChanges);
|
MarkWorkingCopyDirtyManually();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,8 +499,6 @@ namespace SourceGit.ViewModels {
|
||||||
HasUnsolvedConflict = hasUnsolvedConflict;
|
HasUnsolvedConflict = hasUnsolvedConflict;
|
||||||
OnPropertyChanged(nameof(WorkingCopyChangesCount));
|
OnPropertyChanged(nameof(WorkingCopyChangesCount));
|
||||||
});
|
});
|
||||||
|
|
||||||
_watcher.MarkWorkingCopyRefreshed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshStashes() {
|
public void RefreshStashes() {
|
||||||
|
|
|
@ -246,7 +246,7 @@ namespace SourceGit.ViewModels {
|
||||||
await Task.Run(() => new Commands.Add(_repo.FullPath, step).Exec());
|
await Task.Run(() => new Commands.Add(_repo.FullPath, step).Exec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_repo.RefreshWorkingCopyChanges();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
IsStaging = false;
|
IsStaging = false;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ namespace SourceGit.ViewModels {
|
||||||
await Task.Run(() => new Commands.Reset(_repo.FullPath, step).Exec());
|
await Task.Run(() => new Commands.Reset(_repo.FullPath, step).Exec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_repo.RefreshWorkingCopyChanges();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
IsUnstaging = false;
|
IsUnstaging = false;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ namespace SourceGit.ViewModels {
|
||||||
if (succ) {
|
if (succ) {
|
||||||
await Task.Run(() => new Commands.Add(_repo.FullPath, [ctx.Change]).Exec());
|
await Task.Run(() => new Commands.Add(_repo.FullPath, [ctx.Change]).Exec());
|
||||||
}
|
}
|
||||||
_repo.RefreshWorkingCopyChanges();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ namespace SourceGit.ViewModels {
|
||||||
if (succ) {
|
if (succ) {
|
||||||
await Task.Run(() => new Commands.Add(_repo.FullPath, [ctx.Change]).Exec());
|
await Task.Run(() => new Commands.Add(_repo.FullPath, [ctx.Change]).Exec());
|
||||||
}
|
}
|
||||||
_repo.RefreshWorkingCopyChanges();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ namespace SourceGit.ViewModels {
|
||||||
PopupHost.ShowAndStartPopup(new Push(_repo, null));
|
PopupHost.ShowAndStartPopup(new Push(_repo, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_repo.RefreshWorkingCopyChanges();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
IsCommitting = false;
|
IsCommitting = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,7 +734,7 @@ namespace SourceGit.Views {
|
||||||
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--cache --index").Exec();
|
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--cache --index").Exec();
|
||||||
File.Delete(tmpFile);
|
File.Delete(tmpFile);
|
||||||
|
|
||||||
repo.RefreshWorkingCopyChanges();
|
repo.MarkWorkingCopyDirtyManually();
|
||||||
repo.SetWatcherEnabled(true);
|
repo.SetWatcherEnabled(true);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -760,7 +760,7 @@ namespace SourceGit.Views {
|
||||||
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--reverse").Exec();
|
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--reverse").Exec();
|
||||||
File.Delete(tmpFile);
|
File.Delete(tmpFile);
|
||||||
|
|
||||||
repo.RefreshWorkingCopyChanges();
|
repo.MarkWorkingCopyDirtyManually();
|
||||||
repo.SetWatcherEnabled(true);
|
repo.SetWatcherEnabled(true);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -788,7 +788,7 @@ namespace SourceGit.Views {
|
||||||
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--cache --index --reverse").Exec();
|
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--cache --index --reverse").Exec();
|
||||||
File.Delete(tmpFile);
|
File.Delete(tmpFile);
|
||||||
|
|
||||||
repo.RefreshWorkingCopyChanges();
|
repo.MarkWorkingCopyDirtyManually();
|
||||||
repo.SetWatcherEnabled(true);
|
repo.SetWatcherEnabled(true);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -814,7 +814,7 @@ namespace SourceGit.Views {
|
||||||
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--index --reverse").Exec();
|
new Commands.Apply(ctx.RepositoryPath, tmpFile, true, "nowarn", "--index --reverse").Exec();
|
||||||
File.Delete(tmpFile);
|
File.Delete(tmpFile);
|
||||||
|
|
||||||
repo.RefreshWorkingCopyChanges();
|
repo.MarkWorkingCopyDirtyManually();
|
||||||
repo.SetWatcherEnabled(true);
|
repo.SetWatcherEnabled(true);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue