Esempio n. 1
0
        /// <summary>
        /// Compare 'Action', 'Source', and 'Target' of the current item with the provided item.
        /// The current item is the child of the provided item if
        /// 1. Actions are the same
        /// 2. Parent items's Target is the sub-item of the current item's Target.
        /// 3. For rename/branch/merge, Parent item's Source is the sub-item of the item's Source and postfix sould be the same.
        /// </summary>
        /// <param name="parentItem">Item to be compared</param>
        /// <returns>True if the provided item is the parent of the current item.</returns>
        public static bool isChildItemOf(BatchedItem item, BatchedItem parentItem)
        {
            if ((parentItem == null) || (parentItem.Target == null) || (item == null) || (item.Target == null))
            {
                return(false);
            }

            if ((item.Action == parentItem.Action) && (VersionControlPath.IsSubItem(item.Target, parentItem.Target)))
            {
                if ((item.Action == WellKnownChangeActionId.Rename) && (VersionControlPath.IsSubItem(item.Source, parentItem.Source)))
                {
                    //Construct a canonlized serverpath instead of a truncated path to avoid assertion failure in TFC debug build.
                    string sourcePostFix     = item.Source.Substring(parentItem.Source.Length);
                    string constructedTarget = ConcatWithoutDoubleSlashes(parentItem.Target, sourcePostFix);
                    if (VersionControlPath.EqualsCaseSensitive(item.Target, constructedTarget))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }