当前位置: 首页>>代码示例>>C#>>正文


C# Workspace.GetPendingChanges方法代码示例

本文整理汇总了C#中Microsoft.TeamFoundation.VersionControl.Client.Workspace.GetPendingChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.GetPendingChanges方法的具体用法?C# Workspace.GetPendingChanges怎么用?C# Workspace.GetPendingChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.TeamFoundation.VersionControl.Client.Workspace的用法示例。


在下文中一共展示了Workspace.GetPendingChanges方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteFolder

        /// <summary>
        /// 'Pends' a delete of a folder and its contents that was previously 
        /// checked-in and then commits that deletion to the repository.
        /// </summary>
        /// <param name="workspace">Version control workspace to use when 
        /// deleting the folder and its contents.</param>
        /// <param name="newFilename">Full path to the folder to delete</param>
        /// <exception cref="SecurityException">If the user doesn't have
        /// check-in permission for the specified <paramref name="workspace"/>.</exception>
        /// <exception cref="IOException">If there's a problem creating the file.</exception>
        /// <exception cref="VersionControlException">If </exception>
        private static void DeleteFolder(Workspace workspace, String newFolder)
        {
            Debug.Assert(workspace != null);
            Debug.Assert(!String.IsNullOrEmpty(newFolder));

            try
            {
                // Delete the items
                workspace.PendDelete(workspace.GetServerItemForLocalItem(newFolder), RecursionType.Full);
                var pendingDeletes = workspace.GetPendingChanges();

                if (pendingDeletes.Length > 0)
                {
                    workspace.CheckIn(pendingDeletes, "Clean up!");
                }
            }
            catch (VersionControlException ex)
            {
                Console.Error.WriteLine("Error deleting file: {0}", ex.Message);
                throw;
            }
        }
开发者ID:spraints,项目名称:svn2tfs,代码行数:33,代码来源:Program.cs

示例2: AddToTFVC

        public bool AddToTFVC(string[] _files, WorkItem _wi, Workspace _ws)
        {
            try
             {
                 _ws.Get();
                 // Now add everything.
                 _ws.PendAdd(_files, false);
                 WorkItemCheckinInfo[] _wici = new WorkItemCheckinInfo[1];

                 _wici[0] = new WorkItemCheckinInfo(_wi, WorkItemCheckinAction.Associate);

                 if (_ws.CheckIn(_ws.GetPendingChanges(), null, null, _wici, null) > 0)
                 {
                     _ws.Delete();
                     return true;

                 }
                 else
                 {
                     return false;
                 }

             }
             catch
             {
                 return false;
             }
        }
开发者ID:hopenbr,项目名称:HopDev,代码行数:28,代码来源:TFVC.cs

示例3: ModifyFile

        /// <summary>
        /// 'Pends' a change to a file that was previously checked-in and then checks
        /// that change into the repository.
        /// </summary>
        /// <param name="workspace">Version control workspace to use when 
        /// changing the folder and file.</param>
        /// <param name="newFilename">Full path to the file to change</param>
        /// <exception cref="SecurityException">If the user doesn't have
        /// check-in permission for the specified <paramref name="workspace"/>.</exception>
        /// <exception cref="IOException">If there's a problem creating the file.</exception>
        /// <exception cref="VersionControlException">If </exception>
        private static void ModifyFile(Workspace workspace, String newFilename)
        {
            Debug.Assert(workspace != null);
            Debug.Assert(!String.IsNullOrEmpty(newFilename));

            try
            {
                // Checkout and modify the file
                workspace.PendEdit(newFilename);

                using (var streamWriter = new StreamWriter(newFilename))
                {
                    streamWriter.WriteLine("Revision 2");
                }

                // Get the pending change and check in the new revision.
                var pendingChanges = workspace.GetPendingChanges();
                int changesetForChange = workspace.CheckIn(pendingChanges, "Modified file contents");
                Console.WriteLine("Checked in changeset {0}", changesetForChange);
            }
            catch (IOException ex)
            {
                Console.Error.WriteLine("Error writing {1}: {0}", ex.Message, newFilename);
                throw;
            }
            catch (VersionControlException ex)
            {
                Console.Error.WriteLine("Error modifying file: {0}", ex.Message);
                throw;
            }
        }
开发者ID:spraints,项目名称:svn2tfs,代码行数:42,代码来源:Program.cs

