Example #1
0
        private static void IncrementOperations(GitProviderTests.FollowResult result, ChangeItem item)
        {
            result.FinalName = item.ServerPath;
            if (item.IsAdd())
            {
                result.Add++;
            }

            if (item.IsEdit())
            {
                result.Modify++;
            }

            if (item.IsRename())
            {
                result.Rename++;
            }

            if (item.IsCopy())
            {
                result.Copy++;
            }

            if (item.IsDelete())
            {
                result.Delete++;
            }
        }
Example #2
0
        private void ParseLogEntry(XmlReader reader, List <ChangeSet> result)
        {
            var cs = new ChangeSet();


            // revision -> Id
            var revision = ReadRevision(reader);

            cs.Id = revision;
            _tracking.BeginChangeSet(cs);

            // author -> Committer
            if (!reader.ReadToDescendant("author"))
            {
                throw new InvalidDataException("author");
            }

            cs.Committer = reader.ReadString();

            // date -> date
            if (!reader.ReadToNextSibling("date"))
            {
                throw new InvalidDataException("date");
            }

            cs.Date = DateTime.Parse(reader.ReadString().Trim());

            if (!reader.ReadToNextSibling("paths"))
            {
                throw new InvalidDataException("paths");
            }

            if (reader.ReadToDescendant("path"))
            {
                do
                {
                    var item = new ChangeItem();

                    var kind = reader.GetAttribute("kind");
                    if (kind != "file")
                    {
                        continue;
                    }

                    var action = reader.GetAttribute("action");
                    item.Kind = SvnActionToKindOfChange(action);
                    if (item.IsRename() || item.IsAdd())
                    {
                        // Both actions can mean a renaming or movement.
                        var copyFromPath = GetStringAttribute(reader, "copyfrom-path");
                        if (copyFromPath != null)
                        {
                            var id          = GetULongAttribute(reader, "copyfrom-rev");
                            var copyFromRev = new NumberId(id);
                            item.FromServerPath = copyFromPath;
                        }
                    }
                    else
                    {
                        Debug.Assert(string.IsNullOrEmpty(GetStringAttribute(reader, "copyfrom-path")));
                        Debug.Assert(string.IsNullOrEmpty(GetStringAttribute(reader, "copyfrom-rev")));
                    }

                    // All attributes must have been read here.

                    var path = reader.ReadString().Trim();
                    item.ServerPath = path;
                    item.LocalPath  = MapToLocalFile_ServerIsAbsolute(path);

                    if (item.Kind == KindOfChange.Rename && item.FromServerPath == null)
                    {
                        // Wtf. This can happen. Just ignore it.
                    }
                    else
                    {
                        _tracking.TrackId(item);
                    }
                } while (reader.ReadToNextSibling("path"));

                if (!reader.ReadToFollowing("msg"))
                {
                    throw new InvalidDataException("msg");
                }

                cs.Comment = reader.ReadString().Trim();
                ParseWorkItemsFromComment(cs.WorkItems, cs.Comment);
            }

            // Applies all change set items and sets their id
            _tracking.ApplyChangeSet(cs.Items);

            result.Add(cs);
        }