From 9074c923ea5d8b290563f90f5ff2e400add98032 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 25 Oct 2015 17:06:56 +0100 Subject: [PATCH] index: add AddToSupersedes() --- repository/index.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/repository/index.go b/repository/index.go index 66c734585..ec714c94c 100644 --- a/repository/index.go +++ b/repository/index.go @@ -165,6 +165,20 @@ func (idx *Index) Supersedes() backend.IDs { return idx.supersedes } +// AddToSupersedes adds the ids to the list of indexes superseded by this +// index. If the index has already been finalized, an error is returned. +func (idx *Index) AddToSupersedes(ids ...backend.ID) error { + idx.m.Lock() + defer idx.m.Unlock() + + if idx.final { + return errors.New("index already finalized") + } + + idx.supersedes = append(idx.supersedes, ids...) + return nil +} + // PackedBlob is a blob already saved within a pack. type PackedBlob struct { pack.Blob