mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
e953a3cc27
Summary: Directly pass in the path + len and the node. Note that the path is now a char* + len, because this allows us to use the path in treemanifest_find directly, rather than to construct a new path. Test Plan: run existing perftest without crash. Reviewers: #fastmanifest, durham Reviewed By: durham Subscribers: mitrandir Differential Revision: https://phabricator.intern.facebook.com/D3738280 Signature: t1:3738280:1471890923:c13283f1c61dc020ba1918ee9b25c24dfd2fc19b
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
// manifest_fetcher.cpp - c++ implementation of a fetcher for manifests
|
|
//
|
|
// Copyright 2016 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
|
|
|
|
#include "manifest_fetcher.h"
|
|
|
|
ManifestFetcher::ManifestFetcher(PythonObj &store) :
|
|
_get(store.getattr("get")) {
|
|
}
|
|
|
|
/**
|
|
* Fetches the Manifest from the store for the provided manifest key.
|
|
* Returns the manifest if found, or throws an exception if not found.
|
|
*/
|
|
Manifest *ManifestFetcher::get(
|
|
const char *path, size_t pathlen,
|
|
std::string &node) const {
|
|
PythonObj arglist = Py_BuildValue("s#s#",
|
|
path, (Py_ssize_t) pathlen,
|
|
node.c_str(), (Py_ssize_t)node.size());
|
|
|
|
PyObject *result = PyEval_CallObject(this->_get, arglist);
|
|
|
|
if (!result) {
|
|
if (PyErr_Occurred()) {
|
|
throw pyexception();
|
|
}
|
|
|
|
PyErr_Format(PyExc_RuntimeError,
|
|
"unable to find tree '%.*s:...'", (int) pathlen, path);
|
|
throw pyexception();
|
|
}
|
|
|
|
PythonObj resultobj(result);
|
|
return new Manifest(resultobj);
|
|
}
|