mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
fc8c0d61a1
Summary: This allows us to use fastmanifest as a directory to drop in the python module. Test Plan: compiles, passes existing tests. Reviewers: lcharignon Reviewed By: lcharignon Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3351021 Signature: t1:3351021:1464284417:6cbcde514ab1fd7b5caa6c83cb5577f3502dbc58
88 lines
2.5 KiB
C
88 lines
2.5 KiB
C
// Copyright 2016-present Facebook. All Rights Reserved.
|
|
//
|
|
// tree_path.h: declarations for the core path function for parsing and
|
|
// traversing a path through a tree.
|
|
//
|
|
// no-check-code
|
|
|
|
#ifndef __FASTMANIFEST_TREE_PATH_H__
|
|
#define __FASTMANIFEST_TREE_PATH_H__
|
|
|
|
#include "node.h"
|
|
|
|
typedef struct _tree_state_changes_t {
|
|
ptrdiff_t size_change;
|
|
int32_t num_leaf_node_change;
|
|
bool non_arena_allocations;
|
|
bool checksum_dirty;
|
|
} tree_state_changes_t;
|
|
|
|
typedef enum {
|
|
TREE_ADD_CHILD_OK,
|
|
TREE_ADD_CHILD_OOM,
|
|
TREE_ADD_CHILD_WTF,
|
|
} tree_add_child_code_t;
|
|
typedef struct _tree_add_child_result_t {
|
|
tree_add_child_code_t code;
|
|
node_t *newroot;
|
|
node_t *newchild;
|
|
} tree_add_child_result_t;
|
|
|
|
typedef enum {
|
|
// walks the tree and searches for a leaf node. if the path cannot be found,
|
|
// exit with `FIND_PATH_NOT_FOUND`.
|
|
BASIC_WALK,
|
|
|
|
// walks the tree and searches for any node (including implicit nodes). if
|
|
// the path cannot be found, exit with `FIND_PATH_NOT_FOUND`.
|
|
BASIC_WALK_ALLOW_IMPLICIT_NODES,
|
|
|
|
// walks the tree. if the intermediate paths cannot be found, create them.
|
|
// if a leaf node exists where an intermediate path node needs to be
|
|
// created, then return `FIND_PATH_CONFLICT`.
|
|
CREATE_IF_MISSING,
|
|
|
|
// walks the tree. if the path cannot be found, exit with
|
|
// `FIND_PATH_NOT_FOUND`. if the operation is successful, then check
|
|
// intermediate nodes to ensure that they still have children. any nodes
|
|
// that do not should be removed.
|
|
REMOVE_EMPTY_IMPLICIT_NODES,
|
|
} find_path_operation_type;
|
|
typedef enum {
|
|
FIND_PATH_OK,
|
|
FIND_PATH_NOT_FOUND,
|
|
FIND_PATH_OOM,
|
|
FIND_PATH_CONFLICT,
|
|
FIND_PATH_WTF,
|
|
} find_path_result_t;
|
|
typedef struct _find_path_callback_result_t {
|
|
find_path_result_t code;
|
|
node_t *newroot;
|
|
} find_path_callback_result_t;
|
|
|
|
extern tree_add_child_result_t tree_add_child(
|
|
tree_t *tree,
|
|
node_t *const root_parent,
|
|
node_t *root,
|
|
const char *name, const size_t name_sz,
|
|
size_t num_children_hint,
|
|
tree_state_changes_t *changes);
|
|
|
|
extern find_path_result_t find_path(
|
|
tree_t *tree,
|
|
node_t *const root_parent,
|
|
node_t *root,
|
|
const char *path, const size_t path_sz,
|
|
find_path_operation_type operation_type,
|
|
tree_state_changes_t *changes,
|
|
find_path_callback_result_t (*callback)(
|
|
tree_t *tree,
|
|
node_t *const dir_parent,
|
|
node_t *dir,
|
|
const char *path, const size_t path_sz,
|
|
tree_state_changes_t *changes,
|
|
void *context),
|
|
void *context);
|
|
|
|
#endif // #ifndef __FASTMANIFEST_TREE_PATH_H__
|