~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
                                
48
48
                                foreach (DirectoryEntry ent in Svn.ListUrl (Url, false)) {
49
49
                                        if (ent.IsDirectory) {
50
 
                                                SubversionRepository rep = new SubversionRepository (Svn, Url + "/" + ent.Name, null);
 
50
                                                SubversionRepository rep = new SubversionRepository (VersionControlSystem, Url + "/" + ent.Name, null);
51
51
                                                rep.Name = ent.Name;
52
52
                                                list.Add (rep);
53
53
                                        }
55
55
                                return list;
56
56
                        }
57
57
                }
58
 
                
59
 
                SubversionVersionControl Svn {
60
 
                        get { return (SubversionVersionControl) VersionControlSystem; }
61
 
                }
62
 
 
63
 
                bool IsVersioned (FilePath sourcefile)
 
58
 
 
59
                SubversionVersionControl VersionControlSystem {
 
60
                        get { return (SubversionVersionControl) base.VersionControlSystem;
 
61
                        }
 
62
                }
 
63
 
 
64
                SubversionBackend backend;
 
65
                protected internal SubversionBackend Svn {
 
66
                        get {
 
67
                                if (backend == null)
 
68
                                        backend = VersionControlSystem.CreateBackend ();
 
69
                                return backend;
 
70
                        }
 
71
                }
 
72
 
 
73
                static bool IsVersioned (FilePath sourcefile)
64
74
                {
65
 
                        return Svn.IsVersioned (sourcefile);
 
75
                        return SubversionVersionControl.IsVersioned (sourcefile);
66
76
                }
67
77
                
68
78
                public override string GetBaseText (FilePath sourcefile)
78
88
                        return Svn.GetPathToBaseText (sourcefile);
79
89
                }
80
90
 
81
 
                public override string GetTextAtRevision (FilePath repositoryPath, Revision revision)
 
91
                protected override string OnGetTextAtRevision (FilePath repositoryPath, Revision revision)
82
92
                {
83
93
                        return Svn.GetTextAtRevision (repositoryPath, revision);
84
94
                }
85
95
 
86
 
                public override Revision[] GetHistory (FilePath sourcefile, Revision since)
 
96
                protected override Revision[] OnGetHistory (FilePath sourcefile, Revision since)
87
97
                {
88
98
                        return Svn.GetHistory (this, sourcefile, since);
89
99
                }
130
140
                        return true;
131
141
                }
132
142
 
133
 
                public override void Lock (IProgressMonitor monitor, params FilePath[] localPaths)
 
143
                protected override void OnLock (IProgressMonitor monitor, params FilePath[] localPaths)
134
144
                {
135
145
                        Svn.Lock (monitor, "", false, localPaths);
136
146
                }
137
147
 
138
 
                public override void Unlock (IProgressMonitor monitor, params FilePath[] localPaths)
 
148
                protected override void OnUnlock (IProgressMonitor monitor, params FilePath[] localPaths)
139
149
                {
140
150
                        Svn.Unlock (monitor, false, localPaths);
141
151
                }
142
152
 
143
 
                public override Repository Publish (string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor)
 
153
                protected override Repository OnPublish (string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor)
144
154
                {
145
155
                        string url = Url;
146
156
                        if (!serverPath.StartsWith ("/") && !url.EndsWith ("/"))
148
158
                        url += serverPath;
149
159
                        
150
160
                        string[] paths = new string[] {url};
151
 
                        
 
161
 
152
162
                        CreateDirectory (paths, message, monitor);
153
163
                        Svn.Checkout (this.Url + "/" + serverPath, localPath, null, true, monitor);
154
164
 
 
165
                        rootPath = localPath;
155
166
                        Set<FilePath> dirs = new Set<FilePath> ();
156
167
                        PublishDir (dirs, localPath, false, monitor);
157
168
 
162
173
 
163
174
                        Svn.Commit (new FilePath[] { localPath }, message, monitor);
164
175
                        
165
 
                        return new SubversionRepository (Svn, paths[0], localPath);
 
176
                        return new SubversionRepository (VersionControlSystem, paths[0], localPath);
166
177
                }
167
178
 
168
179
                void PublishDir (Set<FilePath> dirs, FilePath dir, bool rec, IProgressMonitor monitor)
