Esempio n. 1
0
        public static void MenuItemCallback(object sender, EventArgs e)
        {
            var origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            lastFolderDisplayed = null;

            Workspace myWorkspace = Utilities.vcext.Explorer.Workspace;
            Utilities.vcsrv.Getting += new GettingEventHandler(vcServer_Getting);

            foreach (string sourcePath in Utilities.vcext.Explorer.SelectedItems.Select(x => x.SourceServerPath))
            {
                Utilities.OutputCommandString("Previewing GET command for path: " + sourcePath);
                var getreq = new GetRequest(new ItemSpec(sourcePath, RecursionType.Full), VersionSpec.Latest);
                var status = myWorkspace.Get(getreq, GetOptions.Preview);

                Utilities.OutputCommandString("HaveResolvableWarnings=" + status.HaveResolvableWarnings);
                Utilities.OutputCommandString("NumConflicts=" + status.NumConflicts);
                Utilities.OutputCommandString("NumFailures=" + status.NumFailures);
                Utilities.OutputCommandString("NumOperations=" + status.NumOperations);
                Utilities.OutputCommandString("NumUpdated=" + status.NumUpdated);
                Utilities.OutputCommandString("NumWarnings=" + status.NumWarnings);
            }

            Utilities.vcsrv.Getting -= new GettingEventHandler(vcServer_Getting);

            Cursor.Current = origCursor;
        }
Esempio n. 2
0
        public GettingDialog(VersionControlServer vcs, Workspace workspace, GetRequest[] requests)
            : base("Progress")
        {
            VBox.Spacing = 10;
                VBox.Add(new Label("Getting files from the server..."));

                progressBar = new ProgressBar();
                VBox.Add(progressBar);

                fileLabel = new Label("");
                VBox.Add(fileLabel);

                AddCloseButton("Cancel");
                DefaultResponse = ResponseType.Cancel;

                ShowAll();

                getLatestList.Clear();
                vcs.Getting += MyGettingEventHandler;

                GetStatus status = workspace.Get(requests, GetOptions.GetAll|GetOptions.Overwrite);
                foreach (string file in getLatestList)
                    {
                        Console.WriteLine(file);
                        Pulse("Setting permissions: " + file);
                        if (! FileTypeDatabase.ShouldBeExecutable(file)) continue;
                        FileType.MakeExecutable(file);
                    }
        }
Esempio n. 3
0
 public static string GetDeploymentItems(string teamProjectName, string buildType)
 {
     string workspaceDirectory = SourceCodeControlHelper.GetWorkspaceDirectory("TFSDeployerConfiguration2");
     TeamProject teamProject = GetTeamProject(teamProjectName);
     ItemSpec configurationFileItemSpec = new ItemSpec(string.Format(ConfigurationFileLocation,teamProject.ServerItem,buildType),RecursionType.Full);
     VersionSpec version = VersionSpec.Latest;
     GetRequest[] request = new GetRequest[] { new GetRequest(configurationFileItemSpec, version) };
     string directoryToPlaceFiles  = string.Format(ConfigurationFileLocation, teamProject.ServerItem, buildType);
     TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Getting file from {0} to {1}",workspaceDirectory,directoryToPlaceFiles);
     SourceCodeControlHelper.GetLatestFromSourceCodeControl(directoryToPlaceFiles, workspaceDirectory, request);
     return workspaceDirectory;
 }
