Пример #1
0
 public void SetupModification(Modification[] modifications)
 {
     foreach( Modification mod in modifications )
     {
         mod.Url = String.Format( _url, mod.FolderName + "/" + mod.FileName, mod.ChangeNumber );
     }
 }
Пример #2
0
 private Modification CreateModification(FileInfo info)
 {
     Modification modification = new Modification();
     modification.FileName = info.Name;
     modification.ModifiedTime = info.LastWriteTime;
     modification.FolderName = info.DirectoryName;
     return modification;
 }
Пример #3
0
        /// <summary>
        /// Build the Modification list of what files will be built 
        /// with this Release
        /// </summary>
        /// <param name="mods"></param>
        /// <returns></returns>
        public static Modification[] AnalyzeModifications(IList mods)
        {
            // Hashtables are used so we can compare on the keys in search of duplicates
            Hashtable allFiles = new Hashtable();
            foreach (Modification mod in mods)
            {
                string key = mod.FolderName + mod.FileName;
                if (!allFiles.ContainsKey(key))
                    allFiles.Add(key, mod);
                else
                {
                    // If the revision number on the original is larger, then
                    // do the comparision against the original modification
                    // in search to see which revision is higher
                    // example: 1.64.1 < 1.65 but you need to compare against the
                    // larger string of 1.64.1 because we are splitting the numbers individually
                    // so 1 is compared to 1 and 64 is compared to 65.
                    Modification compareMod = allFiles[key] as Modification;
                    string[] originalVersion = compareMod.Version.Split(char.Parse("."));
                    string[] currentVersion = mod.Version.Split(char.Parse("."));
                    int len1 = originalVersion.Length;
                    int len2 = currentVersion.Length;
                    int usingLen = -1;
                    int otherLen = -1;
                    if (len1 >= len2)
                    {
                        usingLen = len1;
                        otherLen = len2;
                    }
                    else
                    {
                        usingLen = len2;
                        otherLen = len1;
                    }

                    for (int i = 0; i < usingLen; i++)
                    {
                        if (i > otherLen)
                            continue;
                        if (Convert.ToInt32(currentVersion[i]) > Convert.ToInt32(originalVersion[i]))
                        {
                            allFiles[compareMod.FolderName + compareMod.FileName] = mod;
                            break;
                        }
                    }
                }
            }
            // Convert the Hashtables to Modification arrays
            Modification[] validMods = new Modification[allFiles.Count];
            int count = 0;
            foreach (string key in allFiles.Keys)
            {
                validMods[count++] = allFiles[key] as Modification;
            }
            return validMods;
        }
Пример #4
0
 public void AssignModificationTime( Modification modification, string time )
 {
     try
     {
         modification.ModifiedTime = DateTime.Parse( time );
     }
     catch ( FormatException )
     {
         modification.ModifiedTime = DateTime.MinValue;
     }
 }
 public void WriteModifications(Modification[] mods)
 {
     writer.WriteStartElement(Elements.MODIFICATIONS);
     if (mods == null)
     {
         return;
     }
     foreach (Modification mod in mods)
     {
         mod.ToXml(writer);
     }
     writer.WriteEndElement();
 }
Пример #6
0
 public void AssignFileInfo( Modification modification, string file )
 {
     int separatorLocation = file.LastIndexOf( Path.DirectorySeparatorChar.ToString() );
     if ( separatorLocation > - 1 )
     {
         modification.FolderName = file.Substring( 0, separatorLocation );
         modification.FileName = file.Substring( separatorLocation + 1 );
     }
     else
     {
         modification.FolderName = string.Empty;
         modification.FileName = file;
     }
 }
