2017-03-21 21:53:15 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-03-21 21:53:15 +03:00
|
|
|
*
|
2019-06-20 02:58:25 +03:00
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
2017-03-21 21:53:15 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2017-03-21 21:53:15 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include "eden/fs/inodes/InodePtrFwd.h"
|
2017-04-14 21:31:48 +03:00
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
namespace folly {
|
|
|
|
template <typename T>
|
|
|
|
class Future;
|
2018-06-01 20:55:42 +03:00
|
|
|
struct Unit;
|
2017-11-04 01:58:04 +03:00
|
|
|
} // namespace folly
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
2017-03-24 23:42:39 +03:00
|
|
|
class DiffContext;
|
|
|
|
class GitIgnoreStack;
|
2017-03-21 21:53:15 +03:00
|
|
|
class Hash;
|
|
|
|
class ObjectStore;
|
|
|
|
class TreeEntry;
|
|
|
|
class TreeInode;
|
2019-09-24 01:19:29 +03:00
|
|
|
class DiffCallback;
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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:
|
2020-02-06 00:13:11 +03:00
|
|
|
explicit DeferredDiffEntry(DiffContext* context, RelativePath&& path)
|
2017-03-24 23:42:39 +03:00
|
|
|
: context_{context}, path_{std::move(path)} {}
|
2017-03-21 21:53:15 +03:00
|
|
|
virtual ~DeferredDiffEntry() {}
|
|
|
|
|
|
|
|
const RelativePath& getPath() const {
|
|
|
|
return path_;
|
|
|
|
}
|
|
|
|
|
2018-04-27 06:41:40 +03:00
|
|
|
FOLLY_NODISCARD virtual folly::Future<folly::Unit> run() = 0;
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
static std::unique_ptr<DeferredDiffEntry> createUntrackedEntry(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2017-03-21 21:53:15 +03:00
|
|
|
RelativePath path,
|
|
|
|
InodePtr inode,
|
2017-04-29 05:14:25 +03:00
|
|
|
const GitIgnoreStack* ignore,
|
2017-03-24 23:42:39 +03:00
|
|
|
bool isIgnored);
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is named differently from the createUntrackedEntry() function above
|
|
|
|
* just to avoid ambiguous overload calls--folly::Future<X> can unfortunately
|
|
|
|
* be implicitly constructed from X. We could help the compiler avoid the
|
|
|
|
* ambiguity by making the Future<InodePtr> version of createUntrackedEntry()
|
|
|
|
* be a template method. However, just using a separate name is easier for
|
|
|
|
* now.
|
|
|
|
*/
|
|
|
|
static std::unique_ptr<DeferredDiffEntry> createUntrackedEntryFromInodeFuture(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2017-03-21 21:53:15 +03:00
|
|
|
RelativePath path,
|
|
|
|
folly::Future<InodePtr>&& inodeFuture,
|
2017-04-29 05:14:25 +03:00
|
|
|
const GitIgnoreStack* ignore,
|
2017-03-24 23:42:39 +03:00
|
|
|
bool isIgnored);
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
static std::unique_ptr<DeferredDiffEntry> createRemovedEntry(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2017-03-21 21:53:15 +03:00
|
|
|
RelativePath path,
|
|
|
|
const TreeEntry& scmEntry);
|
|
|
|
|
|
|
|
static std::unique_ptr<DeferredDiffEntry> createModifiedEntry(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2017-03-21 21:53:15 +03:00
|
|
|
RelativePath path,
|
|
|
|
const TreeEntry& scmEntry,
|
|
|
|
InodePtr inode,
|
2017-04-29 05:14:25 +03:00
|
|
|
const GitIgnoreStack* ignore,
|
2017-03-24 23:42:39 +03:00
|
|
|
bool isIgnored);
|
2017-03-21 21:53:15 +03:00
|
|
|
|
2017-03-24 23:42:39 +03:00
|
|
|
static std::unique_ptr<DeferredDiffEntry> createModifiedEntryFromInodeFuture(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2017-03-21 21:53:15 +03:00
|
|
|
RelativePath path,
|
|
|
|
const TreeEntry& scmEntry,
|
|
|
|
folly::Future<InodePtr>&& inodeFuture,
|
2017-04-29 05:14:25 +03:00
|
|
|
const GitIgnoreStack* ignore,
|
2017-03-24 23:42:39 +03:00
|
|
|
bool isIgnored);
|
2017-03-21 21:53:15 +03:00
|
|
|
|
|
|
|
static std::unique_ptr<DeferredDiffEntry> createModifiedEntry(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2017-03-21 21:53:15 +03:00
|
|
|
RelativePath path,
|
|
|
|
const TreeEntry& scmEntry,
|
|
|
|
Hash currentBlobHash);
|
|
|
|
|
2020-01-29 22:15:29 +03:00
|
|
|
static std::unique_ptr<DeferredDiffEntry> createModifiedScmEntry(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2020-01-29 22:15:29 +03:00
|
|
|
RelativePath path,
|
|
|
|
Hash scmHash,
|
|
|
|
Hash wdHash,
|
|
|
|
const GitIgnoreStack* ignore,
|
|
|
|
bool isIgnored);
|
|
|
|
|
2020-01-29 22:15:29 +03:00
|
|
|
static std::unique_ptr<DeferredDiffEntry> createAddedScmEntry(
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* context,
|
2020-01-29 22:15:29 +03:00
|
|
|
RelativePath path,
|
|
|
|
Hash wdHash,
|
|
|
|
const GitIgnoreStack* ignore,
|
|
|
|
bool isIgnored);
|
|
|
|
|
2020-02-06 00:13:11 +03:00
|
|
|
static std::unique_ptr<DeferredDiffEntry>
|
|
|
|
createRemovedScmEntry(DiffContext* context, RelativePath path, Hash scmHash);
|
2020-01-29 22:15:29 +03:00
|
|
|
|
2017-03-24 23:42:39 +03:00
|
|
|
protected:
|
2020-02-06 00:13:11 +03:00
|
|
|
DiffContext* const context_;
|
2017-03-24 23:42:39 +03:00
|
|
|
RelativePath const path_;
|
2017-03-21 21:53:15 +03:00
|
|
|
};
|
2017-11-04 01:58:04 +03:00
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|