示例#1
0
        /// <summary>
        /// Returns information about the Hg repositories that the ChorusHub knows about.
        ///
        /// Similar to GetRepositoryInformation except the value of the id field is the id
        /// of the tip revision of the repository.
        ///
        /// For the returned tip to be accurate, clients using this method have to call
        /// PutFile(IChorusHubService.tipIdFolder, projectName, tipId) after doing a push.
        /// </summary>
        public string GetRepositoryInformationWithTipIds(string searchUrl)
        {
            List <RepositoryInformation> results = new List <RepositoryInformation>();

            foreach (RepositoryInformation repoInfo in
                     ImitationHubJSONService.ParseJsonStringsToChorusHubRepoInfos(GetRepositoryInformation(searchUrl, false)))
            {
                string tipId = GetFileAsText(TipIdFolder, repoInfo.RepoName);
                if (tipId == null)
                {
                    tipId = GetTipId(repoInfo.RepoName);
                    PutFileFromText(TipIdFolder, repoInfo.RepoName, tipId);
                }
                results.Add(new RepositoryInformation(repoInfo.RepoName, tipId));
            }

            return(string.Join("/", results.Select(r => ImitationHubJSONService.MakeJsonString(r.RepoName, r.RepoID))));
        }
示例#2
0
        private static bool HasRepo(string dirName, out string jsonRepoInfo)
        {
            jsonRepoInfo = null;
            var hgDir = Path.Combine(dirName, HgFolder);

            if (!Directory.Exists(hgDir))
            {
                return(false);
            }
            var repo = HgRepository.CreateOrUseExisting(dirName, new ConsoleProgress());
            var id   = repo.Identifier;
            var name = Path.GetFileName(dirName);

            if (id == null)
            {
                id = RepositoryInformation.NEW_REPO;
            }
            jsonRepoInfo = ImitationHubJSONService.MakeJsonString(name, id);
            return(true);
        }