append() static private method

static private append ( GitSharp.Core.RefRename refRename, string logName, string msg ) : void
refRename GitSharp.Core.RefRename
logName string
msg string
return void
コード例 #1
0
        private RefUpdateResult UpdateRepositoryStore(LockFile @lock, RefUpdateResult status)
        {
            if (status == RefUpdateResult.NoChange)
            {
                return(status);
            }

            @lock.NeedStatInformation = true;
            @lock.Write(_newValue);

            string msg = GetRefLogMessage();

            if (msg != null)
            {
                if (_refLogIncludeResult)
                {
                    string strResult = ToResultString(status);
                    if (strResult != null)
                    {
                        msg = !string.IsNullOrEmpty(msg) ? msg + ": " + strResult : strResult;
                    }
                }

                RefLogWriter.append(this, msg);
            }

            if ([email protected]())
            {
                return(RefUpdateResult.LockFailure);
            }

            _db.Stored(_ref.OriginalName, _ref.Name, _newValue, @lock.CommitLastModified);
            return(status);
        }
コード例 #2
0
ファイル: RefRename.cs プロジェクト: kkl713/GitSharp
        /// <summary>
        /// The result of the new ref update
        /// </summary>
        /// <returns></returns>
        /// <exception cref="IOException"></exception>
        public RefResult Rename()
        {
            Ref        oldRef        = _oldFromDelete.Repository.getRef(Constants.HEAD);
            bool       renameHeadToo = oldRef != null && oldRef.Name == _oldFromDelete.Name;
            Repository db            = _oldFromDelete.Repository;

            RefLogWriter.renameTo(db, _oldFromDelete, _newToUpdate);
            _newToUpdate.SetRefLogMessage(null, false);
            string tmpRefName = "RENAMED-REF.." + Thread.CurrentThread.ManagedThreadId;

            RefUpdate tmpUpdateRef = db.UpdateRef(tmpRefName);

            if (renameHeadToo)
            {
                try
                {
                    _oldFromDelete.Repository.Link(Constants.HEAD, tmpRefName);
                }
                catch (IOException)
                {
                    RefLogWriter.renameTo(db, _newToUpdate, _oldFromDelete);
                    return(_renameResult = RefResult.LockFailure);
                }
            }

            tmpUpdateRef.NewObjectId   = _oldFromDelete.OldObjectId;
            tmpUpdateRef.IsForceUpdate = true;
            RefResult update = tmpUpdateRef.Update();

            if (update != RefResult.Forced && update != RefResult.New && update != RefResult.NoChange)
            {
                RefLogWriter.renameTo(db, _newToUpdate, _oldFromDelete);
                if (renameHeadToo)
                {
                    _oldFromDelete.Repository.Link(Constants.HEAD, _oldFromDelete.Name);
                }

                return(_renameResult = update);
            }

            _oldFromDelete.ExpectedOldObjectId = _oldFromDelete.OldObjectId;
            _oldFromDelete.IsForceUpdate       = true;
            RefResult delete = _oldFromDelete.Delete();

            if (delete != RefResult.Forced)
            {
                if (db.getRef(_oldFromDelete.Name) != null)
                {
                    RefLogWriter.renameTo(db, _newToUpdate, _oldFromDelete);
                    if (renameHeadToo)
                    {
                        _oldFromDelete.Repository.Link(Constants.HEAD, _oldFromDelete.Name);
                    }
                }
                return(_renameResult = delete);
            }

            _newToUpdate.NewObjectId = tmpUpdateRef.NewObjectId;
            RefResult updateResult = _newToUpdate.Update();

            if (updateResult != RefResult.New)
            {
                RefLogWriter.renameTo(db, _newToUpdate, _oldFromDelete);
                if (renameHeadToo)
                {
                    _oldFromDelete.Repository.Link(Constants.HEAD, _oldFromDelete.Name);
                }
                _oldFromDelete.ExpectedOldObjectId = null;
                _oldFromDelete.NewObjectId         = _oldFromDelete.OldObjectId;
                _oldFromDelete.IsForceUpdate       = true;
                _oldFromDelete.SetRefLogMessage(null, false);
                RefResult undelete = _oldFromDelete.Update();
                if (undelete != RefResult.New && undelete != RefResult.LockFailure)
                {
                    return(_renameResult = RefResult.IOFailure);
                }
                return(_renameResult = RefResult.LockFailure);
            }

            if (renameHeadToo)
            {
                _oldFromDelete.Repository.Link(Constants.HEAD, _newToUpdate.Name);
            }
            else
            {
                db.fireRefsMaybeChanged();
            }

            RefLogWriter.append(this, _newToUpdate.Name, "Branch: renamed "
                                + Repository.ShortenRefName(_oldFromDelete.Name) + " to "
                                + Repository.ShortenRefName(_newToUpdate.Name));

            if (renameHeadToo)
            {
                RefLogWriter.append(this, Constants.HEAD, "Branch: renamed "
                                    + Repository.ShortenRefName(_oldFromDelete.Name) + " to "
                                    + Repository.ShortenRefName(_newToUpdate.Name));
            }

            return(_renameResult = RefResult.Renamed);
        }