コード例 #1
0
        protected override RefUpdateResult doUpdate(RefUpdateResult status)
        {
            _lock.setNeedStatInformation(true);
            _lock.Write(NewObjectId);

            string msg = getRefLogMessage();

            if (msg != null)
            {
                if (isRefLogIncludingResult())
                {
                    string strResult = toResultString(status);
                    if (strResult != null)
                    {
                        if (msg.Length > 0)
                        {
                            msg = msg + ": " + strResult;
                        }
                        else
                        {
                            msg = strResult;
                        }
                    }
                }
                _database.log(this, msg, true);
            }
            if (!_lock.Commit())
            {
                return(RefUpdateResult.LOCK_FAILURE);
            }
            _database.stored(this, _lock.CommitLastModified);
            return(status);
        }
コード例 #2
0
        /// <summary>
        /// Delete the ref.
        /// </summary>
        /// <param name="walk">
        /// a RevWalk instance this delete command can borrow to perform
        /// the merge test. The walk will be reset to perform the test.
        /// </param>
        /// <returns>the result status of the delete.</returns>
        public RefUpdateResult delete(RevWalk.RevWalk walk)
        {
            string myName = Ref.getLeaf().getName();

            if (myName.StartsWith(Constants.R_HEADS))
            {
                Ref head = getRefDatabase().getRef(Constants.HEAD);
                while (head.isSymbolic())
                {
                    head = head.getTarget();
                    if (myName.Equals(head.getName()))
                    {
                        return(result = RefUpdateResult.REJECTED_CURRENT_BRANCH);
                    }
                }
            }

            try
            {
                return(result = updateImpl(walk, new DeleteStore(this)));
            }
            catch (IOException)
            {
                result = RefUpdateResult.IO_FAILURE;
                throw;
            }
        }
コード例 #3
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);
        }
コード例 #4
0
            public override RefUpdateResult Store(LockFile @lock, RefUpdateResult status)
            {
                var storage = RefUpdate._ref.StorageFormat;

                if (storage == Ref.Storage.New)
                {
                    return(status);
                }

                if (storage.IsPacked)
                {
                    RefUpdate._db.RemovePackedRef(RefUpdate._ref.Name);
                }

                int levels = Count(RefUpdate._ref.Name, '/') - 2;

                // Delete logs _before_ unlocking
                DirectoryInfo gitDir = RefUpdate._db.Repository.Directory;
                var           logDir = new DirectoryInfo(gitDir + "/" + Constants.LOGS);

                DeleteFileAndEmptyDir(new FileInfo(logDir + "/" + RefUpdate._ref.Name), levels);

                // We have to unlock before (maybe) deleting the parent directories
                @lock.Unlock();
                if (storage.IsLoose)
                {
                    DeleteFileAndEmptyDir(RefUpdate._looseFile, levels);
                }
                return(status);
            }
コード例 #5
0
 protected override RefUpdateResult doDelete(RefUpdateResult status)
 {
     if (Ref.getLeaf().getStorage() != Storage.New)
     {
         _database.delete(this);
     }
     return(status);
 }
コード例 #6
0
 public override RefUpdateResult execute(RefUpdateResult status)
 {
     if (status == RefUpdateResult.NO_CHANGE)
     {
         return(status);
     }
     return(_refUpdate.doUpdate(status));
 }
コード例 #7
0
 /// <summary>
 /// Gracefully update the ref to the new value.
 /// <para/>
 /// Merge test will be performed according to <see cref="IsForceUpdate"/>.
 /// </summary>
 /// <param name="walk">
 /// a RevWalk instance this update command can borrow to perform
 /// the merge test. The walk will be reset to perform the test.
 /// </param>
 /// <returns>
 /// the result status of the update.
 /// </returns>
 public RefUpdateResult update(RevWalk.RevWalk walk)
 {
     requireCanDoUpdate();
     try
     {
         return(result = updateImpl(walk, new UpdateStore(this)));
     }
     catch (IOException x)
     {
         result = RefUpdateResult.IO_FAILURE;
         throw x;
     }
 }