169
180
                {
170
 
                        string ndir = (string) dir;
171
 
                        while (ndir[ndir.Length - 1] == Path.DirectorySeparatorChar)
172
 
                                ndir = ndir.Substring (0, ndir.Length - 1);
173
 
 
174
 
                        dir = ndir;
175
 
                        if (dirs.Contains (dir))
176
 
                                return;
177
 
 
178
 
                        dirs.Add (dir);
179
 
                        if (rec) {
180
 
                                PublishDir (dirs, dir.ParentDirectory, true, monitor);
181
 
                                Add (dir, false, monitor);
 
181
                        if (dirs.Add (dir.CanonicalPath)) {
 
182
                                if (rec) {
 
183
                                        PublishDir (dirs, dir.ParentDirectory, true, monitor);
 
184
                                        Add (dir, false, monitor);
 
185
                                }
182
186
                        }
183
187
                }
184
188
 
185
 
                public override void Update (FilePath[] paths, bool recurse, IProgressMonitor monitor)
 
189
                protected override void OnUpdate (FilePath[] paths, bool recurse, IProgressMonitor monitor)
186
190
                {
187
191
                        foreach (string path in paths)
188
192
                                Svn.Update (path, recurse, monitor);
189
193
                }
190
194
                
191
 
                public override void Commit (ChangeSet changeSet, IProgressMonitor monitor)
 
195
                protected override void OnCommit (ChangeSet changeSet, IProgressMonitor monitor)
192
196
                {
193
197
                        List<FilePath> list = new List<FilePath> ();
194
198
                        foreach (ChangeSetItem it in changeSet.Items)
201
205
                        Svn.Mkdir (paths, message, monitor);
202
206
                }
203
207
 
204
 
                public override void Checkout (FilePath path, Revision rev, bool recurse, IProgressMonitor monitor)
 
208
                protected override void OnCheckout (FilePath path, Revision rev, bool recurse, IProgressMonitor monitor)
205
209
                {
206
210
                        Svn.Checkout (this.Url, path, rev, recurse, monitor);
207
211
                }
215
219
                        VersionControlService.NotifyFileStatusChanged (args);
216
220
                }
217
221
 