示例4: BranchFile

        /// <summary>
        /// 'Pends' a branch of a file that was previously checked-in and then checks
        /// that branch into the repository.
        /// </summary>
        /// <param name="workspace">Version control workspace to use when 
        /// branching the folder and file.</param>
        /// <param name="newFilename">Full path to the file to branch</param>
        /// <exception cref="VersionControlException">If there's a problem performing
        /// the branch operation.</exception>
        private static void BranchFile(Workspace workspace, String newFilename)
        {
            Debug.Assert(workspace != null);
            Debug.Assert(!String.IsNullOrEmpty(newFilename));

            String branchedFilename = Path.Combine(Path.GetDirectoryName(newFilename),
                Path.GetFileNameWithoutExtension(newFilename)) + "-branch" +
                Path.GetExtension(newFilename);

            workspace.PendBranch(newFilename, branchedFilename, VersionSpec.Latest,
                LockLevel.Checkin, true);

            var pendingChanges = workspace.GetPendingChanges();
            int changesetForBranch = workspace.CheckIn(pendingChanges, "Branched file");
            Console.WriteLine("Branched {0} to {1} in changeset {2}", newFilename,
                branchedFilename, changesetForBranch);
        }
开发者ID:spraints,项目名称:svn2tfs,代码行数:26,代码来源:Program.cs

示例5: AddNewFile

        /// <summary>
        /// 'Pends' the add of a new folder and file and then checks it into the 
        /// repository.
        /// </summary>
        /// <param name="workspace">Version control workspace to use when 
        /// adding the folder and file.</param>
        /// <param name="newFilename">Full path to the file to add (the path
        /// of the folder will be derived from the file's path.</param>
        /// <exception cref="SecurityException">If the user doesn't have
        /// check-in permission for the specified <paramref name="workspace"/>.</exception>
        /// <exception cref="IOException">If there's a problem creating the file.</exception>
        /// <exception cref="VersionControlException">If </exception>
        private static void AddNewFile(Workspace workspace, String newFilename)
        {
            Debug.Assert(workspace != null);
            Debug.Assert(!String.IsNullOrEmpty(newFilename));
            Debug.Assert(!File.Exists(newFilename));

            if (!workspace.HasCheckInPermission)
            {
                throw new SecurityException(
                    String.Format("{0} does not have check-in permission for workspace: {1}",
                        workspace.VersionControlServer.AuthenticatedUser,
                        workspace.DisplayName));
            }

            try
            {
                // create the new file
                using (var streamWriter = new StreamWriter(newFilename))
                {
                    streamWriter.WriteLine("Revision 1");
                }

                // Now pend the add of our new folder and file
                workspace.PendAdd(Path.GetDirectoryName(newFilename), true);

                // Show our pending changes
                var pendingAdds = new List<PendingChange>((IEnumerable<PendingChange>)
                    workspace.GetPendingChanges());

                pendingAdds.ForEach(delegate(PendingChange add)
                {
                    Console.WriteLine("\t{1}: {0}",
                        add.LocalItem, PendingChange.GetLocalizedStringForChangeType(add.ChangeType));
                });

                // Checkin the items we added
                int changesetForAdd = workspace.CheckIn(pendingAdds.ToArray(), "Initial check-in");
                Console.WriteLine("Checked in changeset {0}", changesetForAdd);
            }
            catch (IOException ex)
            {
                Console.Error.WriteLine("Error writing {1}: {0}", ex.Message, newFilename);
                throw;
            }
            catch (VersionControlException ex)
            {
                Console.Error.WriteLine("Error adding file: {0}", ex.Message);
                throw;
            }
        }
开发者ID:spraints,项目名称:svn2tfs,代码行数:62,代码来源:Program.cs

示例6: TryGetPendingChanges

        public bool TryGetPendingChanges(out PendingChange[] pendingChanges, Workspace workspace, string[] items)
        {
            try
            {
                pendingChanges = workspace.GetPendingChanges(items);
                return true;
            }
            catch (Exception ex)
            {
                this.Logger().DebugException(ex);
                LastException = ex;
            }

            pendingChanges = null;
            return false;
        }
开发者ID:BruceMellows,项目名称:TeamPilgrim,代码行数:16,代码来源:TeamPilgrimServiceModelProvider.cs

