Пример #1
0
        private IEnumerable<IssueMarker> PerformSplit(SettingsCache cache, string logmessage)
        {
            foreach (Match m in cache.LogPrepareRe.Matches(logmessage))
            {
                if (!m.Success)
                    continue;

                foreach (Capture c in m.Captures)
                {
                    string text = logmessage.Substring(c.Index, c.Length);

                    foreach (Match sm in cache.LogSplitRe.Matches(c.Value))
                    {
                        if (!sm.Success)
                            continue;

                        foreach (Capture sc in sm.Captures)
                        {
                            yield return new IssueMarker(c.Index + sc.Index, sc.Length, sc.Value);
                        }
                    }
                }
            }
        }
Пример #2
0
        void SetProjectRootValue(string value)
        {
            if (SolutionFilename == null)
                return;

            string sd = GitTools.GetRepositoryPath(GitTools.GetNormalizedDirectoryName(SolutionFilename).TrimEnd('\\') + '\\');
            string v = GitTools.GetRepositoryPath(GitTools.GetNormalizedFullPath(value)).ToString();

            if (!v.EndsWith("/"))
                v += "/";

            if (!sd.StartsWith(v, FileSystemUtil.StringComparison))
                return;

            GetService<IFileStatusCache>().MarkDirty(SolutionFilename);
            _cache = null;
        }
Пример #3
0
        private IEnumerable<IssueMarker> PerformAllInOne(SettingsCache sc, string logmessage)
        {
            foreach (Match m in sc.AllInOneRe.Matches(logmessage))
            {
                if (!m.Success)
                    continue;

                bool first = true;
                foreach (Group g in m.Groups)
                {
                    if (first)
                        first = false;
                    else
                        foreach (Capture c in g.Captures)
                            yield return new IssueMarker(c.Index, c.Length, c.Value);
                }
            }
        }
Пример #4
0
        private void RefreshIfDirty()
        {
            if (!IsDirty() && _cache != null)
                return;

            _cache = null;
            SettingsCache cache = new SettingsCache();
            try
            {
                string solutionFile = SelectionContext.SolutionFilename;

                if (string.IsNullOrEmpty(solutionFile))
                    return;

                GitItem item = StatusCache[solutionFile];

                if (item == null)
                    return;

                cache.SolutionFilename = item.FullPath;
                cache.SolutionCookie = item.ChangeCookie;

                if (!item.Exists)
                    return;

                GitWorkingCopy wc = item.WorkingCopy;
                GitItem parent;
                if (wc != null)
                    parent = StatusCache[wc.FullPath];
                else
                    parent = item.Parent;

                if (parent != null)
                {
                    cache.ProjectRoot = parent.FullPath;
                    cache.ProjectRootItem = parent;
                }

                if (cache.ProjectRoot != null)
                {
                    parent = StatusCache[cache.ProjectRoot];

                    if (parent == null)
                        return;

                    cache.ProjectRootItem = parent;
                    cache.RootCookie = parent.ChangeCookie;
                }
            }
            finally
            {
                _cache = cache;
            }
        }
Пример #5
0
        private void SetProjectRootViaProperty(SettingsCache cache, string value)
        {
            string dir = value;
            string solutionFile = cache.SolutionFilename;

            SvnItem directory = StatusCache[solutionFile].Parent;
            if (directory == null)
                return;

            SvnWorkingCopy wc = directory.WorkingCopy;

            int up = 0;

            while (dir.StartsWith("../"))
            {
                up++;
                dir = dir.Substring(3);
                if (directory != null)
                    directory = directory.Parent;
            }

            if (directory == null)
                return; // Invalid value

            if (directory.WorkingCopy != wc)
                return; // Outside workingcopy

            if (dir.Length == 0)
            {
                cache.ProjectRoot = directory.FullPath;
                cache.ProjectRootUri = directory.Uri;
            }
        }
