mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
[ctreemanifest] move treemanifest_get inside the treemanifest class
Summary: This removes a bunch of extra arguments we were passing in because the treemanifest knows about it already. Also inlined the entire resolve-the-root-manifest operation into a separate method. Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/fb-hgext/tests/perftest.py --config remotefilelog.fastdatapack=True testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"` Reviewers: #fastmanifest, durham Reviewed By: durham Subscribers: durham, mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3800793 Signature: t1:3800793:1472758998:c4617894c947f84268a3fa1d0cdde03793889640
This commit is contained in:
parent
dac5c4103c
commit
fb19ea1321
@ -185,14 +185,9 @@ static PyObject *treemanifest_find(PyObject *o, PyObject *args) {
|
||||
char resultflag;
|
||||
try {
|
||||
// Grab the root node's data
|
||||
if (self->tm.rootManifest == NULL) {
|
||||
self->tm.rootManifest = fetcher.get(NULL, 0, self->tm.rootNode);
|
||||
}
|
||||
|
||||
treemanifest_get(
|
||||
self->tm.treemanifest_get(
|
||||
std::string(filename, filenamelen),
|
||||
self->tm.rootManifest,
|
||||
fetcher,
|
||||
&resultnode, &resultflag);
|
||||
} catch (const pyexception &ex) {
|
||||
return NULL;
|
||||
@ -395,15 +390,8 @@ static PyObject *treemanifest_getitem(py_treemanifest *self, PyObject *key) {
|
||||
std::string resultnode;
|
||||
char resultflag;
|
||||
try {
|
||||
// Grab the root node's data
|
||||
if (self->tm.rootManifest == NULL) {
|
||||
self->tm.rootManifest = fetcher.get(NULL, 0, self->tm.rootNode);
|
||||
}
|
||||
|
||||
treemanifest_get(
|
||||
self->tm.treemanifest_get(
|
||||
std::string(filename, filenamelen),
|
||||
self->tm.rootManifest,
|
||||
fetcher,
|
||||
&resultnode, &resultflag);
|
||||
} catch (const pyexception &ex) {
|
||||
return NULL;
|
||||
@ -443,15 +431,8 @@ static PyObject *treemanifest_flags(py_treemanifest *self, PyObject *args, PyObj
|
||||
std::string resultnode;
|
||||
char resultflag;
|
||||
try {
|
||||
// Grab the root node's data
|
||||
if (self->tm.rootManifest == NULL) {
|
||||
self->tm.rootManifest = fetcher.get(NULL, 0, self->tm.rootNode);
|
||||
}
|
||||
|
||||
treemanifest_get(
|
||||
self->tm.treemanifest_get(
|
||||
std::string(filename, filenamelen),
|
||||
self->tm.rootManifest,
|
||||
fetcher,
|
||||
&resultnode, &resultflag);
|
||||
} catch (const pyexception &ex) {
|
||||
return NULL;
|
||||
@ -598,15 +579,8 @@ static int treemanifest_contains(py_treemanifest *self, PyObject *key) {
|
||||
std::string resultnode;
|
||||
char resultflag;
|
||||
try {
|
||||
// Grab the root node's data
|
||||
if (self->tm.rootManifest == NULL) {
|
||||
self->tm.rootManifest = fetcher.get(NULL, 0, self->tm.rootNode);
|
||||
}
|
||||
|
||||
treemanifest_get(
|
||||
self->tm.treemanifest_get(
|
||||
std::string(filename, filenamelen),
|
||||
self->tm.rootManifest,
|
||||
fetcher,
|
||||
&resultnode, &resultflag);
|
||||
if (resultnode.size() == 0) {
|
||||
return 0;
|
||||
|
@ -322,11 +322,11 @@ static FindResult treemanifest_get_callback(
|
||||
return FIND_PATH_OK;
|
||||
}
|
||||
|
||||
void treemanifest_get(
|
||||
void treemanifest::treemanifest_get(
|
||||
const std::string &filename,
|
||||
Manifest *rootmanifest,
|
||||
const ManifestFetcher &fetcher,
|
||||
std::string *resultnode, char *resultflag) {
|
||||
resolveRootManifest();
|
||||
|
||||
GetResult extras = {resultnode, resultflag};
|
||||
PathIterator pathiter(filename);
|
||||
FindContext changes;
|
||||
@ -334,7 +334,7 @@ void treemanifest_get(
|
||||
changes.extras = &extras;
|
||||
|
||||
treemanifest_find(
|
||||
rootmanifest,
|
||||
this->rootManifest,
|
||||
pathiter,
|
||||
fetcher,
|
||||
BASIC_WALK,
|
||||
|
@ -95,22 +95,33 @@ class PathIterator {
|
||||
* A single instance of a treemanifest.
|
||||
*/
|
||||
struct treemanifest {
|
||||
// Fetcher for the manifests.
|
||||
ManifestFetcher fetcher;
|
||||
// Fetcher for the manifests.
|
||||
ManifestFetcher fetcher;
|
||||
|
||||
// The 20-byte root node of this manifest
|
||||
std::string rootNode;
|
||||
// The 20-byte root node of this manifest
|
||||
std::string rootNode;
|
||||
|
||||
// The resolved Manifest node, if the root has already been resolved.
|
||||
Manifest *rootManifest;
|
||||
// The resolved Manifest node, if the root has already been resolved.
|
||||
Manifest *rootManifest;
|
||||
|
||||
treemanifest(PythonObj store, std::string rootNode) :
|
||||
fetcher(store),
|
||||
rootNode(rootNode),
|
||||
rootManifest(NULL) {
|
||||
}
|
||||
treemanifest(PythonObj store, std::string rootNode) :
|
||||
fetcher(store),
|
||||
rootNode(rootNode),
|
||||
rootManifest(NULL) {
|
||||
}
|
||||
|
||||
~treemanifest();
|
||||
~treemanifest();
|
||||
|
||||
void treemanifest_get(
|
||||
const std::string &filename,
|
||||
std::string *resultnode, char *resultflag);
|
||||
|
||||
private:
|
||||
void resolveRootManifest() {
|
||||
if (this->rootManifest == NULL) {
|
||||
this->rootManifest = fetcher.get(NULL, 0, this->rootNode);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -162,12 +173,6 @@ struct fileiter {
|
||||
}
|
||||
};
|
||||
|
||||
extern void treemanifest_get(
|
||||
const std::string &filename,
|
||||
Manifest *rootmanifest,
|
||||
const ManifestFetcher &fetcher,
|
||||
std::string *resultnode, char *resultflag);
|
||||
|
||||
extern void treemanifest_diffrecurse(
|
||||
Manifest *selfmf,
|
||||
Manifest *othermf,
|
||||
|
Loading…
Reference in New Issue
Block a user