示例7: CreateShelveset

        /// <summary>
        /// 
        /// </summary>
        /// <param name="service"></param>
        /// <param name="workspace"></param>
        /// <param name="force">True when the user manually initiates a ShelveSet via the Team menu or mapped shortcut key.</param>
        private void CreateShelveset(VersionControlServer service, Workspace workspace, bool force)
        {
            // Build event args for notification create shelveset result
            var autoShelveEventArg = new ShelvesetCreatedEventArgs();

            try
            {
                // If there are no pending changes that have changed since the last shelveset then there is nothing to do
                bool isDelta = false;
                var pendingChanges = workspace.GetPendingChanges();
                int numPending = pendingChanges.Count();

                if (!force && numPending > 0)
                {
                    // Compare numPending to numItemsShelved;  Force shelveset if they differ
                    // Otherwise, resort to comparing file HashValues
                    var lastShelveset = GetPastShelvesets(service, workspace).FirstOrDefault();
                    var shelvedChanges = service.QueryShelvedChanges(lastShelveset)[0].PendingChanges;
                    int numItemsShelved = lastShelveset == null ? 0 : shelvedChanges.Count();
                    isDelta = (numPending != numItemsShelved) || pendingChanges.DifferFrom(shelvedChanges);
                }
                autoShelveEventArg.ShelvesetChangeCount = (force || isDelta) ? numPending : 0;
                if (force || isDelta)
                {
                    // Build a new, valid shelve set name
                    var setname = string.Format(ShelvesetName, workspace.Name, workspace.OwnerName, DateTime.Now, workspace.OwnerName.GetDomain(), workspace.OwnerName.GetLogin());
                    setname = CleanShelvesetName(setname);

                    // Actually create a new Shelveset 
                    var shelveset = new Shelveset(service, setname, workspace.OwnerName);
                    autoShelveEventArg.ShelvesetName = setname;
                    shelveset.Comment = string.Format("Shelved by {0}. {1} items", _extensionName, numPending);
                    workspace.Shelve(shelveset, pendingChanges, ShelvingOptions.Replace);

                    // Clean up past Shelvesets
                    if (MaximumShelvesets > 0)
                    {
                        foreach (var set in GetPastShelvesets(service, workspace).Skip(MaximumShelvesets))
                        {
                            service.DeleteShelveset(set);
                            autoShelveEventArg.ShelvesetsPurgeCount++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _tfsExt = null; // Force re-init on next attempt
                autoShelveEventArg.ExecutionException = ex;
            }
            // Fire event for each VS instance to report results
            if (OnShelvesetCreated != null)
            {
                OnShelvesetCreated(this, autoShelveEventArg);
            }
        }
开发者ID:modulexcite,项目名称:tfsautoshelve,代码行数:62,代码来源:TfsAutoShelve.cs

示例8: CheckIn

 /// <summary>
 /// Check In all pending changes within the workspace
 /// </summary>
 /// <param name="_ws">
 /// workspace with pending changes
 /// </param>
 /// <returns>
 /// true if check-in is successful
 /// </returns>
 public bool CheckIn(Workspace _ws)
 {
     try
     {
         _ws.CheckIn(_ws.GetPendingChanges(), null);
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:hopenbr,项目名称:HopDev,代码行数:21,代码来源:TFS.cs

示例9: GetPendingChangesByFile

 private static List<PendingChange> GetPendingChangesByFile(List<MergeRelation> mergeRelationships, string targetBranch, Workspace workspace)
 {
     var itemSpecs = new List<ItemSpec>();
     foreach (var mergeRelationship in mergeRelationships)
     {
         if (mergeRelationship.Target.StartsWith(targetBranch))
         {
             var recursionType = CalculateRecursionType(mergeRelationship);
             itemSpecs.Add(new ItemSpec(mergeRelationship.Target, recursionType));
         }
     }
     return workspace.GetPendingChanges(itemSpecs.ToArray()).ToList();
 }
开发者ID:Manuel-S,项目名称:AutoMerge,代码行数:13,代码来源:BranchesViewModel.cs

示例10: HasPendingChanges

 public bool HasPendingChanges(Workspace workspace, string localItem)
 {
     return workspace.GetPendingChanges(localItem).Length != 0;
 }
开发者ID:vardars,项目名称:ci-factory,代码行数:4,代码来源:TfsVersionControlFunctions.cs

示例11: IsCheckedOut

        public static bool IsCheckedOut(Workspace workspace, string path)
        {
            if (workspace == null)
            {
                return false;
            }

            try
            {
                foreach (PendingChange change in workspace.GetPendingChanges(path))
                {
                    if ((change.ChangeType & (ChangeType.Edit | ChangeType.Add)) > 0)
                    {
                        return true;
                    }
                }
            }
            catch
            {
            }

            return false;
        }
开发者ID:garyjohnson,项目名称:wpnest,代码行数:23,代码来源:Tfs.cs


注:本文中的Microsoft.TeamFoundation.VersionControl.Client.Workspace.GetPendingChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。