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;
59
SubversionVersionControl Svn {
60
get { return (SubversionVersionControl) VersionControlSystem; }
63
bool IsVersioned (FilePath sourcefile)
59
SubversionVersionControl VersionControlSystem {
60
get { return (SubversionVersionControl) base.VersionControlSystem;
64
SubversionBackend backend;
65
protected internal SubversionBackend Svn {
68
backend = VersionControlSystem.CreateBackend ();
73
static bool IsVersioned (FilePath sourcefile)
65
return Svn.IsVersioned (sourcefile);
75
return SubversionVersionControl.IsVersioned (sourcefile);
68
78
public override string GetBaseText (FilePath sourcefile)
78
88
return Svn.GetPathToBaseText (sourcefile);
81
public override string GetTextAtRevision (FilePath repositoryPath, Revision revision)
91
protected override string OnGetTextAtRevision (FilePath repositoryPath, Revision revision)
83
93
return Svn.GetTextAtRevision (repositoryPath, revision);
86
public override Revision[] GetHistory (FilePath sourcefile, Revision since)
96
protected override Revision[] OnGetHistory (FilePath sourcefile, Revision since)
88
98
return Svn.GetHistory (this, sourcefile, since);
133
public override void Lock (IProgressMonitor monitor, params FilePath[] localPaths)
143
protected override void OnLock (IProgressMonitor monitor, params FilePath[] localPaths)
135
145
Svn.Lock (monitor, "", false, localPaths);
138
public override void Unlock (IProgressMonitor monitor, params FilePath[] localPaths)
148
protected override void OnUnlock (IProgressMonitor monitor, params FilePath[] localPaths)
140
150
Svn.Unlock (monitor, false, localPaths);
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)
145
155
string url = Url;
146
156
if (!serverPath.StartsWith ("/") && !url.EndsWith ("/"))
148
158
url += serverPath;
150
160
string[] paths = new string[] {url};
152
162
CreateDirectory (paths, message, monitor);
153
163
Svn.Checkout (this.Url + "/" + serverPath, localPath, null, true, monitor);
165
rootPath = localPath;
155
166
Set<FilePath> dirs = new Set<FilePath> ();
156
167
PublishDir (dirs, localPath, false, monitor);
163
174
Svn.Commit (new FilePath[] { localPath }, message, monitor);
165
return new SubversionRepository (Svn, paths[0], localPath);
176
return new SubversionRepository (VersionControlSystem, paths[0], localPath);
168
179
void PublishDir (Set<FilePath> dirs, FilePath dir, bool rec, IProgressMonitor monitor)
170
string ndir = (string) dir;
171
while (ndir[ndir.Length - 1] == Path.DirectorySeparatorChar)
172
ndir = ndir.Substring (0, ndir.Length - 1);
175
if (dirs.Contains (dir))
180
PublishDir (dirs, dir.ParentDirectory, true, monitor);
181
Add (dir, false, monitor);
181
if (dirs.Add (dir.CanonicalPath)) {
183
PublishDir (dirs, dir.ParentDirectory, true, monitor);
184
Add (dir, false, monitor);
185
public override void Update (FilePath[] paths, bool recurse, IProgressMonitor monitor)
189
protected override void OnUpdate (FilePath[] paths, bool recurse, IProgressMonitor monitor)
187
191
foreach (string path in paths)
188
192
Svn.Update (path, recurse, monitor);
191
public override void Commit (ChangeSet changeSet, IProgressMonitor monitor)
195
protected override void OnCommit (ChangeSet changeSet, IProgressMonitor monitor)
193
197
List<FilePath> list = new List<FilePath> ();
194
198
foreach (ChangeSetItem it in changeSet.Items)
201
205
Svn.Mkdir (paths, message, monitor);
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)
206
210
Svn.Checkout (this.Url, path, rev, recurse, monitor);
215
219
VersionControlService.NotifyFileStatusChanged (args);
218
public override void Revert (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
222
protected override void OnRevert (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
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);
229
public override void RevertRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
233
protected override void OnRevertRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
231
235
Svn.RevertRevision (localPath, revision, monitor);
234
public override void RevertToRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
238
protected override void OnRevertToRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
236
240
Svn.RevertToRevision (localPath, revision, monitor);
239
public override void Add (FilePath[] paths, bool recurse, IProgressMonitor monitor)
243
protected override void OnAdd (FilePath[] paths, bool recurse, IProgressMonitor monitor)
241
245
foreach (FilePath path in paths) {
242
246
if (IsVersioned (path) && File.Exists (path) && !Directory.Exists (path)) {
243
if (rootPath == null)
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;
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)
313
317
bool destIsVersioned = false;
323
327
destIsVersioned = true;
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);
337
341
MakeDirVersioned (Path.GetDirectoryName (destPath), monitor);
338
342
Svn.Move (srcPath, destPath, force, monitor);
340
base.MoveFile (srcPath, destPath, force, monitor);
344
base.OnMoveFile (srcPath, destPath, force, monitor);
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)
346
350
if (IsVersioned (destPath))
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.");
415
419
if (Directory.Exists (destPath))
416
420
throw new InvalidOperationException ("Cannot move directory. Destination directory already exist.");
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);
426
430
if (IsVersioned (srcPath)) {
427
431
MakeDirVersioned (Path.GetDirectoryName (destPath), monitor);
428
432
Svn.Move (srcPath, destPath, force, monitor);
430
base.MoveDirectory (srcPath, destPath, force, monitor);
434
base.OnMoveDirectory (srcPath, destPath, force, monitor);
463
public override void DeleteFiles (FilePath[] paths, bool force, IProgressMonitor monitor)
467
protected override void OnDeleteFiles (FilePath[] paths, bool force, IProgressMonitor monitor)
465
469
foreach (string path in paths) {
466
470
if (IsVersioned (path))
467
471
Svn.Delete (path, force, monitor);
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);
479
public override void DeleteDirectories (FilePath[] paths, bool force, IProgressMonitor monitor)
483
protected override void OnDeleteDirectories (FilePath[] paths, bool force, IProgressMonitor monitor)
481
485
foreach (string path in paths) {
482
486
if (IsVersioned (path))