public static Repository GetRepositoryReference(string path, string id)
        {
            VersionControlSystem detectedVCS  = null;
            FilePath             shortestPath = FilePath.Null;

            foreach (VersionControlSystem vcs in GetVersionControlSystems())
            {
                var newPath = vcs.GetRepositoryPath(path, id);
                if (!newPath.IsNullOrEmpty)
                {
                    if (string.IsNullOrEmpty(shortestPath))
                    {
                        shortestPath = newPath;
                        detectedVCS  = vcs;
                    }
                    else if (shortestPath.CompareTo(newPath) <= 0)
                    {
                        // They are guaranteed to be on the same path segments, so choose by path length.
                        shortestPath = newPath;
                        detectedVCS  = vcs;
                    }
                }
            }
            return(detectedVCS == null ? null : detectedVCS.GetRepositoryReference(shortestPath, id));
        }
        public static Repository GetRepositoryReference(string path, string id)
        {
            VersionControlSystem detectedVCS = null;
            FilePath             bestMatch   = FilePath.Null;

            foreach (VersionControlSystem vcs in GetVersionControlSystems())
            {
                var newPath = vcs.GetRepositoryPath(path, id);
                if (!newPath.IsNullOrEmpty)
                {
                    // Check whether we have no match or if a new match is found with a longer path.
                    // TODO: If the repo root is not the same as the repo reference, ask user for input.
                    // TODO: If we have two version control directories in the same place, ask user for input.
                    if (bestMatch.IsNullOrEmpty)
                    {
                        bestMatch   = newPath;
                        detectedVCS = vcs;
                    }
                    else if (bestMatch.CompareTo(newPath) <= 0)
                    {
                        bestMatch   = newPath;
                        detectedVCS = vcs;
                    }
                }
            }
            return(detectedVCS == null ? null : detectedVCS.GetRepositoryReference(bestMatch, id));
        }
Example #3
0
        protected int CompareTo(MsDataFilePath other)
        {
            // Culture specific sorting desirable in file paths
// ReSharper disable StringCompareToIsCultureSpecific
            int result = FilePath.CompareTo(other.FilePath);

            if (result != 0)
            {
                return(result);
            }
            result = SampleName.CompareTo(other.SampleName);
            if (result != 0)
            {
                return(result);
            }
            result = SampleIndex.CompareTo(other.SampleIndex);
            if (result != 0)
            {
                return(result);
            }
            result = CentroidMs1.CompareTo(other.CentroidMs1);
            if (result != 0)
            {
                return(result);
            }
            result = CentroidMs2.CompareTo(other.CentroidMs2);
            if (result != 0)
            {
                return(result);
            }
            return(LockMassParameters.CompareTo(other.LockMassParameters));
// ReSharper restore StringCompareToIsCultureSpecific
        }
Example #4
0
            /// <summary>
            /// Verify whether the actual directory location of block file has the
            /// expected directory path computed using its block ID.
            /// </summary>
            private void VerifyFileLocation(FilePath actualBlockDir, FilePath bpFinalizedDir,
                                            long blockId)
            {
                FilePath blockDir = DatanodeUtil.IdToBlockDir(bpFinalizedDir, blockId);

                if (actualBlockDir.CompareTo(blockDir) != 0)
                {
                    Log.Warn("Block: " + blockId + " has to be upgraded to block ID-based layout");
                }
            }
Example #5
0
        public static Repository GetRepositoryReference(string path, string id)
        {
            VersionControlSystem detectedVCS = null;
            FilePath             bestMatch   = FilePath.Null;

            foreach (VersionControlSystem vcs in GetVersionControlSystems())
            {
                var newPath = vcs.GetRepositoryPath(path, id);
                if (!newPath.IsNullOrEmpty)
                {
                    // Check whether we have no match or if a new match is found with a longer path.
                    // TODO: If the repo root is not the same as the repo reference, ask user for input.
                    // TODO: If we have two version control directories in the same place, ask user for input.
                    if (bestMatch.IsNullOrEmpty)
                    {
                        bestMatch   = newPath;
                        detectedVCS = vcs;
                    }
                    else if (bestMatch.CompareTo(newPath) <= 0)
                    {
                        bestMatch   = newPath;
                        detectedVCS = vcs;
                    }
                }
            }

            bestMatch = bestMatch.CanonicalPath;

            lock (repositoryCacheLock) {
                if (repositoryCache.TryGetValue(bestMatch, out var repository))
                {
                    if (!repository.IsDisposed)
                    {
                        return(repository);
                    }
                    repositoryCache.Remove(bestMatch);
                }

                try {
                    var repo = detectedVCS?.GetRepositoryReference(bestMatch, id);
                    if (repo != null)
                    {
                        repo.RepositoryPath = bestMatch.CanonicalPath;
                        repositoryCache.Add(bestMatch, repo);
                        Instrumentation.Repositories.Inc(new RepositoryMetadata(detectedVCS));
                    }
                    return(repo);
                } catch (Exception e) {
                    LoggingService.LogError($"Could not query {detectedVCS.Name} repository reference", e);
                    return(null);
                }
            }
        }
Example #6
0
        public static Repository GetRepositoryReference(string path, string id)
        {
            VersionControlSystem detectedVCS = null;
            FilePath             bestMatch   = FilePath.Null;

            foreach (VersionControlSystem vcs in GetVersionControlSystems())
            {
                var newPath = vcs.GetRepositoryPath(path, id);
                if (!newPath.IsNullOrEmpty)
                {
                    // Check whether we have no match or if a new match is found with a longer path.
                    // TODO: If the repo root is not the same as the repo reference, ask user for input.
                    // TODO: If we have two version control directories in the same place, ask user for input.
                    if (bestMatch.IsNullOrEmpty)
                    {
                        bestMatch   = newPath;
                        detectedVCS = vcs;
                    }
                    else if (bestMatch.CompareTo(newPath) <= 0)
                    {
                        bestMatch   = newPath;
                        detectedVCS = vcs;
                    }
                }
            }

            bestMatch = bestMatch.CanonicalPath;

            try {
                return(repositoryCache.GetOrAdd(bestMatch, p => {
                    var result = detectedVCS?.GetRepositoryReference(p, id);
                    if (result != null)
                    {
                        Instrumentation.Repositories.Inc(new RepositoryMetadata(detectedVCS));
                        return result;
                    }
                    // never add null values
                    throw new ArgumentNullException("result");
                }));
            } catch (Exception e) {
                // ArgumentNullException for "result" is expected when GetRepositoryReference returns null, no need to log
                if (!(e is ArgumentNullException ne) || ne.ParamName != "result")
                {
                    LoggingService.LogInternalError($"Could not query {detectedVCS.Name} repository reference", e);
                }
                return(null);
            }
        }
Example #7
0
 public int CompareTo(Song other)
 {
     return(FilePath.CompareTo(other.FilePath));
 }
Example #8
0
 public int CompareTo(SoldakObject other)
 {
     return(FilePath.CompareTo(other.FilePath) == 1 ? 1 : 0);
 }
Example #9
0
 public int CompareTo(object obj)
 {
     return(FilePath.CompareTo(((FileDataInfo)obj).FilePath));
 }