示例#1
0
        public void Add(BatchedItem change)
        {
            if (change == null)
            {
                throw new ArgumentNullException("change");
            }

            lock (m_locker)
            {
                if (!acceptingNewChanges)
                {
                    Debug.Fail("ChangeOprimizer is not accepting new changes");
                }

                if (change.Action == WellKnownChangeActionId.Rename)
                {
                    bool addToRenameList = true;
                    foreach (BatchedItem existingRenameChange in m_unresolvedRenames)
                    {
                        if (TfsUtil.isChildItemOf(change, existingRenameChange))
                        {
                            addToRenameList = false;
                            break;
                        }
                    }
                    if (addToRenameList)
                    {
                        m_unresolvedRenames.Add(change);
                    }
                    else
                    {
                        m_implicitRenames.Add(change.Target);
                    }

                    if (!m_renamePairs.ContainsKey(change.Target))
                    {
                        m_renamePairs.Add(change.Target, change.Source);
                    }
                }
                else if ((change.Action == WellKnownChangeActionId.Branch) ||
                         (change.Action == WellKnownChangeActionId.Add) ||
                         (change.Action == WellKnownChangeActionId.Undelete))
                {
                    m_unresolvedAdditiveActions.Add(change);
                }
                else
                {
                    // Deletes, Edits or Encodings
                    m_unresolvedChanges.Add(change);
                }
            }
        }
        private static void deleteFiles_inner(string directory)
        {
            foreach (string file in Directory.GetFiles(directory))
            {
                TfsUtil.DeleteFile(file);
            }

            foreach (string subDirectory in Directory.GetDirectories(directory))
            {
                deleteFiles_inner(subDirectory);
                Directory.Delete(subDirectory);
            }
        }
示例#3
0
        private int[] getMappedTfsChange()
        {
            m_hwmDelta.Reload();


            Debug.Assert(m_hwmDelta.Value >= 0, "High water mark of delta table must be non-negtive");

            int latestChangeset = m_tfsClient.GetLatestChangesetId();

            // No new changesets on server, return.
            if (m_hwmDelta.Value >= latestChangeset)
            {
                return(new int[0]);
            }

            int startingChangeset = m_hwmDelta.Value + 1;

            string skipComment     = ConfigurationService.GetValue <string>(Constants.SkipComment, "**NOMIGRATION**");
            string commentModifier = ConfigurationService.GetValue <string>(Constants.CommentModifier, TfsVCAdapterResource.DefaultCommentModifier);

            SortedDictionary <int, bool> mappedChangesets = new SortedDictionary <int, bool>();

            foreach (MappingEntry m in ConfigurationService.Filters)
            {
                if (m.Cloak)
                {
                    continue;
                }
                try
                {
                    foreach (Changeset changeset in m_tfsClient.QueryHistory(m.Path,
                                                                             VersionSpec.Latest,
                                                                             0,
                                                                             RecursionType.Full,
                                                                             null,
                                                                             new ChangesetVersionSpec(startingChangeset),
                                                                             new ChangesetVersionSpec(latestChangeset),
                                                                             int.MaxValue, // All changes
                                                                             false,
                                                                             true))
                    {
                        if (mappedChangesets.ContainsKey(changeset.ChangesetId))
                        {
                            continue;
                        }

                        if (TfsUtil.IsOurTfsChange(changeset, TranslationService, m_conflictManagementService.SourceId))
                        {
                            TraceManager.TraceInformation("Skipping mirrored change {0}", changeset.ChangesetId);
                            continue;
                        }

                        if (!string.IsNullOrEmpty(skipComment))
                        {
                            if (changeset.Comment != null && changeset.Comment.Contains(skipComment))
                            {
                                TraceManager.TraceInformation("Changeset {0} contains the skip comment {1}",
                                                              changeset.ChangesetId,
                                                              skipComment);
                                continue;
                            }
                        }

                        if (!mappedChangesets.ContainsKey(changeset.ChangesetId))
                        {
                            mappedChangesets.Add(changeset.ChangesetId, true);
                        }
                    }
                }
                catch (ItemNotFoundException)
                {
                    // the path does not contain any changesets
                }
            }
            if (mappedChangesets.Count > 0)
            {
                int[] mappedChangesetsArray = new int[mappedChangesets.Count];
                mappedChangesets.Keys.CopyTo(mappedChangesetsArray, 0);
                return(mappedChangesetsArray);
            }
            else
            {
                // No new changesets are found, update the HWM as current latest
                m_hwmDelta.Update(latestChangeset);
                return(new int[0]);
            }
        }