~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Publish.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.Collections;
3
 
 
4
 
using MonoDevelop.Projects;
5
 
using MonoDevelop.Core;
6
 
using MonoDevelop.Ide.Gui;
7
 
 
8
 
using MonoDevelop.VersionControl.Dialogs;
9
 
 
10
 
namespace MonoDevelop.VersionControl 
11
 
{
12
 
        internal class PublishCommand 
13
 
        {
14
 
                public static bool Publish (CombineEntry entry, string localPath, bool test)
15
 
                {
16
 
                        if (test)
17
 
                                return true;
18
 
 
19
 
                        if (!VersionControlService.CheckVersionControlInstalled ())
20
 
                                return false;
21
 
                        
22
 
                        ArrayList files = new ArrayList ();
23
 
 
24
 
                        // Build the list of files to be checked in                     
25
 
                        string moduleName = entry.Name;
26
 
                        if (localPath == entry.BaseDirectory) {
27
 
                                GetFiles (files, entry);
28
 
                        } else if (entry is Project) {
29
 
                                foreach (ProjectFile file in ((Project)entry).ProjectFiles.GetFilesInPath (localPath))
30
 
                                        if (file.Subtype != Subtype.Directory)
31
 
                                                files.Add (file.FilePath);
32
 
                        } else
33
 
                                return false;
34
 
        
35
 
                        SelectRepositoryDialog dlg = new SelectRepositoryDialog (SelectRepositoryMode.Publish);
36
 
                        try {
37
 
                                dlg.ModuleName = moduleName;
38
 
                                dlg.Message = GettextCatalog.GetString ("Initial check-in of module {0}", moduleName);
39
 
                                do {
40
 
                                        if (dlg.Run () == (int) Gtk.ResponseType.Ok && dlg.Repository != null) {
41
 
                                                if (IdeApp.Services.MessageService.AskQuestion (GettextCatalog.GetString ("Are you sure you want to publish the project to the repository '{0}'?", dlg.Repository.Name))) {
42
 
                                                        PublishWorker w = new PublishWorker (dlg.Repository, dlg.ModuleName, localPath, (string[]) files.ToArray (typeof(string)), dlg.Message);
43
 
                                                        w.Start ();
44
 
                                                        break;
45
 
                                                }
46
 
                                        } else
47
 
                                                break;
48
 
                                } while (true);
49
 
                        } finally {
50
 
                                dlg.Destroy ();
51
 
                        }
52
 
                        return true;
53
 
                }
54
 
                
55
 
                static void GetFiles (ArrayList files, CombineEntry entry)
56
 
                {
57
 
                        files.Add (entry.FileName);
58
 
                        if (entry is Project) {
59
 
                                foreach (ProjectFile file in ((Project)entry).ProjectFiles)
60
 
                                        if (file.Subtype != Subtype.Directory)
61
 
                                                files.Add (file.FilePath);
62
 
                        } else if (entry is Combine) {
63
 
                                foreach (CombineEntry e in ((Combine)entry).Entries)
64
 
                                        GetFiles (files, e);
65
 
                        }
66
 
                }
67
 
                
68
 
                public static bool CanPublish (Repository vc, string path, bool isDir) {
69
 
                        if (!vc.IsVersioned (path) && isDir) 
70
 
                                return true;
71
 
                        return false;
72
 
                }
73
 
        }
74
 
        
75
 
        internal class PublishWorker : Task {
76
 
                Repository vc;
77
 
                string path;
78
 
                string moduleName;
79
 
                string[] files;
80
 
                string message;
81
 
                                        
82
 
                public PublishWorker (Repository vc, string moduleName, string localPath, string[] files, string message) 
83
 
                {
84
 
                        this.vc = vc;
85
 
                        this.path = localPath;
86
 
                        this.moduleName = moduleName;
87
 
                        this.files = files;
88
 
                        this.message = message;
89
 
                }
90
 
 
91
 
                protected override string GetDescription ()
92
 
                {
93
 
                        return "Publishing \"" + moduleName + "\" Project...";
94
 
                }
95
 
                
96
 
                protected override void Run ()
97
 
                {
98
 
                        vc.Publish (moduleName, path, files, message, GetProgressMonitor ());
99
 
                        
100
 
                        Gtk.Application.Invoke (delegate {
101
 
                                VersionControlService.NotifyFileStatusChanged (vc, path, true);
102
 
                        });
103
 
                }
104
 
        }
105
 
}