コード例 #1
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
        private void updateFETCH_HEAD(FetchResult result)
        {
            LockFile @lock = new LockFile(new FileInfo(Path.Combine(_transport.Local.Directory.FullName, "FETCH_HEAD")));

            try
            {
                if (@lock.Lock())
                {
                    StreamWriter w = new StreamWriter(@lock.GetOutputStream());

                    try
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }
                    finally
                    {
                        w.Close();
                    }

                    @lock.Commit();
                }
            }
            finally
            {
                @lock.Unlock();
            }
        }
コード例 #2
0
ファイル: DirCache.cs プロジェクト: ashmind/ngit
        /// <summary>Commit this change and release the lock.</summary>
        /// <remarks>
        /// Commit this change and release the lock.
        /// <p>
        /// If this method fails (returns false) the lock is still released.
        /// </remarks>
        /// <returns>
        /// true if the commit was successful and the file contains the new
        /// data; false if the commit failed and the file remains with the
        /// old data.
        /// </returns>
        /// <exception cref="System.InvalidOperationException">the lock is not held.</exception>
        public virtual bool Commit()
        {
            LockFile tmp = myLock;

            RequireLocked(tmp);
            myLock = null;
            if (!tmp.Commit())
            {
                return(false);
            }
            snapshot = tmp.GetCommitSnapshot();
            return(true);
        }
コード例 #3
0
ファイル: DirCache.cs プロジェクト: yhtsnda/Bonobo-Git-Server
        ///	<summary>
        /// Commit this change and release the lock.
        /// <para />
        /// If this method fails (returns false) the lock is still released.
        /// </summary>
        /// <returns>
        /// True if the commit was successful and the file contains the new
        /// data; false if the commit failed and the file remains with the
        /// old data.
        /// </returns>
        ///	<exception cref="InvalidOperationException">
        /// the lock is not held.
        /// </exception>
        public bool commit()
        {
            LockFile tmp = _myLock;

            RequireLocked(tmp);
            _myLock = null;
            if (!tmp.Commit())
            {
                return(false);
            }
            _lastModified = tmp.CommitLastModified;
            return(true);
        }
コード例 #4
0
        /// <summary>Commit this change and release the lock.</summary>
        /// <remarks>
        /// Commit this change and release the lock.
        /// <p>
        /// If this method fails (returns false) the lock is still released.
        /// </remarks>
        /// <returns>
        /// true if the commit was successful and the file contains the new
        /// data; false if the commit failed and the file remains with the
        /// old data.
        /// </returns>
        /// <exception cref="System.InvalidOperationException">the lock is not held.</exception>
        public virtual bool Commit()
        {
            LockFile tmp = myLock;

            RequireLocked(tmp);
            myLock = null;
            if (!tmp.Commit())
            {
                return(false);
            }
            snapshot = tmp.GetCommitSnapshot();
            if (indexChangedListener != null && !Arrays.Equals(readIndexChecksum, writeIndexChecksum
                                                               ))
            {
                indexChangedListener.OnIndexChanged(new IndexChangedEvent());
            }
            return(true);
        }
コード例 #5
0
        private void updateFETCH_HEAD(FetchResult result)
        {
            using (LockFile @lock = new LockFile(PathUtil.CombineFilePath(_transport.Local.Directory, "FETCH_HEAD")))
            {
                if (@lock.Lock())
                {
                    using (StreamWriter w = new StreamWriter(@lock.GetOutputStream()))
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }

                    @lock.Commit();
                }
            }
        }
コード例 #6
0
        protected internal override void WriteFile(string file, byte[] content)
        {
            FilePath p   = new FilePath(_db.Directory, file);
            LockFile lck = new LockFile(p, FS.DETECTED);

            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);
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
0
        /// <exception cref="System.IO.IOException"></exception>
        private void UpdateFETCH_HEAD(FetchResult result)
        {
            FilePath meta = transport.local.Directory;

            if (meta == null)
            {
                return;
            }
            LockFile Lock = new LockFile(new FilePath(meta, "FETCH_HEAD"), transport.local.FileSystem
                                         );

            try
            {
                if (Lock.Lock())
                {
                    TextWriter w = new OutputStreamWriter(Lock.GetOutputStream());
                    try
                    {
                        foreach (FetchHeadRecord h in fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }
                    finally
                    {
                        w.Close();
                    }
                    Lock.Commit();
                }
            }
            finally
            {
                Lock.Unlock();
            }
        }
コード例 #9
0
ファイル: FetchProcess.cs プロジェクト: HackerBaloo/GitSharp
        private void updateFETCH_HEAD(FetchResult result)
        {
            LockFile @lock = new LockFile(new FileInfo(Path.Combine(_transport.Local.Directory.FullName, "FETCH_HEAD")));
            try
            {
                if (@lock.Lock())
                {
                    StreamWriter w = new StreamWriter(@lock.GetOutputStream());

                    try
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }
                    finally
                    {
                        w.Close();
                    }

                    @lock.Commit();
                }
            }
            finally
            {
                @lock.Unlock();
            }
        }
コード例 #10
0
ファイル: FetchProcess.cs プロジェクト: dev218/GitSharp
        private void updateFETCH_HEAD(FetchResult result)
        {
            using (LockFile @lock = new LockFile(PathUtil.CombineFilePath(_transport.Local.Directory, "FETCH_HEAD")))
            {
                if (@lock.Lock())
                {
                    using (StreamWriter w = new StreamWriter(@lock.GetOutputStream()))
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }

                    @lock.Commit();
                }
            }
        }