コード例 #8
0
 /// <summary>
 /// Gracefully update the ref to the new value.
 /// </summary>
 /// <param name="walk">
 /// A <see cref="RevWalk"/> instance this update command can borrow to
 /// perform the merge test. The walk will be reset to perform the test.
 /// </param>
 /// <returns>The result status of the update.</returns>
 public RefUpdateResult Update(RevWalk.RevWalk walk)
 {
     RequireCanDoUpdate();
     try
     {
         return(Result = UpdateImpl(walk, new UpdateStore(this)));
     }
     catch (IOException)
     {
         Result = RefUpdateResult.IOFailure;
         throw;
     }
 }
コード例 #9
0
        /// <summary>
        /// Replace this reference with a symbolic reference to another reference.
        /// <para/>
        /// This exact reference (not its traversed leaf) is replaced with a symbolic
        /// reference to the requested name.
        /// </summary>
        /// <param name="target">
        /// name of the new target for this reference. The new target name
        /// must be absolute, so it must begin with {@code refs/}.
        /// </param>
        /// <returns><see cref="RefUpdateResult.NEW"/> or <see cref="RefUpdateResult.FORCED"/> on success.</returns>
        public RefUpdateResult link(string target)
        {
            if (!target.StartsWith(Constants.R_REFS))
            {
                throw new ArgumentException("Not " + Constants.R_REFS);
            }
            if (getRefDatabase().isNameConflicting(Name))
            {
                return(RefUpdateResult.LOCK_FAILURE);
            }
            try
            {
                if (!tryLock(false))
                {
                    return(RefUpdateResult.LOCK_FAILURE);
                }

                Ref old = getRefDatabase().getRef(Name);
                if (old != null && old.isSymbolic())
                {
                    Ref dst = old.getTarget();
                    if (target.Equals(dst.getName()))
                    {
                        return(result = RefUpdateResult.NO_CHANGE);
                    }
                }

                if (old != null && old.getObjectId() != null)
                {
                    OldObjectId = (old.getObjectId());
                }

                Ref dst2 = getRefDatabase().getRef(target);
                if (dst2 != null && dst2.getObjectId() != null)
                {
                    NewObjectId = (dst2.getObjectId());
                }

                return(result = doLink(target));
            }
            catch (IOException)
            {
                result = RefUpdateResult.IO_FAILURE;
                throw;
            }
            finally
            {
                unlock();
            }
        }
コード例 #10
0
        private static string toResultString(RefUpdateResult status)
        {
            switch (status)
            {
            case RefUpdateResult.FORCED:
                return("forced-update");

            case RefUpdateResult.FAST_FORWARD:
                return("fast forward");

            case RefUpdateResult.NEW:
                return("created");

            default:
                return(null);
            }
        }
コード例 #11
0
        private static string ToResultString(RefUpdateResult status)
        {
            switch (status)
            {
            case RefUpdateResult.Forced:
                return("forced-update");

            case RefUpdateResult.FastForward:
                return("fast forward");

            case RefUpdateResult.New:
                return("created");

            default:
                return(null);
            }
        }
コード例 #12
0
        /// <summary>
        /// Delete the ref.
        /// </summary>
        /// <param name="walk">
        /// A <see cref="RevWalk"/> instance this Delete command can borrow to
        /// perform the merge test. The walk will be reset to perform the test.
        /// </param>
        /// <returns>The result status of the Delete.</returns>
        public RefUpdateResult Delete(RevWalk.RevWalk walk)
        {
            if (Name.StartsWith(Constants.R_HEADS))
            {
                Ref head = _db.ReadRef(Constants.HEAD);
                if (head != null && Name.Equals(head.Name))
                {
                    return(Result = RefUpdateResult.RejectedCurrentBranch);
                }
            }

            try
            {
                return(Result = UpdateImpl(walk, new DeleteStore(this)));
            }
            catch (IOException)
            {
                Result = RefUpdateResult.IOFailure;
                throw;
            }
        }
