sapling/eden/fs/store/Diff.h
Andrey Chursin 0af2511a3f separate out ObjectId [proxy hash removal 1/n]
Summary:
The goal of this stack is to remove Proxy Hash type, but to achieve that we need first to address some tech debt in Eden codebase.

For the long time EdenFs had single Hash type that was used for many different use cases.

One of major uses for Hash type is identifies internal EdenFs objects such as blobs, trees, and others.

We seem to reach agreement that we need a different type for those identifiers, so we introduce separate ObjectId type in this diff to denote new identifier type and replace _some_ usage of Hash with ObjectId.

We still retain original Hash type for other use cases.

Roughly speaking, this is how this diff separates between Hash and ObjectId:

**ObjectId**:
* Everything that is stored in local store(blobs, trees, commits)

**Hash20**:
* Explicit hashes(Sha1 of the blob)
* Hg identifiers: manifest id and blob hg ig

For now, in this diff ObjectId has exactly same content as Hash, but this will change in the future diffs. Doing this way allows to keep diff size manageable, while migrating to new ObjectId right away would produce insanely large diff that would be both hard to make and review.

There are few more things that needs to be done before we can get to the meat of removing proxy hashes:

1) Replace include Hash.h with ObjectId.h where needed
2) Remove Hash type, explicitly rename rest of Hash usages to Hash20
3) Modify content of ObjectId to support new use cases
4) Modify serialized metadata and possibly other places that assume ObjectId size is fixed and equal to Hash20 size

Reviewed By: chadaustin

Differential Revision: D31316477

fbshipit-source-id: 0d5e4460a461bcaac6b9fd884517e129aeaf4baf
2021-10-01 10:25:46 -07:00

105 lines
3.0 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include "eden/fs/service/gen-cpp2/eden_types.h"
#include "eden/fs/utils/PathFuncs.h"
namespace folly {
template <typename T>
class Future;
}
namespace facebook::eden {
class ObjectId;
class Hash20;
using Hash = Hash20;
class ObjectStore;
class Tree;
class DiffContext;
class GitIgnoreStack;
class RootId;
/**
* Compute the diff between two commits.
*
* The caller is responsible for ensuring that the ObjectStore remains valid
* until the returned Future completes.
*
* The differences will be returned to the caller.
*/
folly::Future<std::unique_ptr<ScmStatus>> diffCommitsForStatus(
const ObjectStore* store,
const RootId& root1,
const RootId& root2);
/**
* Compute the diff between a source control Tree and the current directory
* state. This function is called with the hashes of a source control tree
* entry and an unmaterialized inode entry.
*
* The path argument specifies the path to these trees, and will be prefixed
* to all differences recorded in the results.
*
* The caller is responsible for ensuring that the context remains valid
* until the returned Future completes.
*
* The differences will be recorded using the callback inside the passed
* DiffContext.
*/
folly::Future<folly::Unit> diffTrees(
DiffContext* context,
RelativePathPiece currentPath,
ObjectId scmHash,
ObjectId wdHash,
const GitIgnoreStack* parentIgnore,
bool isIgnored);
/**
* Process an added tree (present locally but not present in the source control
* tree). This function is called with the hash of an unmaterialized inode
* entry. This whole subtree is marked as added using the DiffContext.
*
* The path argument specifies the path to these trees, and will be prefixed
* to all differences recorded in the results.
*
* The caller is responsible for ensuring that the context remains valid
* until the returned Future completes.
*
* The differences will be recorded using the callback inside the passed
* DiffContext.
*/
folly::Future<folly::Unit> diffAddedTree(
DiffContext* context,
RelativePathPiece currentPath,
ObjectId wdHash,
const GitIgnoreStack* ignore,
bool isIgnored);
/**
* Process a removed tree (not present locally but present in the source control
* tree). This function is called with the hash of the source control tree
* entry. This whole subtree is marked as removed using the DiffContext.
*
* The path argument specifies the path to these trees, and will be prefixed
* to all differences recorded in the results.
*
* The caller is responsible for ensuring that the context remains valid
* until the returned Future completes.
*
* The differences will be recorded using the callback inside the passed
* DiffContext.
*/
folly::Future<folly::Unit> diffRemovedTree(
DiffContext* context,
RelativePathPiece currentPath,
ObjectId scmHash);
} // namespace facebook::eden