Ejemplo n.º 1
0
        public void stored(RefDirectoryUpdate update, long modified)
        {
            ObjectId target = update.getNewObjectId().Copy();
            Ref      leaf   = update.getRef().getLeaf();

            putLooseRef(new LooseUnpeeled(modified, leaf.getName(), target));
        }
Ejemplo n.º 2
0
        public 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.
            PackedRefList packed = getPackedRefs();

            if (packed.contains(name))
            {
                var lck = new LockFile(packedRefsFile);
                if (!lck.Lock())
                {
                    throw new IOException("Cannot lock " + packedRefsFile);
                }
                try
                {
                    PackedRefList cur = readPackedRefs(0, 0);
                    int           idx = cur.find(name);
                    if (0 <= idx)
                    {
                        commitPackedRefs(lck, cur.remove(idx), packed);
                    }
                }
                finally
                {
                    lck.Unlock();
                }
            }

            RefList <LooseRef> curLoose, 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(logFor(name), levels);
            if (dst.getStorage().IsLoose)
            {
                update.unlock();
                delete(fileFor(name), levels);
            }

            modCnt.incrementAndGet();
            fireRefsChanged();
        }
Ejemplo n.º 3
0
 public void storedSymbolicRef(RefDirectoryUpdate u, long modified, string target)
 {
     putLooseRef(newSymbolicRef(modified, u.getRef().getName(), target));
     fireRefsChanged();
 }