1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
using MonoDevelop.Components.Commands;
using MonoDevelop.Core;
using MonoDevelop.VersionControl.Dialogs;
using MonoDevelop.Ide;
using System.Linq;
namespace MonoDevelop.VersionControl
{
internal class CheckoutCommand : CommandHandler
{
protected override void Update (CommandInfo info)
{
info.Enabled = VersionControlService.CheckVersionControlInstalled ();
info.Visible = !VersionControlService.IsGloballyDisabled;
}
protected override void Run()
{
SelectRepositoryDialog del = new SelectRepositoryDialog (SelectRepositoryMode.Checkout);
try {
if (MessageService.RunCustomDialog (del) == (int) Gtk.ResponseType.Ok && del.Repository != null) {
CheckoutWorker w = new CheckoutWorker (del.Repository, del.TargetPath);
w.Start ();
}
} finally {
del.Destroy ();
}
}
}
class CheckoutWorker : VersionControlTask
{
Repository vc;
string path;
public CheckoutWorker (Repository vc, string path)
{
this.vc = vc;
this.path = path;
OperationType = VersionControlOperationType.Pull;
}
protected override string GetDescription ()
{
return GettextCatalog.GetString ("Checking out {0}...", path);
}
protected override ProgressMonitor CreateProgressMonitor ()
{
return new MonoDevelop.Core.ProgressMonitoring.AggregatedProgressMonitor (
base.CreateProgressMonitor (),
new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor (true, true, true, true)
);
}
protected override void Run ()
{
if (System.IO.Directory.Exists (path) && System.IO.Directory.EnumerateFileSystemEntries (path).Any ()) {
if (MessageService.AskQuestion (GettextCatalog.GetString (
"Checkout path is not empty. Do you want to delete its contents?"),
path,
AlertButton.Cancel,
AlertButton.Ok) == AlertButton.Cancel)
return;
FileService.DeleteDirectory (path);
FileService.CreateDirectory (path);
}
try {
vc.Checkout (path, null, true, Monitor);
} catch (VersionControlException e) {
Monitor.ReportError (GettextCatalog.GetString (e.Message), null);
return;
}
if (Monitor.CancellationToken.IsCancellationRequested) {
Monitor.ReportSuccess (GettextCatalog.GetString ("Checkout operation cancelled"));
return;
}
if (!System.IO.Directory.Exists (path)) {
Monitor.ReportError (GettextCatalog.GetString ("Checkout folder does not exist"), null);
return;
}
string projectFn = null;
string[] list = System.IO.Directory.GetFiles (path);
if (projectFn == null) {
foreach (string str in list) {
if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile (str)) {
projectFn = str;
break;
}
}
}
if (projectFn != null) {
DispatchService.GuiDispatch (delegate {
IdeApp.Workspace.OpenWorkspaceItem (projectFn);
});
}
Monitor.ReportSuccess (GettextCatalog.GetString ("Solution checked out"));
}
}
}
|