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); }
/// <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; } }
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); }
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); }
protected override RefUpdateResult doDelete(RefUpdateResult status) { if (Ref.getLeaf().getStorage() != Storage.New) { _database.delete(this); } return(status); }
public override RefUpdateResult execute(RefUpdateResult status) { if (status == RefUpdateResult.NO_CHANGE) { return(status); } return(_refUpdate.doUpdate(status)); }
/// <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; } }
/// <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; } }
/// <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(); } }
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); } }
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); } }
/// <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; } }
protected abstract RefUpdateResult doUpdate(RefUpdateResult desiredResult);
public override RefUpdateResult Store(LockFile lockFile, RefUpdateResult status) { return RefUpdate.UpdateRepositoryStore(lockFile, status); }
public abstract RefUpdateResult Store(LockFile lockFile, RefUpdateResult status);
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; }
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; }
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; } }
public override RefUpdateResult execute(RefUpdateResult status) { if (status == RefUpdateResult.NO_CHANGE) return status; return _refUpdate.doUpdate(status); }
public override RefUpdateResult Store(LockFile lockFile, RefUpdateResult status) { return(RefUpdate.UpdateRepositoryStore(lockFile, status)); }
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 override RefUpdateResult execute(RefUpdateResult status) { return(_refUpdate.doDelete(status)); }
protected abstract RefUpdateResult doDelete(RefUpdateResult desiredResult);
public abstract RefUpdateResult execute(RefUpdateResult status);
public override RefUpdateResult execute(RefUpdateResult status) { return _refUpdate.doDelete(status); }
/// <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; } }
protected override RefUpdateResult doDelete(RefUpdateResult status) { if (Ref.getLeaf().getStorage() != Storage.New) _database.delete(this); return status; }
/// <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(); } }
public override RefUpdateResult Store(LockFile lockFile, RefUpdateResult status) { return ref_update.updateStore(lockFile, status); }
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; }
/// <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; } }
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; } }
/// <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; } }
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; }
/// <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; } }