Пример #7
0
        /// <summary>
        /// Parses output from p4.exe obtained using arguments <code>p4 -s describe -s 123</code>
        /// where 123 (etc...) are changelist numbers.  This output looks like this:
        /// <p>
        /// <code>
        /// text: Change 123 by user@hostname on 2002/08/21 14:39:52
        /// text:
        /// text:   The checkin comment
        /// text:
        /// text: Affected files ...
        /// text:
        /// info1: //view/path/filename.java#1 add
        /// text:
        /// exit: 0
        /// </code>
        /// </p>
        /// the type appears at the end of the info1 line, and may be add, edit, delete etc...
        /// Two regex strings are used to match the first line, and the 'info1:' line.
        /// NOTE there's a tab character before comment text.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public Modification[] Parse(TextReader reader, DateTime from, DateTime to)
        {
            ArrayList mods = new ArrayList();
            string line;
            string change = null, email = null, user = null, comment = string.Empty;
            DateTime date = DateTime.Now;
            while((line = reader.ReadLine()) != null)
            {
                Match modificationMatch = modRegex.Match(line);
                if (modificationMatch.Success)
                {
                    // when this line is matched, we're finished with this mod, so add it
                    Modification mod = new Modification();
                    mod.ChangeNumber = Int32.Parse(change);
                    mod.Version = modificationMatch.Groups["revision"].Value;
                    mod.FolderName = modificationMatch.Groups["folder"].Value;
                    mod.FileName = modificationMatch.Groups["file"].Value;
                    mod.Type = modificationMatch.Groups["type"].Value;
                    mod.EmailAddress = email;
                    mod.UserName = user;
                    mod.ModifiedTime = date;
                    mod.Comment = comment.Trim();
                    mods.Add(mod);
                }
                else
                {
                    Match changeMatch = changeRegex.Match(line);
                    if (changeMatch.Success)
                    {
                        // set these values while they're available
                        change = changeMatch.Groups["change"].Value;
                        email = changeMatch.Groups["email"].Value;
                        user = changeMatch.Groups["user"].Value;
                        date = DateTime.Parse(changeMatch.Groups["date"].Value);
                        // TODO this is necessary, could someone explain why?
                        comment = "";
                    }
                    else
                    {
                        string checkinCommentPrefix = "text: \t";
                        if (line.StartsWith(checkinCommentPrefix))
                        {
                            comment += line.Substring(checkinCommentPrefix.Length) + "\r\n";
                        }
                    }
                }
            }

            return (Modification[]) mods.ToArray(typeof(Modification));
        }
Пример #8
0
 private Modification ParseModification(string[] modificationParams)
 {
     Modification modification = new Modification();
     int lastIndexOfBackslash = modificationParams[1].LastIndexOf("\\");
     modification.FileName = modificationParams[1].Substring(modificationParams[1].LastIndexOf("\\") + 1);
     if (lastIndexOfBackslash > 0)
     {
         modification.FolderName = modificationParams[1].Substring(0, (modificationParams[1].LastIndexOf("\\")));
     }
     modification.ChangeNumber = int.Parse(modificationParams[2]);
     modification.ModifiedTime = DateTime.Parse(modificationParams[3]);
     modification.UserName = modificationParams[4];
     modification.Comment = modificationParams[5];
     return modification;
 }
Пример #9
0
 private Modification ParseModificationLine(string line)
 {
     Match match = Regex.Match(line, @"^<([^>]*)><([^>]*)><([^>]*)><([^>]*)><([^>]*)><([^>]*)><([^>]*)><([^>]*)>$");
     if (!match.Success)
     {
         throw new ArgumentException("Unable to parse line: " + line);
     }
     Modification modification = new Modification();
     modification.FolderName = match.Groups[1].ToString();
     modification.FileName = match.Groups[2].ToString();
     modification.ChangeNumber = Int32.Parse(match.Groups[3].ToString());
     modification.Type = match.Groups[4].ToString();
     modification.ModifiedTime = DateTime.ParseExact(match.Groups[5].ToString(), TO_SSCM_DATE_FORMAT, CultureInfo.InvariantCulture);
     modification.Comment = match.Groups[6].ToString();
     modification.UserName = match.Groups[7].ToString();
     modification.EmailAddress = match.Groups[8].ToString();
     return modification;
 }
