Commit() public method

public Commit ( ) : bool
return bool
コード例 #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
            protected override void writeFile(string name, byte[] content)
            {
                _lck.setNeedStatInformation(true);
                try
                {
                    _lck.Write(content);
                }
                catch (IOException ioe)
                {
                    throw new ObjectWritingException("Unable to write " + name,
                                                     ioe);
                }
                try
                {
                    _lck.waitForStatChange();
                }
                catch (ThreadAbortException)
                {
                    _lck.Unlock();
                    throw new ObjectWritingException("Interrupted writing "
                                                     + name);
                }
                if (!_lck.Commit())
                {
                    throw new ObjectWritingException("Unable to write " + name);
                }

                _packedRefs.compareAndSet(_oldPackedList, new PackedRefList(_refs,
                                                                            content.Length, _lck.CommitLastModified));
            }
コード例 #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
ファイル: PackLock.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Create the <code>pack-*.keep</code> file, with the given message.
        /// </summary>
        /// <param name="msg">message to store in the file.</param>
        /// <returns>
        /// true if the keep file was successfully written; false otherwise.
        /// </returns>
        /// <exception cref="IOException">
		/// The keep file could not be written.
        /// </exception>
        public bool Lock(string msg)
        {
            if (msg == null) 
				return false;
			
            if (!msg.EndsWith("\n")) msg += "\n";
            using(LockFile lf = new LockFile(_keepFile))
			{
	            if (!lf.Lock()) 
					return false;
	            lf.Write(Constants.encode(msg));
	            return lf.Commit();
			}
        }
コード例 #5
0
		protected override void writeFile(string file, byte[] content) {
			FileInfo p = PathUtil.CombineFilePath(_db.Directory, file);
			LockFile lck = new LockFile(p);
			if (!lck.Lock())
				throw new ObjectWritingException("Can't write " + p);
			try {
				lck.Write(content);
			}
			catch (IOException) {
				throw new ObjectWritingException("Can't write " + p);
			}
			if (!lck.Commit())
				throw new ObjectWritingException("Can't write " + p);
		}
コード例 #6
0
        public void save()
        {
            byte[] o = Constants.encode(toText());
            using (LockFile lf = new LockFile(getFile()))
            {
                if (!lf.Lock())
                {
                    throw new IOException("Cannot lock " + getFile());
                }

                lf.Write(o);
                if (!lf.Commit())
                {
                    throw new IOException("Cannot commit write to " + getFile());
                }
            }
        }
コード例 #7
0
ファイル: PackLock.cs プロジェクト: kkl713/GitSharp
        /// <summary>
        /// Create the <code>pack-*.keep</code> file, with the given message.
        /// </summary>
        /// <param name="msg">message to store in the file.</param>
        /// <returns>
        /// true if the keep file was successfully written; false otherwise.
        /// </returns>
        /// <exception cref="IOException">
        /// The keep file could not be written.
        /// </exception>
        public bool Lock(string msg)
        {
            if (msg == null)
            {
                return(false);
            }
            if (!msg.EndsWith("\n"))
            {
                msg += "\n";
            }
            var lf = new LockFile(_keepFile);

            if (!lf.Lock())
            {
                return(false);
            }
            lf.Write(Constants.encode(msg));
            return(lf.Commit());
        }
コード例 #8
0
ファイル: RefDatabase.cs プロジェクト: kkl713/GitSharp
        private static void LockAndWriteFile(FileInfo file, byte[] content)
        {
            string name = file.Name;
            var    lck  = new LockFile(file);

            if (!lck.Lock())
            {
                throw new ObjectWritingException("Unable to lock " + name);
            }

            try
            {
                lck.Write(content);
            }
            catch (IOException ioe)
            {
                throw new ObjectWritingException("Unable to write " + name, ioe);
            }
            if (!lck.Commit())
            {
                throw new ObjectWritingException("Unable to write " + name);
            }
        }
コード例 #9
0
ファイル: FileBasedConfig.cs プロジェクト: georgeck/GitSharp
 public void save()
 {
     byte[] o = Constants.encode(toText());
     LockFile lf = new LockFile(getFile());
     if (!lf.Lock())
         throw new IOException("Cannot lock " + getFile());
     try
     {
         lf.Write(o);
         if (!lf.Commit())
             throw new IOException("Cannot commit write to " + getFile());
     }
     finally
     {
         lf.Unlock();
     }
 }
コード例 #10
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;
        }
コード例 #11
0
ファイル: RefDatabase.cs プロジェクト: stschake/GitSharp
        }

        private static void LockAndWriteFile(FileInfo file, byte[] content)
        {
            string name = file.Name;
            using (LockFile lck = new LockFile(file))
            {
                if (!lck.Lock())
                {
                    throw new ObjectWritingException("Unable to lock " + name);
                }

                try
                {
                    lck.Write(content);
                }
                catch (IOException ioe)
                {
                    throw new ObjectWritingException("Unable to write " + name, ioe);
                }
                if (!lck.Commit())
                {
                    throw new ObjectWritingException("Unable to write " + name);
                }