Esempio n. 4
0
        public static void GetLatestFromSourceCodeControl(string rootFolder,string workspaceDirectory,  GetRequest[] filesToRetrieve)
        {
            VersionControlServer versionControlServer = ServiceHelper.GetService<VersionControlServer>();
            string workspaceName = GetWorkspaceName();
            string workingDirectory = workspaceDirectory;

            TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Getting files from Source code control. RootFolder{0}, Workspace Directory:{1}, Working Directory: {2}",rootFolder,workspaceDirectory,workingDirectory);
            try
            {

                Workspace workspace = GetWorkspace(rootFolder, versionControlServer, workspaceName, workingDirectory);
                workspace.Get(filesToRetrieve, GetOptions.Overwrite);
            }
            finally
            {
                RemoveWorkspace(workspaceName, versionControlServer);
            }
        }
        public string GetFile(string soruceTFSLocation, string destinationFileLocation)
        {
            // File and path
            var fileDirectory = Path.GetDirectoryName(destinationFileLocation);
            var fileName = Path.GetFileName(destinationFileLocation);

            if (fileName == null)
            {
                throw new ArgumentException("Filename must not be null");
            }

            var fullPathToFile = Path.Combine(fileDirectory, fileName);

            // Write to the log
            _buildMessageWriter.WriteBuildMessage(string.Format("Getting file from Source: {0}", soruceTFSLocation), BuildMessageImportance.High);

            // Create workspace and working folder
            var tempWorkspace = _workspace.VersionControlServer.CreateWorkspace("Temp_NugetWorkSpace");
            var workingFolder = new WorkingFolder(soruceTFSLocation, fullPathToFile);

            // Map the workspace
            tempWorkspace.CreateMapping(workingFolder);

            // Get the file
            var request = new GetRequest(new ItemSpec(soruceTFSLocation, RecursionType.None), VersionSpec.Latest);
            var status = tempWorkspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);

            if (!status.NoActionNeeded)
            {
                foreach (var failure in status.GetFailures())
                {
                    _buildMessageWriter.WriteBuildMessage(string.Format("Failed to get file from source: {0} - {1}", soruceTFSLocation, failure.GetFormattedMessage()), BuildMessageImportance.High);
                }
            }

            // Get rid of the workspace
            tempWorkspace.Delete();

            return fullPathToFile;
        }
Esempio n. 6
0
        public GetStatus Get(GetRequest[] requests, GetOptions options, 
												 GetFilterCallback filterCallback, object userData)
        {
            bool force = ((GetOptions.Overwrite & options) == GetOptions.Overwrite);
            bool noGet = false; // not implemented below: ((GetOptions.Preview & options) == GetOptions.Preview);

            SortedList<int, DateTime> changesetDates = new SortedList<int, DateTime>();
            GetOperation[] getOperations = Repository.Get(Name, OwnerName, requests, force, noGet);
            if (null != filterCallback) filterCallback(this, getOperations, userData);

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);
            foreach (GetOperation getOperation in getOperations)
                {
                    string uPath = null;
                    GettingEventArgs args = new GettingEventArgs(this, getOperation);

                    // Console.WriteLine(getOperation.ToString());

                    if (getOperation.DeletionId != 0)
                        {
                            if ((getOperation.ItemType == ItemType.Folder)&&
                                    (Directory.Exists(getOperation.SourceLocalItem)))
                                {
                                    UnsetDirectoryAttributes(getOperation.SourceLocalItem);
                                    Directory.Delete(getOperation.SourceLocalItem, true);
                                }
                            else if ((getOperation.ItemType == ItemType.File)&&
                                             (File.Exists(getOperation.SourceLocalItem)))
                                {
                                    UnsetFileAttributes(getOperation.SourceLocalItem);
                                    File.Delete(getOperation.SourceLocalItem);
                                }
                        }
                    else if ((!String.IsNullOrEmpty(getOperation.TargetLocalItem))&&
                                     (!String.IsNullOrEmpty(getOperation.SourceLocalItem))&&
                                     (getOperation.SourceLocalItem != getOperation.TargetLocalItem))
                        {
                            uPath = getOperation.TargetLocalItem;
                            try
                                {
                                    File.Move(getOperation.SourceLocalItem, getOperation.TargetLocalItem);
                                }
                            catch (IOException)
                                {
                                    args.Status = OperationStatus.TargetIsDirectory;
                                }
                        }
                    else if (getOperation.ChangeType == ChangeType.None &&
                                     getOperation.VersionServer != 0)
                        {
                            uPath = getOperation.TargetLocalItem;
                            string directory = uPath;

                            if (getOperation.ItemType == ItemType.File)
                                directory = Path.GetDirectoryName(uPath);

                            if (!Directory.Exists(directory))
                                Directory.CreateDirectory(directory);

                            if (getOperation.ItemType == ItemType.File)
                                {
                                    DownloadFile.WriteTo(uPath, Repository, getOperation.ArtifactUri);

                                    // ChangesetMtimes functionality : none standard!
                                    if (mTimeSetting)
                                        {
                                            int cid = getOperation.VersionServer;
                                            DateTime modDate;

                                            if (!changesetDates.TryGetValue(cid, out modDate))
                                                {
                                                    Changeset changeset = VersionControlServer.GetChangeset(cid);
                                                    modDate = changeset.CreationDate;
                                                    changesetDates.Add(cid, modDate);
                                                }

                                            File.SetLastWriteTime(uPath, modDate);
                                        }

                                    // do this after setting the last write time!
                                    SetFileAttributes(uPath);
                                }
                        }

                    versionControlServer.OnDownloading(args);
                    updates.QueueUpdate(getOperation.ItemId, uPath, getOperation.VersionServer);
                }

            updates.Flush();
            return new GetStatus(getOperations.Length);
        }
