コード例 #1
0
 private void VerifyRepository(Hg hg)
 {
     Debug.Assert(hg != null);
     if (FailIfMultipleHeads && hg.Heads(Branch).Count.Tap(i => Log.Debug("{0} head(s) in repository", i)) != 1)
     {
         var message = string.Format(CultureInfo.CurrentCulture, "Multiple or no heads in branch '{0}'.", Branch);
         throw new HgSourceControlException(message);
     }
     if (hg.GetBranchForTag(Tag).Tap(b => Log.Debug("Branch for tag '{0}' is '{1}'", Tag, b)) != Branch)
     {
         var message = string.Format(CultureInfo.CurrentCulture, "Tag '{0}' is not on branch '{1}'.", Tag, Branch);
         throw new HgSourceControlException(message);
     }
 }
コード例 #2
0
 private void PullChanges(Hg hg)
 {
     Debug.Assert(hg != null);
     hg.Pull(SourceRepository);
 }
コード例 #3
0
 private void UpdateWorkingDirectory(Hg hg)
 {
     Debug.Assert(hg != null);
     Log.Debug("Updating to tag or branch '{0}'.", Tag);
     hg.Update(Tag.AsRevision());
 }
コード例 #4
0
 private Revision GetTargetRevision(Hg hg)
 {
     Debug.Assert(hg != null);
     return hg.GetRevisionForTag(Tag);
 }
コード例 #5
0
 private void InitializeWorkingDirectory(string workingDirectory)
 {
     Debug.Assert(!string.IsNullOrEmpty(workingDirectory));
     EnsureWorkingDirectory(workingDirectory);
     var hg = new Hg(new CruiseControlHgProcess(ProcessExecutor), _hgXmlLogParser, workingDirectory);
     EnsureRepository(hg);
     CheckVersion(hg);
 }
コード例 #6
0
        private IEnumerable<Changeset> GetChangesets(Hg hg,
		                                             Revision fromRevision,
		                                             Revision toRevision)
        {
            Debug.Assert(hg != null);
            Debug.Assert(fromRevision != null);
            Debug.Assert(toRevision != null);

            return hg
                .Log(Branch, fromRevision.Through(toRevision))
                .Where(changeset => changeset.Hash.ToRevision() != fromRevision);
        }
コード例 #7
0
 private static void EnsureRepository(Hg hg)
 {
     Log.Debug("Ensuring '{0}' is a repository.", hg.RepositoryPath);
     if (hg.IsRepository)
     {
         return;
     }
     Log.Info("Creating repository at '{0}'.");
     hg.Init();
 }
コード例 #8
0
        private static void CheckVersion(Hg hg)
        {
            Debug.Assert(hg != null);

            var version = hg.Version;
            if (version < VersionWarningThreshold)
            {
                Log.Warning("Hg installed version {0} is less than tested version of {1}.", version, VersionWarningThreshold);
            }
        }
コード例 #9
0
        public override void GetSource(IIntegrationResult result)
        {
            if (!AutoGetSource)
            {
                return;
            }

            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            var workingDirectory = WorkingDirectoryOrDefault(result.WorkingDirectory);

            var hg = new Hg(new CruiseControlHgProcess(ProcessExecutor), _hgXmlLogParser, workingDirectory);

            UpdateWorkingDirectory(hg);
        }
コード例 #10
0
        public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to)
        {
            if (from == null)
            {
                throw new ArgumentNullException("from");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            var progressInformation = to.BuildProgressInformation;

            progressInformation.SignalStartRunTask("Hg: Get Modifications");

            var lastBuilt = from.GetRevision();
            Log.Debug("Last built from revision '{0}'", lastBuilt);
            var workingDirectory = WorkingDirectoryOrDefault(to.WorkingDirectory);

            progressInformation.AddTaskInformation("Hg: Initializing working directory");
            InitializeWorkingDirectory(workingDirectory);

            var hg = new Hg(new CruiseControlHgProcess(ProcessExecutor), _hgXmlLogParser, workingDirectory);

            progressInformation.AddTaskInformation("Hg: Pulling changes");
            PullChanges(hg);

            progressInformation.AddTaskInformation("Hg: Verifying repository");
            VerifyRepository(hg);

            progressInformation.AddTaskInformation("Hg: Getting target revision");
            var targetRevision = GetTargetRevision(hg);

            progressInformation.AddTaskInformation("Hg: Getting changesets");
            var changesets = GetChangesets(hg, lastBuilt, targetRevision);
            Log.Debug("{0} Hg changeset(s) found", changesets.Count());

            to.SetRevision(targetRevision);

            progressInformation.AddTaskInformation("Hg: Generating modifications");
            return ConvertChangesetsToModifications(changesets)
                .TapIf(() => WebUrlBuilder != null, ems => WebUrlBuilder.SetupModification(ems))
                .Tap(FillIssueUrl);
        }