Пример #10
0
 public Modification CreateNewModification(
     string userName,
     string time,
     string elementName,
     string modificationType,
     string comment,
     string change)
 {
     Modification modification = new Modification();
     // ClearCase change number is a string, not an int
     modification.ChangeNumber = ParseChangeNumber( change );
     modification.UserName = userName;
     modification.Type = modificationType;
     modification.Comment = ( comment == string.Empty ? null : comment );
     AssignFileInfo( modification, elementName );
     AssignModificationTime( modification, time );
     return modification;
 }
Пример #11
0
 public ProjectStatus(ProjectIntegratorState status, IntegrationStatus buildStatus, 
     ProjectActivity activity, string name, string webURL, DateTime lastBuildDate, TimeSpan lastBuildDuration,
     string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime,
     string forcee, Modification[] modifications, DateTime currentBuildStartTime, BuildCondition buildCondition)
 {
     this.status = status;
     this.buildStatus = buildStatus;
     this.activity = activity;
     this.name = name;
     this.webURL = webURL;
     this.lastBuildDate = lastBuildDate;
     this.lastBuildLabel = lastBuildLabel;
     this.lastSuccessfulBuildLabel = lastSuccessfulBuildLabel;
     this.nextBuildTime = nextBuildTime;
     this._Forcee = forcee;
     this._Modifications = modifications;
     this.currentBuildStartTime = currentBuildStartTime;
     this.buildCondition = buildCondition;
     this.lastBuildDuration = lastBuildDuration;
 }
Пример #12
0
 public bool Accept(Modification m)
 {
     return Array.IndexOf(UserNames, m.UserName) >= 0;
 }
Пример #13
0
 private string GetVersion(Modification mod, string label)
 {
     return ((label == null || label.Length == 0) ? (mod.Version == null ? "1.0" : mod.Version) : (LabelOrPromotionInput(label)));
 }
Пример #14
0
 private string GetUncPathPrefix(Modification mod)
 {
     //Add extract \ for UNC paths
     return mod.FolderName.StartsWith("\\") ? @"\" : "";
 }
Пример #15
0
 public string CreateIndividualLabelString(Modification mod, string label)
 {
     return string.Format(INDIVIDUAL_LABEL_REVISION_TEMPLATE, GetVersion(mod, label), GetUncPathPrefix(mod), mod.FolderName, mod.FileName);
 }
Пример #16
0
 public string CreateIndividualGetString(Modification mod, string fileLocation)
 {
     return string.Format(INDIVIDUAL_GET_REVISION_TEMPLATE, GetVersion(mod, ""), GetUncPathPrefix(mod), mod.FolderName, mod.FileName, fileLocation);
 }
Пример #17
0
        /// <summary>
        ///     Creates a comma separated list of task IDs.
        /// </summary>
        /// <exception cref="CruiseControlException">
        ///     If <paramref name="modifications" /> is null or empty;
        /// </exception>
        /// <param name="modifications">
        ///     The non-null, non-empty changeset which to use for the list generation.
        /// </param>
        /// <returns>
        ///     A comma separated list of task IDs, with no whitespace.
        /// </returns>
        public static string GetTaskList(Modification[] modifications)
        {
            if (null == modifications || 0 == modifications.Length)
                throw(new CruiseControlException("Invalid Argument: The Synergy task list cannot be empty"));

            int length = modifications.Length;
            // initalize a string build with an approximately sized buffer
            int[] taskList = new int[length];
            StringBuilder retVal = new StringBuilder(10*length);

            // build an array of all unique task numbers
            int j = 0;
            foreach (Modification task in modifications)
            {
                // reset the flag
                bool exists = false;

                for (int i = 0; i < length; i++)
                {
                    if (taskList[i] == task.ChangeNumber)
                    {
                        // exit the for loop when the task number already exists in the array
                        exists = true;
                        break;
                    }
                }

                if (! exists)
                {
                    // also build the comma separated list of tasks
                    if (j > 0)
                    {
                        retVal.Append(',');
                    }
                    retVal.Append(task.ChangeNumber);

                    // if the task was not found, add it to the array
                    taskList[j++] = task.ChangeNumber;
                }
            }
            return (retVal.ToString());
        }
