/** * Create the <code>pack-*.keep</code> file, with the given message. * * @param msg * message to store in the file. * @return true if the keep file was successfully written; false otherwise. * @throws IOException * the keep file could not be written. */ public bool Lock(string msg) { if (msg == null) return false; if (!msg.EndsWith("\n")) msg += "\n"; LockFile lf = new LockFile(keepFile); if (!lf.Lock()) return false; lf.Write(Constants.encode(msg)); return lf.Commit(); }
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); } }
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; }
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(); } }
private RefUpdateResult UpdateRepositoryStore(LockFile @lock, RefUpdateResult status) { if (status == RefUpdateResult.NoChange) return status; @lock.NeedStatInformation = true; @lock.Write(_newValue); string msg = GetRefLogMessage(); if (!string.IsNullOrEmpty(msg)) { 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; }