/* * 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 #include "eden/fs/inodes/InodePtrFwd.h" #include "eden/fs/utils/PathFuncs.h" namespace folly { template class Future; struct Unit; } // namespace folly namespace facebook { namespace eden { class DiffContext; class GitIgnoreStack; class Hash; class ObjectStore; class TreeEntry; class TreeInode; class DiffCallback; /** * A helper class for use in TreeInode::diff() * * While diff() holds the contents_ lock it computes a set of child entries * that need to be examined later once it releases the contents_ lock. * DeferredDiffEntry is used to store the data about which children need to be * examined. The DeferredDiffEntry subclasses contain the logic for how to * then perform the diff on the child entry. */ class DeferredDiffEntry { public: explicit DeferredDiffEntry(const DiffContext* context, RelativePath&& path) : context_{context}, path_{std::move(path)} {} virtual ~DeferredDiffEntry() {} const RelativePath& getPath() const { return path_; } FOLLY_NODISCARD virtual folly::Future run() = 0; static std::unique_ptr createUntrackedEntry( const DiffContext* context, RelativePath path, InodePtr inode, const GitIgnoreStack* ignore, bool isIgnored); /* * This is named differently from the createUntrackedEntry() function above * just to avoid ambiguous overload calls--folly::Future can unfortunately * be implicitly constructed from X. We could help the compiler avoid the * ambiguity by making the Future version of createUntrackedEntry() * be a template method. However, just using a separate name is easier for * now. */ static std::unique_ptr createUntrackedEntryFromInodeFuture( const DiffContext* context, RelativePath path, folly::Future&& inodeFuture, const GitIgnoreStack* ignore, bool isIgnored); static std::unique_ptr createRemovedEntry( const DiffContext* context, RelativePath path, const TreeEntry& scmEntry); static std::unique_ptr createModifiedEntry( const DiffContext* context, RelativePath path, const TreeEntry& scmEntry, InodePtr inode, const GitIgnoreStack* ignore, bool isIgnored); static std::unique_ptr createModifiedEntryFromInodeFuture( const DiffContext* context, RelativePath path, const TreeEntry& scmEntry, folly::Future&& inodeFuture, const GitIgnoreStack* ignore, bool isIgnored); static std::unique_ptr createModifiedEntry( const DiffContext* context, RelativePath path, const TreeEntry& scmEntry, Hash currentBlobHash); static std::unique_ptr createModifiedScmEntry( const DiffContext* context, RelativePath path, Hash scmHash, Hash wdHash, const GitIgnoreStack* ignore, bool isIgnored); static std::unique_ptr createAddedScmEntry( const DiffContext* context, RelativePath path, Hash wdHash, const GitIgnoreStack* ignore, bool isIgnored); protected: const DiffContext* const context_; RelativePath const path_; }; } // namespace eden } // namespace facebook