mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
3b5fb8770e
Summary: Implements the getdeltachain function on the new UnionDatapackStore class. This required some modifications to the DeltaChainIterator. Since the results of the iterator may cross multiple different chains, we need to keep each chain alive until the iterator is destructed, so we need to keep a reference to each chain. We also had to remove the size() property from the iterator since the fact that the chain spans chains means we don't know the size up front. Test Plan: Adds a test Reviewers: #mercurial, simonfar Reviewed By: simonfar Subscribers: simonfar, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D4556458 Signature: t1:4556458:1487199872:07dffa3121acfbeb6d6993b518e6f4887122d4d5
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
// key.h - c++ declarations for a key to pack data
|
|
//
|
|
// Copyright 2017 Facebook, Inc.
|
|
//
|
|
// This software may be used and distributed according to the terms of the
|
|
// GNU General Public License version 2 or any later version.
|
|
//
|
|
// no-check-code
|
|
|
|
#ifndef KEY_H
|
|
#define KEY_H
|
|
|
|
#include <cstring>
|
|
#include <vector>
|
|
#include <stdexcept>
|
|
|
|
#include "convert.h"
|
|
|
|
/* Represents a key into the Mercurial store. Each key is a (name, node) pair,
|
|
* though store implementations can choose to ignore the name in some cases. */
|
|
struct Key {
|
|
/* The filename portion of the key. */
|
|
std::string name;
|
|
|
|
/* The byte node portion of the key. */
|
|
char node[BIN_NODE_SIZE];
|
|
|
|
Key() :
|
|
node() {}
|
|
|
|
Key(const char *name, size_t namelen, const char *node, size_t nodelen) :
|
|
name(name, namelen) {
|
|
if (nodelen != BIN_NODE_SIZE) {
|
|
throw std::logic_error("invalid node length");
|
|
}
|
|
|
|
memcpy(this->node, node, BIN_NODE_SIZE);
|
|
}
|
|
};
|
|
|
|
class MissingKeyError : public std::runtime_error {
|
|
public:
|
|
MissingKeyError(const char *what_arg) :
|
|
std::runtime_error(what_arg) {
|
|
}
|
|
};
|
|
|
|
class KeyIterator {
|
|
protected:
|
|
KeyIterator() {}
|
|
public:
|
|
virtual Key *next() = 0;
|
|
};
|
|
|
|
#endif //KEY_H
|