mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 09:48:05 +03:00
c12e300bb8
Summary: Move top-level Python packages `mercurial`, `hgext` and `hgdemandimport` to a new top-level package `edenscm`. This allows the Python packages provided by the upstream Mercurial to be installed side-by-side. To maintain compatibility, `edenscm/` gets added to `sys.path` in `mercurial/__init__.py`. Reviewed By: phillco, ikostia Differential Revision: D13853115 fbshipit-source-id: b296b0673dc54c61ef6a591ebc687057ff53b22e
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
//
|
|
// tree_dump: Load a tree from disk. Then print all the node hashes along
|
|
// with the length of the name and the number of children.
|
|
//
|
|
// no-check-code
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "edenscm/hgext/extlib/cfastmanifest/tree.h"
|
|
#include "lib/clib/convert.h"
|
|
#include "tests.h"
|
|
|
|
static char buffer[SHA1_BYTES * 2];
|
|
|
|
void print_subtree(node_t* node) {
|
|
hexlify(node->checksum, node->checksum_sz, buffer);
|
|
|
|
printf(
|
|
"%.*s\t%d\t%d\n",
|
|
node->checksum_sz * 2,
|
|
buffer,
|
|
node->name_sz,
|
|
node->num_children);
|
|
|
|
for (uint32_t ix = 0; ix < node->num_children; ix++) {
|
|
print_subtree(get_child_by_index(node, ix));
|
|
}
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if (argc < 2) {
|
|
fprintf(stderr, "Usage: %s <tree-save-file>\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
read_from_file_result_t read_from_file_result =
|
|
read_from_file(argv[1], strlen(argv[1]));
|
|
if (read_from_file_result.code != READ_FROM_FILE_OK) {
|
|
fprintf(stderr, "Unable to read tree file %s\n", argv[1]);
|
|
exit(1);
|
|
}
|
|
|
|
tree_t* tree = read_from_file_result.tree;
|
|
node_t* shadow_root = tree->shadow_root;
|
|
node_t* real_root = get_child_by_index(shadow_root, 0);
|
|
|
|
print_subtree(real_root);
|
|
|
|
return 0;
|
|
}
|