mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 09:48:05 +03:00
228e6a901e
Summary: Moves cstore to hgext/extlib/ and makes it build. Test Plan: make local && run-tests.py Reviewers: #mercurial Differential Revision: https://phabricator.intern.facebook.com/D6678852
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
// Copyright (c) 2004-present, Facebook, Inc.
|
|
// All Rights Reserved.
|
|
//
|
|
// This software may be used and distributed according to the terms of the
|
|
// GNU General Public License version 2 or any later version.
|
|
|
|
// uniondatapackstore.h - c++ declarations for a union datapack store
|
|
// no-check-code
|
|
|
|
#ifndef FBHGEXT_CSTORE_UNIONDATAPACKSTORE_H
|
|
#define FBHGEXT_CSTORE_UNIONDATAPACKSTORE_H
|
|
|
|
#include <cstring>
|
|
#include <stdexcept>
|
|
#include <vector>
|
|
|
|
extern "C" {
|
|
#include "lib/cdatapack/cdatapack.h"
|
|
}
|
|
|
|
#include "hgext/extlib/cstore/key.h"
|
|
#include "hgext/extlib/cstore/datapackstore.h"
|
|
#include "hgext/extlib/cstore/store.h"
|
|
|
|
class UnionDatapackStore;
|
|
class UnionDatapackStoreKeyIterator : public KeyIterator {
|
|
private:
|
|
UnionDatapackStore &_store;
|
|
KeyIterator &_missing;
|
|
|
|
public:
|
|
UnionDatapackStoreKeyIterator(UnionDatapackStore &store, KeyIterator &missing) :
|
|
_store(store),
|
|
_missing(missing) {}
|
|
|
|
Key *next() override;
|
|
};
|
|
|
|
class UnionDeltaChainIterator: public DeltaChainIterator {
|
|
private:
|
|
UnionDatapackStore &_store;
|
|
protected:
|
|
std::shared_ptr<DeltaChain> getNextChain(const Key &key) override;
|
|
|
|
public:
|
|
UnionDeltaChainIterator(UnionDatapackStore &store, const Key &key) :
|
|
DeltaChainIterator(),
|
|
_store(store) {
|
|
_chains.push_back(this->getNextChain(key));
|
|
}
|
|
};
|
|
|
|
class UnionDatapackStore : public Store {
|
|
public:
|
|
std::vector<DataStore*> _stores;
|
|
|
|
UnionDatapackStore(std::vector<DataStore*> stores);
|
|
|
|
~UnionDatapackStore() override;
|
|
|
|
ConstantStringRef get(const Key &key) override;
|
|
|
|
UnionDeltaChainIterator getDeltaChain(const Key &key);
|
|
|
|
bool contains(const Key &key);
|
|
|
|
UnionDatapackStoreKeyIterator getMissing(KeyIterator &missing);
|
|
|
|
void markForRefresh();
|
|
};
|
|
|
|
#endif // FBHGEXT_CSTORE_UNIONDATAPACKSTORE_H
|