Пример #18
0
 public void ParseComment(Modification mod)
 {
     string comment = locale.CommentKeyword + ":";
     int index = entry.IndexOf(comment);
     if (index > -1)
     {
         mod.Comment = entry.Substring(index + comment.Length).Trim();
     }
 }
Пример #19
0
 private bool MatchesFolder(Modification modification)
 {
     if (modification.FolderName == null) return false;
     return exFolder.IsMatch(modification.FolderName);
 }
Пример #20
0
 private bool MatchesFilename(Modification modification)
 {
     if (modification.FileName == null) return false;
     return exFileName.IsMatch(modification.FileName);
 }
Пример #21
0
        public static ChangeSet[] Convert(Modification[] modifications)
        {
            ChangeSetList ChangeTable = new ChangeSetList();

            foreach (Modification modification in modifications)
            {
                ChangeTable.Add(modification.UserName, modification.ChangeNumber.ToString(), modification.Comment, modification.ModifiedTime.ToString(), new Change(modification.Type, modification.FileName, modification.FolderName));
            }

            return ChangeTable.ToArray();
        }
        /// <summary>
        /// Gets the modifications.	
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to)
		{
            List<NameValuePair> originalSourceControlData = new List<NameValuePair>();
            List<NameValuePair> finalSourceControlData = new List<NameValuePair>();

            var sourceControlDataType = from.SourceControlData.GetType();

            // check that the source control data given to us is in the list of list format
            // if not, then convert it now
            var fromSourceControlDataCount = from.SourceControlData.Count;
            if (fromSourceControlDataCount > 0 &&
                (fromSourceControlDataCount != SourceControls.Length ||
                 !XmlConversionUtil.CanConvertXmlToObject(sourceControlDataType, from.SourceControlData[0].Value)
                )
               )
            {
                var conversionList = new List<NameValuePair>();

                for (int i = 0; i < SourceControls.Length; i++)
                    originalSourceControlData.Add(new NameValuePair(string.Format("sc{0:d}", i), ""));

                int scdIndex = fromSourceControlDataCount - 1;
                for (int i = originalSourceControlData.Count - 1; i >= 0; i--)
                {
                    conversionList.Clear();

                    if (scdIndex >= 0)
                        if (!XmlConversionUtil.CanConvertXmlToObject(sourceControlDataType, from.SourceControlData[scdIndex].Value))
                            conversionList.Add(from.SourceControlData[scdIndex]);

                    originalSourceControlData[i].Value = XmlConversionUtil.ConvertObjectToXml(conversionList);

                    scdIndex--;
                }

            }
            else
            {
                originalSourceControlData.AddRange(from.SourceControlData);
            }

            var originalSourceControlDataCount = originalSourceControlData.Count;
            var modificationSet = new Dictionary<Modification, bool>();
            int sourceControlIndex = 0;
            foreach (ISourceControl sourceControl in SourceControls)
            {
                from.SourceControlData.Clear();
                if (sourceControlIndex < originalSourceControlDataCount)
                    from.SourceControlData.AddRange((List<NameValuePair>)(XmlConversionUtil.ConvertXmlToObject(sourceControlDataType, originalSourceControlData[sourceControlIndex].Value)));

                to.SourceControlData.Clear();

                Modification[] mods = sourceControl.GetModifications(from, to);

                finalSourceControlData.Add(new NameValuePair(string.Format("sc{0:d}", sourceControlIndex), XmlConversionUtil.ConvertObjectToXml(to.SourceControlData)));

                if (mods != null && mods.Length > 0)
                {
                    foreach (var mod in mods)
                    {
                        modificationSet[mod] = true;
                    }
                }
                else if (RequireChangesFromAll)
                {
                    modificationSet.Clear();
                    break;
                }

                sourceControlIndex++;
            }

            to.SourceControlData.Clear();
            to.SourceControlData.AddRange(finalSourceControlData);

            // reset the from.SourceControlData to its original contents
            from.SourceControlData.Clear();
            from.SourceControlData.AddRange(originalSourceControlData);

            var modArray = new Modification[modificationSet.Count];
            modificationSet.Keys.CopyTo(modArray, 0);
            return modArray; 
		}
