Ejemplo n.º 1
0
        public SubversionLog(svnInfo repo, string logEntry)
        {
            this.Repository = repo;

            logEntry = logEntry.TrimWhiteSpace();
            if (String.IsNullOrEmpty(logEntry))
            {
                throw new NullReferenceException("unspecified log entry");
            }

            string[] fields = Regex.Split(logEntry, @" \| ");

            // validate number of fields
            if (fields.Length != 4)
            {
                throw new DataMisalignedException("parsed log entry does not have the expected number of fields");
            }

            // validate revision number
            if (!fields[0].StartsWith("r"))
            {
                throw new InvalidDataException("invalid revision");
            }

            try
            {
                this.Revision = int.Parse(StringHelper.TrimStart(fields[0]));
            }
            catch
            {
                throw new InvalidDataException("invalid revision");
            }


            string datestring = Regex.Split(fields[2], @" \(")[0];

            this.Date = DateTime.Parse(datestring);

            this.Authour = fields[1];

            string [] messageLines = Regex.Split(fields[3], @" line.\n");
            if (messageLines.Length > 1)
            {
                this.Message = messageLines[1].TrimWhiteSpace();
            }
            else
            {
                this.Message = "";
            }
        }
Ejemplo n.º 2
0
        public static bool SetProperty(svnInfo repo, string name, int revision, string newValue)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new NullReferenceException("property name not specified");
            }

            if (revision <= 0 || revision > repo.Revision)
            {
                throw new ArgumentOutOfRangeException("invalid revision");
            }

            ShellResults result = Subversion.Run("propset " + name + " -r " + revision.ToString() + " " + newValue + " " + repo.RepositoryRoot);

            return(result.ExitCode == Shell.EXIT_OK);
        }
Ejemplo n.º 3
0
        public static List <SubversionLog> GetLog(svnInfo repo)
        {
            List <SubversionLog> list = new List <SubversionLog>();

            ShellResults result = Shell.Run(singleton.svnPath, "log " + repo.RepositoryRoot);

            foreach (string logEntry in Regex.Split(result.Output, new String('-', 72)))
            {
                string entry = logEntry.TrimWhiteSpace();
                if (!String.IsNullOrEmpty(entry))
                {
                    list.Add(new SubversionLog(repo, entry));
                }
            }

            list.Sort();
            return(list);
        }
Ejemplo n.º 4
0
        public static svnInfo FindSandbox(string searchPath)
        {
            string sandboxPath = searchPath;
            string rootPath    = Directory.GetParent(sandboxPath).Root.FullName;

            svnInfo info = svnInfo.ReadURL(sandboxPath);

            while (!info.NodeFound && sandboxPath != rootPath)
            {
                sandboxPath = Directory.GetParent(sandboxPath).FullName;
                info        = svnInfo.ReadLocal(sandboxPath);
            }

            if (!info.NodeFound)
            {
                throw new DirectoryNotFoundException("Sandbox not found in " + searchPath);
            }

            return(info);
        }
Ejemplo n.º 5
0
        public static svnInfo ReadURL(string RepositoryURL)
        {
            ShellResults result = Subversion.Run("info " + RepositoryURL);

            svnInfo info = new svnInfo();

            if (result.ExitCode == Shell.EXIT_OK)
            {
                info.NodeFound           = true;
                info.WorkingCopyPath     = null;
                info.WorkingCopyRootPath = null;
                info.Repository          = StringHelper.RegexFindString(result.Output, "URL:(.+)\n");
                info.RepositoryRoot      = StringHelper.RegexFindString(result.Output, "Repository Root:(.+)\n");
                info.Revision            = int.Parse(StringHelper.RegexFindString(result.Output, "Revision:(.+)\n"));
            }
            else
            {
                info.NodeFound = false;
            }

            return(info);
        }
Ejemplo n.º 6
0
        public static List <SubversionLog> GetLog()
        {
            svnInfo repo = FindSandbox(Directory.GetCurrentDirectory());

            return(GetLog(repo));
        }