218
 
                public override void Revert (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
 
222
                protected override void OnRevert (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
219
223
                {
220
224
                        // If we have an array of paths such as: new [] { "/Foo/Directory", "/Foo/Directory/File1", "/Foo/Directory/File2" }
221
225
                        // svn will successfully revert the first entry (the directory) and then throw an error when trying to revert the
226
230
                        Svn.Revert (localPaths, recurse, monitor);
227
231
                }
228
232
 
229
 
                public override void RevertRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
 
233
                protected override void OnRevertRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
230
234
                {
231
235
                        Svn.RevertRevision (localPath, revision, monitor);
232
236
                }
233
237
 
234
 
                public override void RevertToRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
 
238
                protected override void OnRevertToRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
235
239
                {
236
240
                        Svn.RevertToRevision (localPath, revision, monitor);
237
241
                }
238
242
 
239
 
                public override void Add (FilePath[] paths, bool recurse, IProgressMonitor monitor)
 
243
                protected override void OnAdd (FilePath[] paths, bool recurse, IProgressMonitor monitor)
240
244
                {
241
245
                        foreach (FilePath path in paths) {
242
246
                                if (IsVersioned (path) && File.Exists (path) && !Directory.Exists (path)) {
243
 
                                        if (rootPath == null)
 
247
                                        if (rootPath.IsNull)
244
248
                                                throw new UserException (GettextCatalog.GetString ("Project publishing failed. There is a stale .svn folder in the path '{0}'", path.ParentDirectory));
245
 
                                        VersionInfo srcInfo = GetVersionInfo (path, false);
 
249
                                        VersionInfo srcInfo = GetVersionInfo (path, VersionInfoQueryFlags.IgnoreCache);
246
250
                                        if (srcInfo.HasLocalChange (VersionStatus.ScheduledDelete)) {
247
251
                                                // It is a file that was deleted. It can be restored now since it's going
248
252
                                                // to be added again.
308
312
                        return (srcRepository is SubversionRepository) && ((SubversionRepository)srcRepository).Root == Root;
309
313
                }
310
314
 
311
 
                public override void MoveFile (FilePath srcPath, FilePath destPath, bool force, IProgressMonitor monitor)
 
315
                protected override void OnMoveFile (FilePath srcPath, FilePath destPath, bool force, IProgressMonitor monitor)
312
316
                {
313
317
                        bool destIsVersioned = false;
314
318
                        
323
327
                                destIsVersioned = true;
324
328
                        }
325
329
                        
326
 
                        VersionInfo srcInfo = GetVersionInfo (srcPath, false);
 
330
                        VersionInfo srcInfo = GetVersionInfo (srcPath, VersionInfoQueryFlags.IgnoreCache);
327
331
                        if (srcInfo != null && srcInfo.HasLocalChange (VersionStatus.ScheduledAdd)) {
328
332
                                // If the file is scheduled to add, cancel it, move the file, and schedule to add again
329
333
                                Revert (srcPath, false, monitor);
330
334
                                if (!destIsVersioned)
331
335
                                        MakeDirVersioned (Path.GetDirectoryName (destPath), monitor);
332
 
                                base.MoveFile (srcPath, destPath, force, monitor);
 
336
                                base.OnMoveFile (srcPath, destPath, force, monitor);
333
337
                                if (!destIsVersioned)
334
338
                                        Add (destPath, false, monitor);
335
339
                        } else {
337
341
                                        MakeDirVersioned (Path.GetDirectoryName (destPath), monitor);
338
342
                                        Svn.Move (srcPath, destPath, force, monitor);
339
343
                                } else
340
 
                                        base.MoveFile (srcPath, destPath, force, monitor);
 
344
                                        base.OnMoveFile (srcPath, destPath, force, monitor);
341
345
                        }
342
346
                }
343
347
 
344
 
                public override void MoveDirectory (FilePath srcPath, FilePath destPath, bool force, IProgressMonitor monitor)
 
348
                protected override void OnMoveDirectory (FilePath srcPath, FilePath destPath, bool force, IProgressMonitor monitor)
345
349
                {
346
350
                        if (IsVersioned (destPath))
347
351
                        {
348
 
                                VersionInfo vinfo = GetVersionInfo (destPath, false);
 
352
                                VersionInfo vinfo = GetVersionInfo (destPath, VersionInfoQueryFlags.IgnoreCache);
349
353
                                if (!vinfo.HasLocalChange (VersionStatus.ScheduledDelete) && Directory.Exists (destPath))
350
354
                                        throw new InvalidOperationException ("Cannot move directory. Destination directory already exist.");
351
355
                                        
415
419
                                if (Directory.Exists (destPath))
416
420
                                        throw new InvalidOperationException ("Cannot move directory. Destination directory already exist.");
417
421
                                
418
 
                                VersionInfo srcInfo = GetVersionInfo (srcPath, false);
 
422
                                VersionInfo srcInfo = GetVersionInfo (srcPath, VersionInfoQueryFlags.IgnoreCache);
419
423
                                if (srcInfo != null && srcInfo.HasLocalChange (VersionStatus.ScheduledAdd)) {
420
424
                                        // If the directory is scheduled to add, cancel it, move the directory, and schedule to add it again
421
425
                                        MakeDirVersioned (Path.GetDirectoryName (destPath), monitor);
422
426
                                        Revert (srcPath, true, monitor);
423
 
                                        base.MoveDirectory (srcPath, destPath, force, monitor);
 
427
                                        base.OnMoveDirectory (srcPath, destPath, force, monitor);
424
428
                                        Add (destPath, true, monitor);
425
429
                                } else {
426
430
                                        if (IsVersioned (srcPath)) {
427
431
                                                MakeDirVersioned (Path.GetDirectoryName (destPath), monitor);
428
432
                                                Svn.Move (srcPath, destPath, force, monitor);
429
433
                                        } else
430
 
                                                base.MoveDirectory (srcPath, destPath, force, monitor);
 
434
                                                base.OnMoveDirectory (srcPath, destPath, force, monitor);
431
435
                                }
432
436
                        }
433
437
                }
460
464
                }
461
465
 
462
466
 
463
 
                public override void DeleteFiles (FilePath[] paths, bool force, IProgressMonitor monitor)
 
467
                protected override void OnDeleteFiles (FilePath[] paths, bool force, IProgressMonitor monitor)
464
468
                {
465
469
                        foreach (string path in paths) {
466
470
                                if (IsVersioned (path))
467
471
                                        Svn.Delete (path, force, monitor);
468
472
                                else {
469
 
                                        VersionInfo srcInfo = GetVersionInfo (path, false);
 
473
                                        VersionInfo srcInfo = GetVersionInfo (path, VersionInfoQueryFlags.IgnoreCache);
470
474
                                        if (srcInfo != null && srcInfo.HasLocalChange (VersionStatus.ScheduledAdd)) {
471
475
                                                // Revert the add command
472
476
                                                Revert (path, false, monitor);
476
480
                        }
477
481
                }
478
482
 
479
 
                public override void DeleteDirectories (FilePath[] paths, bool force, IProgressMonitor monitor)
 
483
                protected override void OnDeleteDirectories (FilePath[] paths, bool force, IProgressMonitor monitor)
480
484
                {
481
485
                        foreach (string path in paths) {
482
486
                                if (IsVersioned (path))