Esempio n. 7
0
        public GetStatus Get(GetRequest request, GetOptions options, 
												 GetFilterCallback filterCallback, object userData)
        {
            GetRequest[] requests = new GetRequest[1];
            requests[0] = request;
            return Get(requests, options, filterCallback, userData);
        }
Esempio n. 8
0
 public GetStatus Get(GetRequest[] requests, GetOptions options)
 {
     return Get(requests, options, null, null);
 }
Esempio n. 9
0
 public GetStatus Get(VersionSpec versionSpec, GetOptions options)
 {
     GetRequest request = new GetRequest(versionSpec);
     return Get(request, GetOptions.None, null, null);
 }
        private void Deploy()
        {
            TfsTeamProjectCollection collection;

            // if setting "Domen" in config file initialized - it means that test run on the local machine, 
            // otherwise means that test run on the specialized testing machine
            if (string.IsNullOrEmpty(ConfigHelper.Instance.Domen))
                collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.TestCollection));
            else
                collection = new TfsTeamProjectCollection(
                    new Uri(ConfigHelper.Instance.TestCollection),
                    new NetworkCredential(ConfigHelper.Instance.Login, ConfigHelper.Instance.Password, ConfigHelper.Instance.Domen));

            var vcs = collection.GetService<VersionControlServer>();
            TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.TestCollectionProject);

            string workspaceName = "MyWorkspace";
            string projectPath = tp.ServerItem;
            string workingDirectory = ClonedRepoFolder;

            if (Directory.Exists(workingDirectory))
            {
                var files = Directory.GetFiles(workingDirectory, "*.*", SearchOption.AllDirectories);
                foreach (var file in files)
                    File.SetAttributes(file, File.GetAttributes(file) & ~FileAttributes.ReadOnly);

                Directory.Delete(workingDirectory, true);
            }
                
            Directory.CreateDirectory(workingDirectory);

            Workspace[] workspaces = vcs.QueryWorkspaces(workspaceName, vcs.AuthorizedUser, Workstation.Current.Name);
            if (workspaces.Length > 0)
                vcs.DeleteWorkspace(workspaceName, vcs.AuthorizedUser);

            _workspace = vcs.CreateWorkspace(workspaceName, vcs.AuthorizedUser, "Test Workspace");

            try
            {
                _workspace.Map(projectPath, workingDirectory);
                GetRequest request = new GetRequest(new ItemSpec(projectPath, RecursionType.Full), VersionSpec.Latest);
                GetStatus status = _workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite); 
            }
            catch
            {}
            
        }
Esempio n. 11
0
        public void GetSource(IIntegrationResult result)
        {
            if (AutoGetSource)
            {
                this.WorkingDirectory = result.BaseFromWorkingDirectory(this.WorkingDirectory);

                if (CleanCopy)
                {
                    // If we have said we want a clean copy, then delete old copy before getting.
                    Log.Debug("Deleting " + this.WorkingDirectory);
                    this.deleteDirectory(this.WorkingDirectory);
                }

                Workspace[] workspaces = this.SourceControl.QueryWorkspaces(Workspace, this.SourceControl.AuthenticatedUser, 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.AuthenticatedUser);
                        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.AuthenticatedUser, DEFAULT_WORKSPACE_COMMENT);
                }

                try
                {
                    workspace.Map(ProjectPath, WorkingDirectory);

                    Log.Debug(String.Format("Getting {0} to {1}", ProjectPath, WorkingDirectory));
                    GetRequest getReq = new GetRequest(new ItemSpec(ProjectPath, RecursionType.Full), this.WorkingVersion);
                    if (CleanCopy || Force)
                    {
                        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();
                    }
                }

            }

        }
