Example #1
0
        private void PerformLabel(SourceProject project, IIntegrationResult result)
        {
            if (project.ApplyLabel)
            {
                Log.Debug(String.Format("Applying label \"{0}\" on project \"{1}\"", result.Label, project.ProjectPath));

                string comment = result.StartTime.ToString() + " on " + project.ProjectPath;

                VersionControlLabel vcLabel = new VersionControlLabel(
                    this.SourceControl, result.Label, this.SourceControl.AuthorizedUser,
                    project.ProjectPath, comment);

                // Create Label Item Spec.
                ItemSpec itemSpec = new ItemSpec(project.ProjectPath, RecursionType.Full);

                LabelItemSpec[] labelItemSpec = new LabelItemSpec[] {
                    new LabelItemSpec(itemSpec, new DateVersionSpec(result.StartTime), false)
                };

                this.SourceControl.CreateLabel(vcLabel, labelItemSpec, LabelChildOption.Replace);
            }
        }
Example #2
0
        private void GetSource(SourceProject project, IIntegrationResult result)
        {
            if (project.CleanCopy)
            {
                // If we have said we want a clean copy, then delete old copy before getting.
                Log.Debug("Deleting " + project.WorkingDirectory);
                DeleteDirectory(project.WorkingDirectory);
            }

            Workspace[] workspaces = this.SourceControl.QueryWorkspaces(Workspace, this.SourceControl.AuthorizedUser, Workstation.Current.Name);
            Workspace   workspace  = null;

            if (workspaces.Length > 0)
            {
                // The workspace exists.
                if (DeleteWorkspace)
                {
                    // We have asked for a new workspace every time, therefore delete the existing one.
                    Log.Debug("Removing existing workspace " + Workspace);
                    this.SourceControl.DeleteWorkspace(Workspace, this.SourceControl.AuthorizedUser);
                    workspaces = new Workspace[0];
                }
                else
                {
                    Log.Debug("Existing workspace detected - reusing");
                    workspace = workspaces[0];
                }
            }
            if (workspaces.Length == 0)
            {
                Log.Debug("Creating new workspace name: " + Workspace);
                workspace = this.SourceControl.CreateWorkspace(Workspace, this.SourceControl.AuthorizedUser, DEFAULT_WORKSPACE_COMMENT);
            }

            try
            {
                workspace.Map(project.ProjectPath, project.WorkingDirectory);

                Log.Debug(String.Format("Getting {0} to {1}", project.ProjectPath, project.WorkingDirectory));

                VersionSpec verSpec = LatestVersionSpec.Instance;
                if (project.ApplyLabel)
                {
                    verSpec = new LabelVersionSpec(result.Label);
                }
                else if (!String.IsNullOrEmpty(project.Label))
                {
                    verSpec = new LabelVersionSpec(project.Label);
                }

                GetRequest getReq = new GetRequest(new ItemSpec(project.ProjectPath, RecursionType.Full), verSpec);

                if (project.CleanCopy)
                {
                    Log.Debug("Forcing a Get Specific with the options \"get all files\" and \"overwrite read/write files\"");
                    workspace.Get(getReq, GetOptions.GetAll | GetOptions.Overwrite);
                }
                else
                {
                    Log.Debug("Performing a Get Latest");
                    workspace.Get(getReq, GetOptions.None);
                }
            }
            finally
            {
                if (workspace != null && DeleteWorkspace)
                {
                    Log.Debug("Deleting the workspace");
                    workspace.Delete();
                }
            }
        }