sapling/eden/fs/store/DiffContext.h
Genevieve Helsel 0907d3adda save loadFileFromPath in DiffContext
Summary: Saves loadFileFromPath in the DiffContext. This allows the source control differ ( at `eden/fs/store/Diff.cpp`) to call this function while it is trying to load gitIgnores and resolve symlinks.

Reviewed By: simpkins

Differential Revision: D18647088

fbshipit-source-id: bddff0158130f0c96ac263bcce81dc51fc017800
2019-12-09 11:33:23 -08:00

86 lines
2.4 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 <folly/Range.h>
#include <folly/futures/Future.h>
#include "eden/fs/utils/PathFuncs.h"
namespace folly {
template <typename T>
class Future;
} // namespace folly
namespace apache {
namespace thrift {
class ResponseChannelRequest;
}
} // namespace apache
namespace facebook {
namespace eden {
class DiffCallback;
class GitIgnoreStack;
class ObjectStore;
class UserInfo;
class TopLevelIgnores;
class EdenMount;
/**
* A helper class to store parameters for a TreeInode::diff() operation.
*
* These parameters remain fixed across all subdirectories being diffed.
* Primarily intent is to compound related diff attributes.
*
* The DiffContext must be alive for the duration of the async operation it is
* used in.
*/
class DiffContext {
public:
DiffContext(
DiffCallback* cb,
bool listIgnored,
const ObjectStore* os,
std::unique_ptr<TopLevelIgnores> topLevelIgnores,
std::function<folly::Future<std::string>(RelativePathPiece)>
loadFileContentsFromPath,
apache::thrift::ResponseChannelRequest* FOLLY_NULLABLE request = nullptr);
DiffContext(DiffCallback* cb, const ObjectStore* os);
DiffContext(const DiffContext&) = delete;
DiffContext& operator=(const DiffContext&) = delete;
DiffContext(DiffContext&&) = delete;
DiffContext& operator=(DiffContext&&) = delete;
~DiffContext();
DiffCallback* const callback;
const ObjectStore* const store;
/**
* If listIgnored is true information about ignored files will be reported.
* If listIgnored is false then ignoredFile() will never be called on the
* callback. The diff operation may be faster with listIgnored=false, since
* it can completely omit processing ignored subdirectories.
*/
bool const listIgnored;
const GitIgnoreStack* getToplevelIgnore() const;
bool isCancelled() const;
const std::function<folly::Future<std::string>(RelativePathPiece)>&
getLoadFileContentsFromPath() const;
private:
std::unique_ptr<TopLevelIgnores> topLevelIgnores_;
const std::function<folly::Future<std::string>(RelativePathPiece)>
loadFileContentsFromPath_;
apache::thrift::ResponseChannelRequest* const FOLLY_NULLABLE request_;
};
} // namespace eden
} // namespace facebook