Esempio n. 12
0
        public GetOperation[] Get(string workspaceName, string ownerName, 
															GetRequest[] requests, bool force, bool noGet)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "Get");
            msg.Body.WriteElementString("workspaceName", workspaceName);
            msg.Body.WriteElementString("ownerName", ownerName);

            msg.Body.WriteStartElement("requests");
            foreach (GetRequest request in requests)
                {
                    request.ToXml(msg.Body, "");
                }
            msg.Body.WriteEndElement();

            msg.Body.WriteElementString("force", force.ToString().ToLower());
            msg.Body.WriteElementString("noGet", noGet.ToString().ToLower());

            List<GetOperation> operations = new List<GetOperation>();
            using (HttpWebResponse response = Invoke(msg))
                {
                    XmlReader results = msg.ResponseReader(response);

                    while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.Element &&
                                    results.Name == "GetOperation")
                                operations.Add(GetOperation.FromXml(ItemUrl, results));
                        }
                }

            return operations.ToArray();
        }
		private void Deploy()
		{
			var collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.FuncTestCollection));
			var vcs = collection.GetService<VersionControlServer>();
			TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.FuncTestsProject);

			const string workspaceName = "MyWorkspace";

			Workspace[] workspaces = vcs.QueryWorkspaces(workspaceName, vcs.AuthorizedUser, Workstation.Current.Name);
			foreach (var workspace in workspaces)
			{
				foreach (var workingFolder in workspace.Folders)
				{
					if (Directory.Exists(workingFolder.LocalItem))
					{
						var files = Directory.GetFiles(workingFolder.LocalItem, "*.*", SearchOption.AllDirectories);
						foreach (var file in files)
							File.SetAttributes(file, File.GetAttributes(file) & ~FileAttributes.ReadOnly);

						Directory.Delete(workingFolder.LocalItem, true);
					}
					workspace.DeleteMapping(workingFolder);
				}
				vcs.DeleteWorkspace(workspace.Name, vcs.AuthorizedUser);
			}

			string projectPath = tp.ServerItem;
			string workingDirectory = ClonedRepoFolder;

			Directory.CreateDirectory(workingDirectory);

			_workspace = vcs.CreateWorkspace(workspaceName, vcs.AuthorizedUser, "Test Workspace");

			try
			{
				_workspace.Map(projectPath, workingDirectory);
				GetRequest request = new GetRequest(new ItemSpec(projectPath, RecursionType.Full), VersionSpec.Latest);
				GetStatus status = _workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);
			}
			catch
			{
				throw;
			}
		}
 public void Get(string strServerPath)
 {
     GetRequest getRequest = new GetRequest(strServerPath, RecursionType.Full, VersionSpec.Latest);
     this.Workspace.Get(getRequest, GetOptions.Overwrite);
 }
Esempio n. 15
0
 public void GetLatest(string element, string wsname, string owner)
 {
     Workspace ws = this.GetWorkSpace(wsname, owner);
      GetRequest getreq = new GetRequest(element, RecursionType.None, VersionSpec.Latest);
      ws.Get(getreq, GetOptions.Overwrite, null, null);
 }
