예제 #1
0
        private SvnCommitResult CommitChangesetFiles(SvnClient svnClient, Changeset changeset, List <string> filePaths)
        {
            SvnCommitResult commitResult;
            SvnCommitArgs   commitArgs;
            int             failCount;
            bool            complete;

            commitArgs = new SvnCommitArgs {
                LogMessage = changeset.Comment
            };
            failCount    = 0;
            complete     = false;
            commitResult = null;

            while (!complete)
            {
                if (failCount > 0)
                {
                    this.LogMessage("Retrying commit again, attempt {0} of {1}...", failCount + 1, this.RetryCount);
                }
                try
                {
                    svnClient.Commit(filePaths, commitArgs, out commitResult);
                    complete = true;
                }
                catch (Exception ex)
                {
                    this.LogException(ex);

                    failCount++;
                    if (failCount > this.RetryCount)
                    {
                        complete = true; // abort
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
            }

            return(commitResult);
        }
예제 #2
0
        protected virtual void SetRevisionProperties(SvnClient svnClient, SvnCommitResult commitResult, Changeset changeset)
        {
            Boolean success = false;
            String  str_exception_msg;

            str_exception_msg = "";
            try
            {
                success  = true;
                success &= svnClient.SetRevisionProperty(this.SvnFullRepositoryUri, commitResult.Revision, "svn:author", changeset.Username);
                DateTime utc_time = changeset.DateTime.ToUniversalTime();
                success &= svnClient.SetRevisionProperty(this.SvnFullRepositoryUri, commitResult.Revision, "svn:date", utc_time.ToString("O"));
            }
            catch (SharpSvn.SvnException ex)
            {
                success           = false;
                str_exception_msg = ex.ToString();
            }

            if (!success)
            {
                this.LogMessage("Couldn't set author and date for revision! Did you remember to set pre-revprop-change hook?\n\n" + str_exception_msg, commitResult.Revision);
                throw new InvalidOperationException("Failed to set Revision Property");
            }
        }
예제 #3
0
        private void AddFileVersionToChangeset(IVSSItem vssFile, Int32 f_count, IVSSVersion vssVersion, bool isAdd)
        {
            string    filePath;
            VSSItem   versionItem;
            string    comment;
            Changeset thisChangeset;

            // define the working copy filename
            if (!this.IsPreview)
            {
                filePath = Path.Combine(this.SvnFullRepositoryPath, this.VssRelativeFilePaths[f_count]);
            }
            else
            {
                filePath = string.Empty;
            }

            //get version item to get the version of the file
            versionItem = vssFile.get_Version(vssVersion.VersionNumber);
            comment     = versionItem.VSSVersion.Comment;

            if (Changesets.ContainsKey(vssVersion.Date))
            {
                // using an existing change set
                thisChangeset = Changesets[vssVersion.Date];

                // different comment, so create a new change set anyway
                if (thisChangeset.Comment != comment)
                {
                    bool done = false;

                    //there are two different changes at the same time
                    //I'm not sure how this happened, but it did.
                    //make the date/time of this changeset after any existing changeset
                    thisChangeset = new Changeset()
                    {
                        Comment  = comment,
                        DateTime = vssVersion.Date,
                        Username = vssVersion.Username
                    };

                    //make sure not to try and add this entry if an entry with the time already exists
                    while (!done)
                    {
                        if (Changesets.ContainsKey(thisChangeset.DateTime))
                        {
                            thisChangeset.DateTime = thisChangeset.DateTime.AddSeconds(1);
                        }
                        else
                        {
                            done = true;
                        }
                    }

                    this.Changesets.Add(thisChangeset.DateTime, thisChangeset);
                }
            }
            else
            {
                // create a new change set
                thisChangeset = new Changeset()
                {
                    Comment  = comment,
                    DateTime = vssVersion.Date,
                    Username = vssVersion.Username
                };
                this.Changesets.Add(thisChangeset.DateTime, thisChangeset);
            }

            // add the file to the change set
            thisChangeset.Files.Add(new ChangesetFileInfo()
            {
                FilePath   = filePath,
                IsAdd      = isAdd,
                VssFile    = vssFile,
                VssVersion = vssVersion
            });
        }