Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="szResult"></param>
        /// <returns></returns>
        private static List<StatusItem> ParseOperaResult(string szResult)
        {
            var listContractedItem = new List<StatusItem>();
            if (string.IsNullOrEmpty(szResult))
                return listContractedItem;

            //remove warning
            var nl = new char[] { '\n', '\r' };
            string szAllInfoStatus = szResult.Trim(nl);
            int ilastWaringPos = szAllInfoStatus.LastIndexOfAny(nl);
            if (ilastWaringPos > 0)
            {
                int ind = szAllInfoStatus.LastIndexOf('\0');
                if (ind < ilastWaringPos)
                {
                    //Remove Warning at end if it exist;
                    ilastWaringPos = szAllInfoStatus.IndexOfAny(nl, ind >= 0 ? ind : 0);
                    szAllInfoStatus = szAllInfoStatus.Substring(0, ilastWaringPos).Trim(nl);
                }
                else
                {
                    //Remove Warning at beginning if it exist;
                    szAllInfoStatus = szAllInfoStatus.Substring(ilastWaringPos).Trim(nl);
                }
            }

            //analyze every item;
            var AllInfoItems = szAllInfoStatus.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
            for(int n=0; n<AllInfoItems.Length; n++)
            {
                string tempItemInfo=AllInfoItems[n];
                if (string.IsNullOrEmpty(tempItemInfo))
                    continue;

                string szRawStatus = null, szFileName = null;
                int iSplitIndex = tempItemInfo.IndexOfAny(new char[] {'\0', '\t', ' '},2);
                if (iSplitIndex>0)
                {
                    szRawStatus = tempItemInfo.Substring(0, iSplitIndex);
                    szFileName = tempItemInfo.Substring(iSplitIndex+1);

                    if (szRawStatus == null || szFileName == null)
                    {
                        continue;
                    }
                }

                StatusItem tpStatusItem=new StatusItem();//here just implement a value initialization, no heeep memory alloc.
                tpStatusItem.szFileName = szFileName.Trim(new char[] { '\"'});
                tpStatusItem.status = ParseRawStatusInfo(szRawStatus);
                if (tpStatusItem.status == FileSccStatus.ST_NULL)
                    continue;
                if (tpStatusItem.status == FileSccStatus.ST_RENMAE)
                {
                    //just treat "R" as  new stage
                    //add followed file into current item, because they are a group
                    tpStatusItem.status = FileSccStatus.ST_NEW_STAGED;
                    tpStatusItem.szAdditionalFile = AllInfoItems[n+1];
                    ++n;
                }
                listContractedItem.Add(tpStatusItem);

            }
            return listContractedItem;
        }
Exemplo n.º 2
0
        private static List<string> GetLocalChangeFiles(string szResult)
        {
            var listContractedItem = new List<string>();
            if (string.IsNullOrEmpty(szResult))
                return listContractedItem;

            //remove warning
            var nl = new char[] { '\n', '\r' };
            string szAllInfoStatus = szResult.Trim(nl);
            int ilastWaringPos = szAllInfoStatus.LastIndexOfAny(nl);
            if (ilastWaringPos > 0)
            {
                int ind = szAllInfoStatus.LastIndexOf('\0');
                if (ind < ilastWaringPos)
                {
                    //Remove Warning at end if it exist;
                    ilastWaringPos = szAllInfoStatus.IndexOfAny(nl, ind >= 0 ? ind : 0);
                    szAllInfoStatus = szAllInfoStatus.Substring(0, ilastWaringPos).Trim(nl);
                }
                else
                {
                    //Remove Warning at beginning if it exist;
                    szAllInfoStatus = szAllInfoStatus.Substring(ilastWaringPos).Trim(nl);
                }
            }

            //analyze every item;
            var AllInfoItems = szAllInfoStatus.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
            for (int n = 0; n < AllInfoItems.Length; n++)
            {
                string tempItemInfo = AllInfoItems[n];
                if (string.IsNullOrEmpty(tempItemInfo))
                    continue;

                string szRawStatus = null, szFileName = null;
                int iSplitIndex = tempItemInfo.IndexOfAny(new char[] { '\0', '\t', ' ' }, 2);
                if (iSplitIndex > 0)
                {
                    szRawStatus = tempItemInfo.Substring(0, iSplitIndex);
                    szFileName = tempItemInfo.Substring(iSplitIndex + 1);
                }
                if (string.IsNullOrEmpty(szRawStatus) || string.IsNullOrEmpty(szFileName) || szRawStatus.Length>2)
                {
                    continue;
                }

                StatusItem tpStatusItem = new StatusItem();//here just implement a value initialization, no heeep memory alloc.
                tpStatusItem.szFileName = szFileName.Trim(new char[] { '\"' });
                string szHead = string.Empty;
                if (IsWorkingArealChange(szRawStatus,out szHead))
                {
                    listContractedItem.Add(szHead + szFileName);
                }
            }
            return listContractedItem;
        }