コード例 #13
0
 protected abstract RefUpdateResult doUpdate(RefUpdateResult desiredResult);
コード例 #14
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
 public override RefUpdateResult Store(LockFile lockFile, RefUpdateResult status)
 {
     return RefUpdate.UpdateRepositoryStore(lockFile, status);
 }
コード例 #15
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
 public abstract RefUpdateResult Store(LockFile lockFile, RefUpdateResult status);
コード例 #16
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
            public override RefUpdateResult Store(LockFile @lockFile, RefUpdateResult status)
            {
                var storage = RefUpdate._ref.StorageFormat;
                if (storage == Ref.Storage.New)
                {
                    return status;
                }

                if (storage.IsPacked)
                {
                    RefUpdate._db.RemovePackedRef(RefUpdate._ref.Name);
                }

                int levels = Count(RefUpdate._ref.Name, '/') - 2;

                // Delete logs _before_ unlocking
                DirectoryInfo gitDir = RefUpdate._db.Repository.Directory;
                var logDir = new DirectoryInfo(gitDir + "/" + Constants.LOGS);
                DeleteFileAndEmptyDir(new FileInfo(logDir + "/" + RefUpdate._ref.Name), levels);

                // We have to unlock before (maybe) deleting the parent directories
                lockFile.Unlock();
                if (storage.IsLoose)
                {
                    DeleteFileAndEmptyDir(RefUpdate._looseFile, levels);
                }
                return status;
            }
コード例 #17
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
        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;
        }
コード例 #18
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
        private static string ToResultString(RefUpdateResult status)
        {
            switch (status)
            {
                case RefUpdateResult.Forced:
                    return "forced-update";

                case RefUpdateResult.FastForward:
                    return "fast forward";

                case RefUpdateResult.New:
                    return "created";

                default:
                    return null;
            }
        }
コード例 #19
0
 public override RefUpdateResult execute(RefUpdateResult status)
 {
     if (status == RefUpdateResult.NO_CHANGE)
         return status;
     return _refUpdate.doUpdate(status);
 }
コード例 #20
0
 public override RefUpdateResult Store(LockFile lockFile, RefUpdateResult status)
 {
     return(RefUpdate.UpdateRepositoryStore(lockFile, status));
 }
コード例 #21
0
ファイル: RefUpdate.cs プロジェクト: gilran/GitSharp
 private RefUpdateResult updateStore(LockFile @lock, RefUpdateResult status)
 {
     if (status == RefUpdateResult.NoChange)
         return status;
     @lock.NeedStatInformation=(true);
     @lock.Write(newValue);
     string msg = GetRefLogMessage();
     if (msg != null && refLogIncludeResult)
     {
         if (status == RefUpdateResult.Forced)
             msg += ": forced-update";
         else if (status == RefUpdateResult.FastForward)
             msg += ": fast forward";
         else if (status == RefUpdateResult.New)
             msg += ": created";
     }
     RefLogWriter.append(this, msg);
     if ([email protected]())
         return RefUpdateResult.LockFailure;
     db.stored(this._ref.OriginalName, _ref.Name, newValue, @lock.CommitLastModified);
     return status;
 }
コード例 #22
0
 public override RefUpdateResult execute(RefUpdateResult status)
 {
     return(_refUpdate.doDelete(status));
 }
コード例 #23
0
 protected abstract RefUpdateResult doDelete(RefUpdateResult desiredResult);
コード例 #24
0
 public abstract RefUpdateResult execute(RefUpdateResult status);
コード例 #25
0
 public override RefUpdateResult execute(RefUpdateResult status)
 {
     return _refUpdate.doDelete(status);
 }
