Hard override on changes from master repo

This commit is contained in:
Jakob Borg
2014-06-16 10:47:02 +02:00
parent 12eda0449a
commit 26ebbee877
5 changed files with 42 additions and 3 deletions

View File

@@ -851,3 +851,26 @@ func (m *Model) State(repo string) string {
return "unknown"
}
}
func (m *Model) Override(repo string) {
fs := m.NeedFilesRepo(repo)
m.rmut.Lock()
r := m.repoFiles[repo]
for i := range fs {
f := &fs[i]
h := r.Get(cid.LocalID, f.Name)
if h.Name != f.Name {
// We are missing the file
f.Flags |= protocol.FlagDeleted
f.Blocks = nil
} else {
// We have the file, replace with our version
*f = h
}
f.Version = lamport.Default.Tick(f.Version)
}
m.rmut.Unlock()
r.Update(cid.LocalID, fs)
}