Esempio n. 16
0
        protected override void ExecuteTask()
        {
            //TODO: Adding the alternet use of a fileset instead of the LocalItem property
            Workspace MyWorkspace = this.WorkspaceHelper.GetWorkspace(this.WorkspaceName, this.LocalItem, this.ServerConnection);

            GetOptions Options = this.GetGetOptions();

            this.ServerConnection.SourceControl.Getting += new GettingEventHandler(OnGet);

            GetStatus Status = null;

            if (!String.IsNullOrEmpty(this.ServerItem))
            {
                RecursionType Recursion = RecursionType.None;
                if (this.Recursive)
                    Recursion = RecursionType.Full;

                GetRequest GetReq = new GetRequest(new ItemSpec(this.ServerItem, Recursion), this.VersionSpec.GetVersionSpec());
                Status = MyWorkspace.Get(GetReq, Options);
            }
            else
            {
                Status = MyWorkspace.Get(this.VersionSpec.GetVersionSpec(), Options);
            }

            this.ServerConnection.SourceControl.Getting -= new GettingEventHandler(OnGet);

            if (this.IsInteractive && (Status.NumConflicts > 0 || Status.HaveResolvableWarnings))
            {
                Object ResolveObject = ResolveConflictsMethod.Invoke(null, new object[] { MyWorkspace, this.ListOfFilesGotten.ToArray() });
                int unresolvedConflictCount = (int)UnresolvedConflictCountProperty.GetValue(ResolveObject, null);
                if (unresolvedConflictCount == 0)
                {
                    this.Failed = false;
                    this.Log(Level.Verbose, "All conflicts have been resolved.");
                }
                else
                {
                    this.Log(Level.Error, "{0} conflict(s) have not been resolved!", unresolvedConflictCount);
                }
            }

            if (this.Failed)
                throw new BuildException("Failed to get from TFS version control successfully!");
        }
 private string GetLatestVerstion(VersionControlServer versionControl, TfsGetCodeParams objTfsGetCodeParams)
 {
     Workspace[] workspaces = versionControl.QueryWorkspaces(objTfsGetCodeParams.WorkStationName, versionControl.AuthenticatedUser, Workstation.Current.Name);
     if (workspaces.Length > 0)
     {
         versionControl.DeleteWorkspace(objTfsGetCodeParams.WorkStationName, versionControl.AuthenticatedUser);
     }
     Workspace workspace = versionControl.CreateWorkspace(objTfsGetCodeParams.WorkStationName, versionControl.AuthenticatedUser, "Temporary Workspace");
     try
     {
         workspace.Map(objTfsGetCodeParams.SourcePath, objTfsGetCodeParams.TargetPath+"/"+objTfsGetCodeParams.BuildVersion );
         GetRequest request = new GetRequest(new ItemSpec(objTfsGetCodeParams.SourcePath, RecursionType.Full), VersionSpec.Latest);
         GetStatus status = workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite); // this line doesn't do anything - no failures or errors
         return "done";
     }
     finally
     {
         if (workspace != null)
         {
             workspace.Delete();
         }
     }
 }
Esempio n. 18
0
 public void GetFromRepository(Workspace workspace, GetRequest[] requests)
 {
     using (GettingDialog gettingDialog = new GettingDialog(currentVcs, workspace, requests))
         {
             gettingDialog.ShowAll();
             gettingDialog.Run();
             gettingDialog.Destroy();
         }
 }
        public void GetSource(IIntegrationResult result)
        {
            this.ChangesetQueue.BeginIntegration();
            Changeset Set = this.ChangesetQueue.GetCurrentIntegrationSet();

            string ChangesetIdTo = ChangesetIdTo = Set.ChangesetId.ToString();
            result.AddIntegrationProperty("CCNetVSTSChangeSetId", ChangesetIdTo);

            if (AutoGetSource)
            {
                if (CleanCopy)
                {
                    // If we have said we want a clean copy, then delete old copy before getting.
                    Log.Debug("Deleting " + this.WorkingDirectory);
                    this.DeleteDirectory(this.WorkingDirectory);
                }

                Workspace[] Workspaces = this.SourceControl.QueryWorkspaces(Workspace, this.SourceControl.AuthenticatedUser, Workstation.Current.Name);
                Workspace MyWorkspace = 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.AuthenticatedUser);
                        Workspaces = new Workspace[0];
                    }
                    else
                    {
                        Log.Debug("Existing workspace detected - reusing");
                        MyWorkspace = Workspaces[0];
                    }
                }
                if (Workspaces.Length == 0)
                {
                    Log.Debug("Creating new workspace name: " + Workspace);
                    MyWorkspace = this.SourceControl.CreateWorkspace(Workspace, this.SourceControl.AuthenticatedUser, "Created By CCNet vstsbychangesetSourceControl.");
                }

                try
                {
                    MyWorkspace.Map(ProjectPath, WorkingDirectory);

                    Log.Debug(String.Format("Getting {0} to {1}", ProjectPath, WorkingDirectory));
                    GetRequest GetInfo;
                    GetInfo = new GetRequest(new ItemSpec(ProjectPath, RecursionType.Full), Set.ChangesetId);

                    this.SourceControl.Getting += new GettingEventHandler(OnGet);
                    if (CleanCopy || Force)
                    {
                        Log.Debug("Forcing a Get Specific with the options \"get all files\" and \"overwrite read/write files\"");
                        MyWorkspace.Get(GetInfo, GetOptions.GetAll | GetOptions.Overwrite);
                    }
                    else
                    {
                        Log.Debug("Performing a Get Latest");
                        MyWorkspace.Get(GetInfo, GetOptions.None);
                    }
                }
                finally
                {
                    if (MyWorkspace != null && DeleteWorkspace)
                    {
                        Log.Debug("Deleting the workspace");
                        MyWorkspace.Delete();
                    }
                    this.SourceControl.Getting -= new GettingEventHandler(OnGet);
                }
            }
        }
