Exemplo n.º 1
0
        private void ParseHeader(string line, PerforceChangeset changeset)
        {
            var sliced = line.Split(' ');

            if (sliced.Length < 7)
            {
                throw new InvalidFormatException("Invalid header, line starting with Change ");
            }

            changeset.ChangesetNumber = Convert.ToInt32(sliced[1]);
            changeset.Author          = sliced[3];
            var slicedAuthor = changeset.Author.Split('@');

            if (slicedAuthor.Length < 2)
            {
                throw new InvalidFormatException("Invalid author. Expected author@workspace");
            }
            changeset.AuthorName      = slicedAuthor[0];
            changeset.AuthorWorkspace = slicedAuthor[1];

            try
            {
                changeset.ChangesetTimestamp = ParseTimestamp(sliced[5], sliced[6]);
            }
            catch
            {
                throw new InvalidFormatException("Invalid date and time. Expecting YYYY/MM/DD HH:MM:SS");
            }
        }
Exemplo n.º 2
0
 private void ParseLine(ref FileChanges currentFileChanges, string line, PerforceChangeset changeset)
 {
     if (line.StartsWith("Change "))
     {
         ParseHeader(line, changeset);
     }
     else if (line.StartsWith("\t"))
     {
         changeset.AppendMessage(line.Substring(1));
     }
     else if (line.StartsWith("===="))
     {
         ParseNewFileChanges(ref currentFileChanges, line, changeset);
     }
     else if (line.StartsWith("add "))
     {
         ParseAddedLines(ref currentFileChanges, line, changeset);
     }
     else if (line.StartsWith("deleted "))
     {
         ParseDeletedLines(ref currentFileChanges, line, changeset);
     }
     else if (line.StartsWith("changed "))
     {
         ParseChangedLines(ref currentFileChanges, line, changeset);
     }
 }
Exemplo n.º 3
0
        public PerforceChangeset Parse(List <string> lines)
        {
            var         result             = new PerforceChangeset();
            FileChanges currentFileChanges = null;

            foreach (var line in lines)
            {
                ParseLine(ref currentFileChanges, line, result);
            }

            return(result);
        }
Exemplo n.º 4
0
        private void ParseNewFileChanges(ref FileChanges currentFileChanges, string line, PerforceChangeset changeset)
        {
            currentFileChanges = new FileChanges();
            changeset.ChangesetFileChanges.Add(currentFileChanges);

            currentFileChanges.FileName = line.Split('#')[0].Split(' ')[1];
        }
Exemplo n.º 5
0
        private void ParseAddedLines(ref FileChanges currentFileChanges, string line, PerforceChangeset changeset)
        {
            var splitted = line.Split(' ');

            currentFileChanges.Added = Convert.ToInt32(splitted[3]);
        }