mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
6cced7c449
Summary: This is an initial pass at implementing "hg status" using the new EdenMount and TreeInode diff() code. More work still needs to be done to clean things up here, but this makes "hg status" more correct in the face of modified files and directories that are not modified, and vice-versa. In particular, the following still needs to be cleaned up in future diffs: - Update the "hg status" code to more correctly process user directives for paths that did not appear in the diff output. This will probably be simplified some by correctly updating the user directive list on checkout and resetCommit() operations. It may also make things simpler if we store the user directives in a hierarchical path map, rather than in a flat list. - Update the addAll() code to also use the new diff logic, rather than the getStatusForExistingDirectory() function. - Clean up the locking some. I think it may be worth changing the code to use a single lock to manage both the current commit ID for the mount and the dirstate user directives. We probably should hold this lock for the duration of a diff operation. The diff operation should also return the commit ID that it is based against. Reviewed By: wez Differential Revision: D4752281 fbshipit-source-id: 6a6d7e2815321b09c75e95aa7460b0da41931dc0
60 lines
1.5 KiB
C++
60 lines
1.5 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.
|
|
*
|
|
*/
|
|
#include "eden/fs/service/PrettyPrinters.h"
|
|
|
|
#include <ostream>
|
|
|
|
namespace {
|
|
template <typename ThriftEnum>
|
|
std::ostream& outputThriftEnum(
|
|
std::ostream& os,
|
|
ThriftEnum value,
|
|
const std::map<ThriftEnum, const char*>& valuesToNames,
|
|
folly::StringPiece typeName) {
|
|
auto iter = valuesToNames.find(value);
|
|
if (iter == valuesToNames.end()) {
|
|
os << typeName << "::" << int(value);
|
|
} else {
|
|
os << iter->second;
|
|
}
|
|
return os;
|
|
}
|
|
} // unnamed namespace
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
/**
|
|
* Pretty-print a CheckoutConflict
|
|
*/
|
|
std::ostream& operator<<(std::ostream& os, ConflictType conflictType) {
|
|
return outputThriftEnum(
|
|
os, conflictType, _ConflictType_VALUES_TO_NAMES, "ConflictType");
|
|
}
|
|
|
|
/**
|
|
* Pretty-print a CheckoutConflict
|
|
*/
|
|
std::ostream& operator<<(std::ostream& os, const CheckoutConflict& conflict) {
|
|
os << "CheckoutConflict(type=" << conflict.type << ", path=\""
|
|
<< conflict.path << "\", message=\"" << conflict.message << "\")";
|
|
return os;
|
|
}
|
|
|
|
/**
|
|
* Pretty-print a StatusCode
|
|
*/
|
|
std::ostream& operator<<(std::ostream& os, StatusCode statusCode) {
|
|
return outputThriftEnum(
|
|
os, statusCode, _StatusCode_VALUES_TO_NAMES, "StatusCode");
|
|
}
|
|
}
|
|
}
|