Пример #6
0
        void SetProjectRootValue(string value)
        {
            if (SolutionFilename == null)
                return;

            string sd = SvnTools.PathToRelativeUri(SvnTools.GetNormalizedDirectoryName(SolutionFilename).TrimEnd('\\') + '\\').ToString();
            string v = SvnTools.PathToRelativeUri(SvnTools.GetNormalizedFullPath(value)).ToString();

            if (!v.EndsWith("/"))
                v += "/";

            if (!sd.StartsWith(v, StringComparison.OrdinalIgnoreCase))
                return;

            Uri solUri;
            Uri resUri;

            if (!Uri.TryCreate("file:///" + sd.Replace('\\', '/'), UriKind.Absolute, out solUri)
                || !Uri.TryCreate("file:///" + v.Replace('\\', '/'), UriKind.Absolute, out resUri))
                return;

            using (SvnClient client = GetService<ISvnClientPool>().GetNoUIClient())
            {
                SvnSetPropertyArgs ps = new SvnSetPropertyArgs();
                ps.ThrowOnError = false;

                client.SetProperty(SolutionFilename, AnkhSccPropertyNames.ProjectRoot, solUri.MakeRelativeUri(resUri).ToString(), ps);

                GetService<IFileStatusCache>().MarkDirty(SolutionFilename);
                // The getter will reload the settings for us
            }

            _cache = null;
        }
Пример #7
0
        private void LoadSolutionProperties(SettingsCache cache, SvnItem item)
        {
            // Subversion -1.5 loads all properties in memory at once; loading them
            // all is always faster than loading a few
            // We must change this algorithm if Subversions implementation changes
            SvnPropertyCollection pc = GetAllProperties(item.FullPath);

            if (pc != null)
                foreach (SvnPropertyValue pv in pc)
                {
                    switch (pv.Key)
                    {
                        case AnkhSccPropertyNames.ProjectRoot:
                            SetProjectRootViaProperty(cache, pv.StringValue);
                            break;
                        default:
                            LoadPropertyBoth(cache, pv);
                            break;
                    }
                }
        }
Пример #8
0
 private void LoadPropertyBoth(SettingsCache cache, SvnPropertyValue pv)
 {
     bool boolValue;
     int intValue;
     switch (pv.Key)
     {
         case SvnPropertyNames.BugTrackAppend:
             if (!cache.BugTrackAppend.HasValue && TryParseBool(pv, out boolValue))
                 cache.BugTrackAppend = boolValue;
             break;
         case SvnPropertyNames.BugTrackLabel:
             if (cache.BugTrackLabel == null)
                 cache.BugTrackLabel = pv.StringValue;
             break;
         case SvnPropertyNames.BugTrackLogRegex:
             if (cache.BugTrackLogRegexes == null)
                 cache.BugTrackLogRegexes = pv.StringValue;
             break;
         case SvnPropertyNames.BugTrackMessage:
             if (cache.BugTrackMessage == null)
                 cache.BugTrackMessage = pv.StringValue.Replace("\r", "");
             break;
         case SvnPropertyNames.BugTrackNumber:
             if (!cache.BugTrackNumber.HasValue && TryParseBool(pv, out boolValue))
                 cache.BugTrackNumber = boolValue;
             break;
         case SvnPropertyNames.BugTrackUrl:
             if (cache.BugTrackUrl == null)
                 cache.BugTrackUrl = pv.StringValue;
             break;
         case SvnPropertyNames.BugTrackWarnIfNoIssue:
             if (!cache.BugTrackWarnIfNoIssue.HasValue && TryParseBool(pv, out boolValue))
                 cache.BugTrackWarnIfNoIssue = boolValue;
             break;
         case SvnPropertyNames.TortoiseSvnLogMinSize:
             if (!cache.LogMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue)
                 && int.TryParse(pv.StringValue, out intValue))
             {
                 cache.LogMessageMinSize = intValue;
             }
             break;
         case SvnPropertyNames.TortoiseSvnLockMsgMinSize:
             if (!cache.LockMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue)
                 && int.TryParse(pv.StringValue, out intValue))
             {
                 cache.LockMessageMinSize = intValue;
             }
             break;
         case SvnPropertyNames.TortoiseSvnLogWidthLine:
             if (!cache.LogWidth.HasValue && !string.IsNullOrEmpty(pv.StringValue)
                 && int.TryParse(pv.StringValue, out intValue))
             {
                 cache.LogWidth = intValue;
             }
             break;
         case SvnPropertyNames.TortoiseSvnLogSummary:
             if (cache.LogSummary == null)
                 cache.LogSummary = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryConnector:
             cache.IssueRepositoryConnectorName = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryUri:
             cache.IssueRepositoryUri = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryId:
             cache.IssueRepositoryId = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryPropertyNames:
             cache.IssueRepositoryPropertyNames = pv.StringValue;
             break;
         case AnkhSccPropertyNames.IssueRepositoryPropertyValues:
             cache.IssueRepositoryPropertyValues = pv.StringValue;
             break;
     }
 }