mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
eb1a2b671c
Summary: Make sure we use pointers to const GitIgnoreStack objects when possible. Also change the code to store the root GitIgnoreStack object for a diff() operation in the DiffContext object, instead of having EdenMount::diff() allocate it separately on the heap. This will make it easier to consolidate a bit more logic in the DiffContext class in the future. In particular, I suspect we will want a version of diff() that only works on one portion of the tree. Putting more of the functionality in DiffContext will make it slightly easier to share code between the full-mount diff and the subtree diff functions. This also happens to save a memory allocation for now. Reviewed By: wez Differential Revision: D4968833 fbshipit-source-id: 1dc33b3d44cdf00e93b22d810c3a736d27c13638
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2004-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include "eden/fs/model/git/GitIgnoreStack.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
class InodeDiffCallback;
|
|
class ObjectStore;
|
|
|
|
/**
|
|
* A small helper class to store parameters for a TreeInode::diff() operation.
|
|
*
|
|
* These are parameters that remain fixed across all subdirectories being
|
|
* diffed. This class is mostly just for convenience so that we do not have to
|
|
* pass these items in individually as separate parameters to each function
|
|
* being called.
|
|
*/
|
|
class DiffContext {
|
|
public:
|
|
DiffContext(InodeDiffCallback* cb, bool listIgn, ObjectStore* os)
|
|
: callback{cb}, store{os}, listIgnored{listIgn} {
|
|
// TODO: Load the system-wide ignore settings and user-specific
|
|
// ignore settings into rootIgnore_.
|
|
}
|
|
|
|
const GitIgnoreStack* getToplevelIgnore() const {
|
|
return &rootIgnore_;
|
|
}
|
|
|
|
InodeDiffCallback* const callback;
|
|
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;
|
|
|
|
private:
|
|
GitIgnoreStack rootIgnore_{nullptr};
|
|
};
|
|
}
|
|
}
|