コード例 #26
0
 /// <summary>
 /// Gracefully update the ref to the new value.
 /// <para/>
 /// Merge test will be performed according to <see cref="IsForceUpdate"/>.
 /// </summary>
 /// <param name="walk">
 /// a RevWalk instance this update command can borrow to perform
 /// the merge test. The walk will be reset to perform the test.
 /// </param>
 /// <returns>
 /// the result status of the update.
 /// </returns>
 public RefUpdateResult update(RevWalk.RevWalk walk)
 {
     requireCanDoUpdate();
     try
     {
         return result = updateImpl(walk, new UpdateStore(this));
     }
     catch (IOException x)
     {
         result = RefUpdateResult.IO_FAILURE;
         throw x;
     }
 }
コード例 #27
0
ファイル: RefDirectoryUpdate.cs プロジェクト: dev218/GitSharp
 protected override RefUpdateResult doDelete(RefUpdateResult status)
 {
     if (Ref.getLeaf().getStorage() != Storage.New)
         _database.delete(this);
     return status;
 }
コード例 #28
0
 public abstract RefUpdateResult Store(LockFile lockFile, RefUpdateResult status);
コード例 #29
0
        /// <summary>
        /// Replace this reference with a symbolic reference to another reference.
        /// <para/>
        /// This exact reference (not its traversed leaf) is replaced with a symbolic
        /// reference to the requested name.
        /// </summary>
        /// <param name="target">
        /// name of the new target for this reference. The new target name
        /// must be absolute, so it must begin with {@code refs/}.
        /// </param>
        /// <returns><see cref="RefUpdateResult.NEW"/> or <see cref="RefUpdateResult.FORCED"/> on success.</returns>
        public RefUpdateResult link(string target)
        {
            if (!target.StartsWith(Constants.R_REFS))
                throw new ArgumentException("Not " + Constants.R_REFS);
            if (getRefDatabase().isNameConflicting(Name))
                return RefUpdateResult.LOCK_FAILURE;
            try
            {
                if (!tryLock(false))
                    return RefUpdateResult.LOCK_FAILURE;

                Ref old = getRefDatabase().getRef(Name);
                if (old != null && old.isSymbolic())
                {
                    Ref dst = old.getTarget();
                    if (target.Equals(dst.getName()))
                        return result = RefUpdateResult.NO_CHANGE;
                }

                if (old != null && old.getObjectId() != null)
                    OldObjectId = (old.getObjectId());

                Ref dst2 = getRefDatabase().getRef(target);
                if (dst2 != null && dst2.getObjectId() != null)
                    NewObjectId = (dst2.getObjectId());

                return result = doLink(target);
            }
            catch (IOException x)
            {
                result = RefUpdateResult.IO_FAILURE;
                throw;
            }
            finally
            {
                unlock();
            }
        }
コード例 #30
0
ファイル: RefUpdate.cs プロジェクト: gilran/GitSharp
 public override RefUpdateResult Store(LockFile lockFile, RefUpdateResult status)
 {
     return ref_update.updateStore(lockFile, status);
 }
コード例 #31
0
 public abstract RefUpdateResult execute(RefUpdateResult status);
コード例 #32
0
ファイル: RefUpdate.cs プロジェクト: gilran/GitSharp
            public override RefUpdateResult Store(LockFile @lock, RefUpdateResult status)
            {
                GitSharp.Ref.Storage storage = ref_update._ref.StorageFormat;
                if (storage == GitSharp.Ref.Storage.New)
                    return status;
                if (storage.IsPacked)
                    ref_update.db.removePackedRef(ref_update._ref.Name);

                int levels = Count(ref_update._ref.Name, '/') - 2;

                // Delete logs _before_ unlocking
                DirectoryInfo gitDir = ref_update.db.Repository.Directory;
                DirectoryInfo logDir = new DirectoryInfo(gitDir+"/"+ Constants.LOGS);
                deleteFileAndEmptyDir(new FileInfo(logDir + "/" + ref_update._ref.Name), levels);

                // We have to unlock before (maybe) deleting the parent directories
                @lock.Unlock();
                if (storage.IsLoose)
                    deleteFileAndEmptyDir(ref_update.looseFile, levels);
                return status;
            }
