2017-03-24 23:42:39 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-03-24 23:42:39 +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-24 23:42:39 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2017-03-24 23:42:39 +03:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-08 23:36:37 +03:00
|
|
|
#include <folly/Range.h>
|
2019-12-09 22:30:47 +03:00
|
|
|
#include <folly/futures/Future.h>
|
|
|
|
|
2020-02-06 03:01:36 +03:00
|
|
|
#include "eden/fs/store/StatsFetchContext.h"
|
2019-12-09 22:30:47 +03:00
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
|
|
|
|
|
|
|
namespace folly {
|
|
|
|
template <typename T>
|
|
|
|
class Future;
|
|
|
|
} // namespace folly
|
2017-04-29 05:14:25 +03:00
|
|
|
|
2019-10-01 19:42:10 +03:00
|
|
|
namespace apache {
|
|
|
|
namespace thrift {
|
|
|
|
class ResponseChannelRequest;
|
|
|
|
}
|
|
|
|
} // namespace apache
|
|
|
|
|
2017-03-24 23:42:39 +03:00
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
2019-09-24 01:19:29 +03:00
|
|
|
class DiffCallback;
|
2018-07-20 03:14:12 +03:00
|
|
|
class GitIgnoreStack;
|
2020-02-06 00:13:11 +03:00
|
|
|
class ObjectFetchContext;
|
2017-04-29 05:14:25 +03:00
|
|
|
class ObjectStore;
|
2018-02-09 06:31:56 +03:00
|
|
|
class UserInfo;
|
2018-07-20 03:14:12 +03:00
|
|
|
class TopLevelIgnores;
|
2019-12-09 22:30:47 +03:00
|
|
|
class EdenMount;
|
2017-04-29 05:14:25 +03:00
|
|
|
|
2017-03-24 23:42:39 +03:00
|
|
|
/**
|
2018-07-20 03:14:12 +03:00
|
|
|
* A helper class to store parameters for a TreeInode::diff() operation.
|
2017-03-24 23:42:39 +03:00
|
|
|
*
|
2018-07-20 03:14:12 +03:00
|
|
|
* These parameters remain fixed across all subdirectories being diffed.
|
|
|
|
* Primarily intent is to compound related diff attributes.
|
2019-10-11 20:42:16 +03:00
|
|
|
*
|
|
|
|
* The DiffContext must be alive for the duration of the async operation it is
|
|
|
|
* used in.
|
2017-03-24 23:42:39 +03:00
|
|
|
*/
|
|
|
|
class DiffContext {
|
|
|
|
public:
|
2020-02-06 00:13:11 +03:00
|
|
|
using LoadFileFunction = std::function<
|
|
|
|
folly::Future<std::string>(ObjectFetchContext&, RelativePathPiece)>;
|
|
|
|
|
2018-02-09 06:31:56 +03:00
|
|
|
DiffContext(
|
2019-09-24 01:19:29 +03:00
|
|
|
DiffCallback* cb,
|
2018-02-09 06:31:56 +03:00
|
|
|
bool listIgnored,
|
|
|
|
const ObjectStore* os,
|
2019-10-01 19:42:10 +03:00
|
|
|
std::unique_ptr<TopLevelIgnores> topLevelIgnores,
|
2020-02-06 00:13:11 +03:00
|
|
|
LoadFileFunction loadFileContentsFromPath,
|
2019-10-01 19:42:10 +03:00
|
|
|
apache::thrift::ResponseChannelRequest* FOLLY_NULLABLE request = nullptr);
|
2019-10-11 20:42:16 +03:00
|
|
|
DiffContext(DiffCallback* cb, const ObjectStore* os);
|
2017-12-08 23:36:37 +03:00
|
|
|
|
2018-07-20 03:14:12 +03:00
|
|
|
DiffContext(const DiffContext&) = delete;
|
|
|
|
DiffContext& operator=(const DiffContext&) = delete;
|
|
|
|
DiffContext(DiffContext&&) = delete;
|
|
|
|
DiffContext& operator=(DiffContext&&) = delete;
|
|
|
|
~DiffContext();
|
2017-03-24 23:42:39 +03:00
|
|
|
|
2019-09-24 01:19:29 +03:00
|
|
|
DiffCallback* const callback;
|
2017-12-08 23:36:37 +03:00
|
|
|
const ObjectStore* const store;
|
2017-03-24 23:42:39 +03:00
|
|
|
/**
|
|
|
|
* 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;
|
2017-04-29 05:14:25 +03:00
|
|
|
|
2018-07-20 03:14:12 +03:00
|
|
|
const GitIgnoreStack* getToplevelIgnore() const;
|
2019-10-01 19:42:10 +03:00
|
|
|
bool isCancelled() const;
|
2020-02-06 00:13:11 +03:00
|
|
|
LoadFileFunction getLoadFileContentsFromPath() const;
|
2020-02-06 03:01:36 +03:00
|
|
|
StatsFetchContext& getFetchContext() {
|
2020-02-06 00:13:11 +03:00
|
|
|
return fetchContext_;
|
|
|
|
}
|
2017-12-08 23:36:37 +03:00
|
|
|
|
2018-07-20 03:14:12 +03:00
|
|
|
private:
|
|
|
|
std::unique_ptr<TopLevelIgnores> topLevelIgnores_;
|
2020-02-06 00:13:11 +03:00
|
|
|
const LoadFileFunction loadFileContentsFromPath_;
|
2019-10-01 19:42:10 +03:00
|
|
|
apache::thrift::ResponseChannelRequest* const FOLLY_NULLABLE request_;
|
2020-02-06 03:01:36 +03:00
|
|
|
StatsFetchContext fetchContext_;
|
2017-03-24 23:42:39 +03:00
|
|
|
};
|
2017-11-04 01:58:04 +03:00
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|