Esempio n. 20
0
        protected override void Execute(CodeActivityContext context)
        {
            #region Workflow Arguments

            // The TFS source location of the file to get
            var fileToGet = context.GetValue(FileToGet);

            // The current workspace - used to create a new workspace for the get
            var workspace = context.GetValue(Workspace);

            // The local build directory
            var buildDirectory = context.GetValue(BuildDirectory);

            #endregion

            // Version seed file and path
            var versionFileDirectory = string.Format("{0}\\VersionSeed", buildDirectory);
            var filename = Path.GetFileName(fileToGet);
            var fullPathToSeedFile = Path.Combine(versionFileDirectory, filename);

            // Return the value back to the workflow
            context.SetValue(FullPathToSeedFile, fullPathToSeedFile);

            // Write to the log
            context.WriteBuildMessage(string.Format("Getting file from Source: {0}", fileToGet),
                                      BuildMessageImportance.High);
            context.WriteBuildMessage(string.Format("Placing version seed file in: {0}", versionFileDirectory),
                                      BuildMessageImportance.High);

            try
            {
                // Create workspace and working folder
                var tempWorkspace = workspace.VersionControlServer.CreateWorkspace("VersionSeed");
                var workingFolder = new WorkingFolder(fileToGet, fullPathToSeedFile);

                // Map the workspace
                tempWorkspace.CreateMapping(workingFolder);

                // Get the file
                var request = new GetRequest(new ItemSpec(fileToGet, RecursionType.None), VersionSpec.Latest);
                var status = tempWorkspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);

                if (!status.NoActionNeeded)
                {
                    foreach (var failure in status.GetFailures())
                    {
                        context.WriteBuildMessage(
                            string.Format("Failed to get file from source: {0} - {1}", fileToGet,
                                          failure.GetFormattedMessage()), BuildMessageImportance.High);
                    }
                }

                // Return the value back to the workflow
                context.SetValue(FullPathToSeedFile, fullPathToSeedFile);

                // Get rid of the workspace
                tempWorkspace.Delete();
            }
            catch (Exception)
            {
                context.WriteBuildMessage(string.Format("Seed file exists in '{0}'. Using existing file.", versionFileDirectory),
                    BuildMessageImportance.High);
            }
        }
 protected override void OnRevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
 {
     var spec = new ItemSpec(localPath, localPath.IsDirectory ? RecursionType.Full : RecursionType.None);
     var rev = (TFSRevision)revision;
     var request = new GetRequest(spec, new ChangesetVersionSpec(rev.Version));
     var workspace = GetWorkspaceByLocalPath(localPath);
     if (workspace != null)
     {
         workspace.Get(request, GetOptions.None, monitor);
         cache.RefreshItem(localPath);
     }
 }
Esempio n. 22
0
        public void UpdateLocalWorkspace(SourceControlContext context)
        {
            using (var tfs = this.GetTeamProjectCollection())
            {
                var versionControlServer = tfs.GetService<VersionControlServer>();

                var workspace = this.GetMappedWorkspace(versionControlServer, (TfsSourceControlContext)context);
                if (context.Label != null)
                {
                    string sourcePath = ((TfsSourceControlContext)context).SourcePath;
                    var getRequest = new GetRequest(new ItemSpec(sourcePath, RecursionType.Full), VersionSpec.ParseSingleSpec("L" + context.Label, versionControlServer.AuthorizedUser));
                    workspace.Get(getRequest, GetOptions.Overwrite);
                }
                else
                {
                    workspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
                }
            }
        }