12
12
public abstract class SubversionVersionControl : VersionControlSystem
14
readonly string[] protocolsSvn = {"svn", "svn+ssh", "http", "https", "file"};
16
14
public override string Name {
17
15
get { return "Subversion"; }
22
20
return new SubversionRepository ();
25
public override Gtk.Widget CreateRepositoryEditor (Repository repo)
23
public override IRepositoryEditor CreateRepositoryEditor (Repository repo)
27
return new UrlBasedRepositoryEditor ((SubversionRepository)repo, protocolsSvn);
25
return new UrlBasedRepositoryEditor ((SubversionRepository)repo);
30
28
public override Repository GetRepositoryReference (FilePath path, string id)
33
31
if (!IsVersioned (path))
35
33
string url = GetPathUrl (path);
36
return new SubversionRepository (this, url);
34
return new SubversionRepository (this, url, path);
37
35
} catch (Exception ex) {
39
37
LoggingService.LogError (ex.ToString ());
60
58
return Path.Combine(sourcepath, ".svn");
63
public bool IsDiffAvailable (Repository repo, FilePath sourcefile) {
65
// Directory check is needed since directory links may look like versioned files
66
return File.Exists(GetTextBase(sourcefile)) && !Directory.Exists (sourcefile)
67
&& IsVersioned(sourcefile)
68
&& GetVersionInfo (repo, sourcefile, false).HasLocalChange (VersionStatus.Modified);
70
// GetVersionInfo may throw an exception
75
61
public bool IsVersioned (FilePath sourcefile)
77
63
return File.Exists (GetTextBase (sourcefile))
78
64
|| Directory.Exists (GetDirectoryDotSvn (sourcefile));
81
public bool CanCommit (Repository repo, FilePath sourcepath)
83
if (Directory.Exists (sourcepath) && Directory.Exists (GetDirectoryDotSvn (sourcepath)))
85
if (GetVersionInfo (repo, sourcepath, false) != null)
90
public bool CanAdd (Repository repo, FilePath sourcepath)
92
// Do some trivial checks
94
if (!Directory.Exists (GetDirectoryDotSvn (Path.GetDirectoryName (sourcepath))))
97
if (File.Exists (sourcepath)) {
98
if (File.Exists (GetTextBase (sourcepath)))
100
} else if (Directory.Exists (sourcepath)) {
101
if (Directory.Exists (GetTextBase (sourcepath)))
106
// Allow adding only if the path is not already scheduled for adding
108
VersionInfo ver = this.GetVersionInfo (repo, sourcepath, false);
111
return !ver.IsVersioned;
114
67
public string GetPathToBaseText (FilePath sourcefile) {
115
68
return GetTextBase (sourcefile);
133
86
public abstract IEnumerable<SvnRevision> Log (Repository repo, FilePath path, SvnRevision revisionStart, SvnRevision revisionEnd);
135
public abstract string GetTextAtRevision (string repositoryPath, Revision revision);
88
public abstract string GetTextAtRevision (string repositoryPath, Revision revision);
90
internal protected virtual VersionControlOperation GetSupportedOperations (Repository repo, VersionInfo vinfo, VersionControlOperation defaultValue)
92
if (vinfo.IsVersioned && File.Exists (vinfo.LocalPath) && !Directory.Exists (vinfo.LocalPath) && vinfo.HasLocalChange (VersionStatus.ScheduledDelete))
93
defaultValue |= VersionControlOperation.Add;
137
97
public VersionInfo GetVersionInfo (Repository repo, FilePath localPath, bool getRemoteStatus)
142
102
else if (File.Exists (GetTextBase(localPath)) || File.Exists (localPath))
143
103
return GetFileStatus (repo, localPath, getRemoteStatus);
105
return VersionInfo.CreateUnversioned (localPath, false);
148
108
private VersionInfo GetFileStatus (Repository repo, FilePath sourcefile, bool getRemoteStatus)
110
SubversionRepository srepo = (SubversionRepository) repo;
150
112
// If the directory is not versioned, there is no version info
151
113
if (!Directory.Exists (GetDirectoryDotSvn (sourcefile.ParentDirectory)))
114
return VersionInfo.CreateUnversioned (sourcefile, false);
115
if (!sourcefile.IsChildPathOf (srepo.RootPath))
116
return VersionInfo.CreateUnversioned (sourcefile, false);
154
118
List<VersionInfo> statuses = new List<VersionInfo> ();
155
119
statuses.AddRange (Status (repo, sourcefile, SvnRevision.Head, false, false, getRemoteStatus));
157
121
if (statuses.Count == 0)
158
throw new ArgumentException("Path '" + sourcefile + "' does not exist in the repository.");
122
return VersionInfo.CreateUnversioned (sourcefile, false);
160
124
if (statuses.Count != 1)
161
throw new ArgumentException("Path '" + sourcefile + "' does not refer to a file in the repository.");
125
return VersionInfo.CreateUnversioned (sourcefile, false);
163
127
VersionInfo ent = (VersionInfo) statuses[0];
164
128
if (ent.IsDirectory)
165
throw new ArgumentException("Path '" + sourcefile + "' does not refer to a file.");
129
return VersionInfo.CreateUnversioned (sourcefile, false);
172
136
// If the directory is not versioned, there is no version info
173
137
if (!Directory.Exists (GetDirectoryDotSvn (localPath)))
138
return VersionInfo.CreateUnversioned (localPath, true);
176
140
foreach (VersionInfo ent in Status (repo, localPath, SvnRevision.Head, false, false, getRemoteStatus)) {
177
if (ent.LocalPath == localPath)
141
if (ent.LocalPath.CanonicalPath == localPath.CanonicalPath)
144
return VersionInfo.CreateUnversioned (localPath, true);
183
147
public VersionInfo[] GetDirectoryVersionInfo (Repository repo, FilePath sourcepath, bool getRemoteStatus, bool recursive)
293
257
/// A <see cref="System.String"/> annotation for each line in file.
295
public virtual List<string> GetAnnotations (Repository repo, FilePath file, SvnRevision revStart, SvnRevision revEnd)
259
public virtual Annotation[] GetAnnotations (Repository repo, FilePath file, SvnRevision revStart, SvnRevision revEnd)
297
return new List<string> ();
261
return new Annotation[0];