Пример #23
0
 public bool Accept(Modification m)
 {
     return Array.IndexOf(Actions, m.Type) >= 0;
 }
Пример #24
0
 public void SetupModification(Modification[] modifications)
 {
 }
Пример #25
0
        private Modification GetModification(XmlNode node)
        {
            string folderName = null;
            string fileName = null;
            StringBuilder nameBuilder = new StringBuilder(255);
            ushort modTypeID = ushort.Parse(node.Attributes["type"].Value);
            int index;

            nameBuilder.Append(node.Attributes["name"].InnerText);

            switch ( modTypeID )
            {
                case 10: // add or delete, name attribute contains only the folder
                case 80:
                    index = node.Attributes["actionString"].InnerText.LastIndexOf(' ');
                    nameBuilder.Append('/');
                    nameBuilder.Append(node.Attributes["actionString"].InnerText.Substring(index).Trim());
                    break;
            }

            string name = nameBuilder.ToString();
            index = name.LastIndexOf('/');
            if (index == -1)
            {
                folderName = name;
            }
            else
            {
                folderName = name.Substring(0, index);
                fileName = name.Substring(index + 1, name.Length - index - 1);
            }
            DateTime date = DateTime.Parse(node.Attributes["date"].InnerText, culture);
            Modification modification = new Modification();
            modification.FileName = fileName;
            modification.FolderName = folderName;
            modification.ModifiedTime = date;
            modification.UserName = node.Attributes["user"].InnerText;
            modification.Type = GetTypeString(node.Attributes["type"].InnerText);
            modification.Comment = GetComment(node);
            modification.ChangeNumber = int.Parse(node.Attributes["txid"].InnerText);
            return modification;
        }
Пример #26
0
 public bool Accept(Modification modification)
 {
     return MatchesFolder(modification) && MatchesFilename(modification);
 }
Пример #27
0
 public virtual Modification Parse()
 {
     Modification mod = new Modification();
     mod.Type = Keyword;
     ParseUsernameAndDate(mod);
     ParseComment(mod);
     mod.FileName = ParseFileName();
     mod.FolderName = ParseFolderName();
     return mod;
 }
Пример #28
0
        /// <remarks>
        /// Modification is not accepted if there isn't any exclusion
        /// filter. Modification is accepted if it is accepted by at 
        /// least one of the defined exclusion filters.
        /// </remarks>
        private bool IsAcceptedByExclusionFilters(Modification m)
        {
            if (_exclusionFilters == null || _exclusionFilters.Count == 0)
                return false;

            foreach (IModificationFilter mf in _exclusionFilters)
            {
                if (mf.Accept(m))
                    return true;
            }

            return false;
        }
Пример #29
0
        public void ParseUsernameAndDate(Modification mod)
        {
            Match match = REGEX_USER_DATE_LINE.Match(entry);
            if (! match.Success)
            {
                throw new CruiseControlException("Invalid data retrieved from VSS.  Unable to parse username and date from text. " + entry);
            }

            mod.UserName = match.Groups[1].Value.Trim();
            string date = match.Groups[2].Value.Trim();
            string time = match.Groups[3].Value.Trim();

            mod.ModifiedTime = locale.ParseDateTime(date, time);
        }
Пример #30
0
 private Modification ParseModification(Match revision, string path, DateTime createdDate)
 {
     Modification mod = new Modification();
     mod.Comment = revision.Groups["Comment"].Value.Trim();
     mod.FileName = Path.GetFileName(path);
     mod.FolderName = Path.GetDirectoryName(path).Trim();
     mod.ModifiedTime = Pvcs.GetDate(revision.Groups["CheckIn"].Value.Trim());
     mod.UserName = revision.Groups["Author"].Value.Trim();
     mod.Version = revision.Groups["Version"].Value.Trim();
     mod.Type = (mod.ModifiedTime == createdDate) ? "New" : "Checked in";
     return mod;
 }