コード例 #33
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
        /// <summary>
        /// Delete the ref.
        /// </summary>
        /// <param name="walk">
        /// A <see cref="RevWalk"/> instance this Delete command can borrow to 
        /// perform the merge test. The walk will be reset to perform the test.
        /// </param>
        /// <returns>The result status of the Delete.</returns>
        public RefUpdateResult Delete(RevWalk.RevWalk walk)
        {
            if (Name.StartsWith(Constants.R_HEADS))
            {
                Ref head = _db.ReadRef(Constants.HEAD);
                if (head != null && Name.Equals(head.Name))
                {
                    return Result = RefUpdateResult.RejectedCurrentBranch;
                }
            }

            try
            {
                return Result = UpdateImpl(walk, new DeleteStore(this));
            }
            catch (IOException)
            {
                Result = RefUpdateResult.IOFailure;
                throw;
            }
        }
コード例 #34
0
ファイル: RefDirectoryUpdate.cs プロジェクト: dev218/GitSharp
 private static string toResultString(RefUpdateResult status)
 {
     switch (status)
     {
         case RefUpdateResult.FORCED:
             return "forced-update";
         case RefUpdateResult.FAST_FORWARD:
             return "fast forward";
         case RefUpdateResult.NEW:
             return "created";
         default:
             return null;
     }
 }
コード例 #35
0
ファイル: RefUpdate.cs プロジェクト: stschake/GitSharp
 /// <summary>
 /// Gracefully update the ref to the new value.
 /// </summary>
 /// <param name="walk">
 /// A <see cref="RevWalk"/> instance this update command can borrow to 
 /// perform the merge test. The walk will be reset to perform the test.
 /// </param>
 /// <returns>The result status of the update.</returns>
 public RefUpdateResult Update(RevWalk.RevWalk walk)
 {
     RequireCanDoUpdate();
     try
     {
         return Result = UpdateImpl(walk, new UpdateStore(this));
     }
     catch (IOException)
     {
         Result = RefUpdateResult.IOFailure;
         throw;
     }
 }
コード例 #36
0
ファイル: RefDirectoryUpdate.cs プロジェクト: dev218/GitSharp
        protected override RefUpdateResult doUpdate(RefUpdateResult status)
        {
            _lock.setNeedStatInformation(true);
            _lock.Write(NewObjectId);

            string msg = getRefLogMessage();
            if (msg != null)
            {
                if (isRefLogIncludingResult())
                {
                    string strResult = toResultString(status);
                    if (strResult != null)
                    {
                        if (msg.Length > 0)
                            msg = msg + ": " + strResult;
                        else
                            msg = strResult;
                    }
                }
                _database.log(this, msg, true);
            }
            if (!_lock.Commit())
                return RefUpdateResult.LOCK_FAILURE;
            _database.stored(this, _lock.CommitLastModified);
            return status;
        }
コード例 #37
0
        /// <summary>
        /// Delete the ref.
        /// </summary>
        /// <param name="walk">
        /// a RevWalk instance this delete command can borrow to perform
        /// the merge test. The walk will be reset to perform the test.
        /// </param>
        /// <returns>the result status of the delete.</returns>
        public RefUpdateResult delete(RevWalk.RevWalk walk)
        {
            string myName = Ref.getLeaf().getName();
            if (myName.StartsWith(Constants.R_HEADS))
            {
                Ref head = getRefDatabase().getRef(Constants.HEAD);
                while (head.isSymbolic())
                {
                    head = head.getTarget();
                    if (myName.Equals(head.getName()))
                        return result = RefUpdateResult.REJECTED_CURRENT_BRANCH;
                }
            }

            try
            {
                return result = updateImpl(walk, new DeleteStore(this));
            }
            catch (IOException x)
            {
                result = RefUpdateResult.IO_FAILURE;
                throw;
            }
        }