mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
[ctree] method to update a manifest entry's node and flags
Summary: This is needed when we're updating a node that already exists. Test Plan: used in later diff. Reviewers: #fastmanifest, durham Reviewed By: durham Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3832631 Signature: t1:3832631:1473362920:8a39f02ced91cc9328c57e416d7dfc9a704b0cc6
This commit is contained in:
parent
d7fb495d51
commit
54195bfd97
@ -119,3 +119,33 @@ Manifest *ManifestEntry::get_manifest(
|
||||
|
||||
return this->resolved;
|
||||
}
|
||||
|
||||
void ManifestEntry::update(const char *node, char flag) {
|
||||
// we cannot flip between file and directory.
|
||||
bool wasdir = this->flag != NULL && *this->flag == MANIFEST_DIRECTORY_FLAG;
|
||||
bool willbedir = flag == MANIFEST_DIRECTORY_FLAG;
|
||||
|
||||
if (wasdir != willbedir) {
|
||||
throw std::logic_error("changing to/from directory is not permitted");
|
||||
}
|
||||
|
||||
// if we didn't previously own the memory, we should now.
|
||||
if (this->ownedmemory == NULL) {
|
||||
this->initialize(this->filename, this->filenamelen, node, flag);
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize node if it's not already done.
|
||||
if (this->node == NULL) {
|
||||
this->node = this->filename + this->filenamelen + 1;
|
||||
}
|
||||
memcpy(this->node, node, HEX_NODE_SIZE);
|
||||
|
||||
if (flag == '\0') {
|
||||
*(this->filename + this->filenamelen + 1 + HEX_NODE_SIZE) = '\n';
|
||||
this->flag = NULL;
|
||||
} else {
|
||||
this->flag = this->filename + filenamelen + 1 + HEX_NODE_SIZE;
|
||||
*this->flag = flag;
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ class ManifestEntry {
|
||||
const char *filename, const size_t filenamelen,
|
||||
const char *node,
|
||||
char flag);
|
||||
|
||||
void update(const char *node, char flag);
|
||||
};
|
||||
|
||||
#endif //REMOTEFILELOG_MANIFEST_ENTRY_H
|
||||
|
Loading…
Reference in New Issue
Block a user