public _RefWriter_712(RefDirectory _enclosing, LockFile lck, RefDirectory.PackedRefList oldPackedList, RefList <Ref> refs, RefList <Ref> baseArg1) : base(baseArg1) { this._enclosing = _enclosing; this.lck = lck; this.oldPackedList = oldPackedList; this.refs = refs; }
/// <exception cref="System.IO.IOException"></exception> internal virtual void Delete(RefDirectoryUpdate update) { Ref dst = update.GetRef().GetLeaf(); string name = dst.GetName(); // Write the packed-refs file using an atomic update. We might // wind up reading it twice, before and after the lock, to ensure // we don't miss an edit made externally. RefDirectory.PackedRefList packed = GetPackedRefs(); if (packed.Contains(name)) { LockFile lck = new LockFile(packedRefsFile, update.GetRepository().FileSystem); if (!lck.Lock()) { throw new LockFailedException(packedRefsFile); } try { RefDirectory.PackedRefList cur = ReadPackedRefs(); int idx = cur.Find(name); if (0 <= idx) { CommitPackedRefs(lck, cur.Remove(idx), packed); } } finally { lck.Unlock(); } } RefList <RefDirectory.LooseRef> curLoose; RefList <RefDirectory.LooseRef> newLoose; do { curLoose = looseRefs.Get(); int idx = curLoose.Find(name); if (idx < 0) { break; } newLoose = curLoose.Remove(idx); }while (!looseRefs.CompareAndSet(curLoose, newLoose)); int levels = LevelsIn(name) - 2; Delete(logWriter.LogFor(name), levels); if (dst.GetStorage().IsLoose()) { update.Unlock(); Delete(FileFor(name), levels); } modCnt.IncrementAndGet(); FireRefsChanged(); }
/// <exception cref="System.IO.IOException"></exception> private RefDirectory.PackedRefList GetPackedRefs() { RefDirectory.PackedRefList curList = packedRefs.Get(); if (!curList.snapshot.IsModified(packedRefsFile)) { return(curList); } RefDirectory.PackedRefList newList = ReadPackedRefs(); if (packedRefs.CompareAndSet(curList, newList) && !curList.id.Equals(newList.id)) { modCnt.IncrementAndGet(); } return(newList); }
/// <exception cref="System.IO.IOException"></exception> private void CommitPackedRefs(LockFile lck, RefList <Ref> refs, RefDirectory.PackedRefList oldPackedList) { new _RefWriter_712(this, lck, oldPackedList, refs, refs).WritePackedRefs(); }