diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2019-03-08 11:40:01 +0300 |
---|---|---|
committer | Lluis Sanchez <llsan@microsoft.com> | 2019-03-08 11:40:01 +0300 |
commit | 39a4669db3021d68e57f179b2b300128a6cafecc (patch) | |
tree | 6b932eb0d14ed17d750412dc0ae6698b2aad5c75 /main | |
parent | 8dfbf435307290dc000cd090056a1e63bb87fa9e (diff) | |
parent | 4e40e402945e7c92d59781478add97838b524a1f (diff) |
Merge remote-tracking branch 'origin/release-8.0-integration' into merge-integration-10
Diffstat (limited to 'main')
2 files changed, 41 insertions, 10 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs index a13f8d7867..18f500f298 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs @@ -105,14 +105,23 @@ namespace MonoDevelop.VersionControl VersionControlSystem vcs; try { - vcs = (VersionControlSystem) args.ExtensionObject; + vcs = (VersionControlSystem)args.ExtensionObject; } catch (Exception e) { LoggingService.LogError ("Failed to initialize VersionControlSystem type.", e); return; } if (args.Change == ExtensionChange.Add) { - handlers.Add (vcs); + IComparer<VersionControlSystem> compare = new CompareVersionControlSystem (); + + int search = handlers.BinarySearch (vcs, compare); + + if (search < 0) + handlers.Insert (~search, vcs); + else { + LoggingService.LogError ("Adding new version control system {0} failed, the name {1} is already reserved.", vcs.GetType ().Name, vcs.Name); + return; + } try { // Include the repository type in the serialization context, so repositories // of this type can be deserialized from the configuration file. @@ -123,8 +132,7 @@ namespace MonoDevelop.VersionControl } catch (Exception e) { LoggingService.LogError ("Error while adding version control system.", e); } - } - else { + } else { handlers.Remove (vcs); } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlSystem.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlSystem.cs index feb396bcdf..46a42844ab 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlSystem.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlSystem.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using MonoDevelop.Core; namespace MonoDevelop.VersionControl @@ -29,9 +30,9 @@ namespace MonoDevelop.VersionControl /// The default implementation returns the full name of the class. /// </remarks> public virtual string Id { - get { return GetType().ToString(); } + get { return GetType ().ToString (); } } - + /// <summary> /// Display name of the version control system /// </summary> @@ -55,12 +56,12 @@ namespace MonoDevelop.VersionControl public virtual bool IsInstalled { get { return false; } } - + /// <summary> /// Creates an instance of a repository for this version control system /// </summary> protected abstract Repository OnCreateRepositoryInstance (); - + /// <summary> /// Creates an editor object for a repository. /// </summary> @@ -70,7 +71,7 @@ namespace MonoDevelop.VersionControl /// <param name='repo'> /// A repository /// </param> - public abstract IRepositoryEditor CreateRepositoryEditor (Repository repo);
+ public abstract IRepositoryEditor CreateRepositoryEditor (Repository repo); /// <summary> /// Gets a repository for a given local path and identifier @@ -123,4 +124,26 @@ namespace MonoDevelop.VersionControl return remoteRelativePath.Replace ('/', System.IO.Path.DirectorySeparatorChar); } } -} + + public class CompareVersionControlSystem : IComparer<VersionControlSystem> + { + public int Compare (VersionControlSystem vcs1, VersionControlSystem vcs2) + { + int result; + + if (ReferenceEquals (vcs1, vcs2)) { + result = 0; + } else { + if (vcs1 is null) { + result = 1; + } else if (vcs2 is null) { + result = -1; + } else { + result = string.Compare(vcs1.Name, vcs2.Name, StringComparison.InvariantCultureIgnoreCase); + } + } + + return result; + } + } +}
\ No newline at end of file |