forked from mirrors/jj
repo_path: make to_internal_file_string() return &str, rename accordingly
This commit is contained in:
parent
12d7f8be16
commit
55f75278bc
5 changed files with 12 additions and 12 deletions
|
@ -215,7 +215,7 @@ impl LockedWorkingCopy for LockedConflictsWorkingCopy {
|
|||
let conflicts = commit
|
||||
.tree()?
|
||||
.conflicts()
|
||||
.map(|(path, _value)| format!("{}\n", path.to_internal_file_string()))
|
||||
.map(|(path, _value)| format!("{}\n", path.as_internal_file_string()))
|
||||
.join("");
|
||||
std::fs::write(self.wc_path.join(".conflicts"), conflicts).unwrap();
|
||||
self.inner.check_out(commit)
|
||||
|
|
|
@ -686,7 +686,7 @@ pub fn show_git_diff(
|
|||
formatter.push_label("diff")?;
|
||||
async {
|
||||
while let Some((path, diff)) = tree_diff.next().await {
|
||||
let path_string = path.to_internal_file_string();
|
||||
let path_string = path.as_internal_file_string();
|
||||
let (left_value, right_value) = diff?;
|
||||
let left_value = materialize_tree_value(store, &path, left_value).block_on()?;
|
||||
let right_value = materialize_tree_value(store, &path, right_value).block_on()?;
|
||||
|
|
|
@ -265,7 +265,7 @@ fn file_states_to_proto(
|
|||
.iter()
|
||||
.map(
|
||||
|(path, state)| crate::protos::working_copy::FileStateEntry {
|
||||
path: path.to_internal_file_string(),
|
||||
path: path.as_internal_file_string().to_owned(),
|
||||
state: Some(file_state_to_proto(state)),
|
||||
},
|
||||
)
|
||||
|
@ -538,7 +538,7 @@ impl TreeState {
|
|||
for path in &self.sparse_patterns {
|
||||
sparse_patterns
|
||||
.prefixes
|
||||
.push(path.to_internal_file_string());
|
||||
.push(path.as_internal_file_string().to_owned());
|
||||
}
|
||||
proto.sparse_patterns = Some(sparse_patterns);
|
||||
proto.watchman_clock = self.watchman_clock.clone();
|
||||
|
@ -862,7 +862,7 @@ impl TreeState {
|
|||
}
|
||||
let maybe_current_file_state = file_states.get(&path);
|
||||
if maybe_current_file_state.is_none()
|
||||
&& git_ignore.matches(&path.to_internal_file_string())
|
||||
&& git_ignore.matches(path.as_internal_file_string())
|
||||
{
|
||||
// If it wasn't already tracked and it matches
|
||||
// the ignored paths, then
|
||||
|
|
|
@ -246,8 +246,8 @@ impl RepoPath {
|
|||
|
||||
/// The full string form used internally, not for presenting to users (where
|
||||
/// we may want to use the platform's separator).
|
||||
pub fn to_internal_file_string(&self) -> String {
|
||||
self.value.to_owned()
|
||||
pub fn as_internal_file_string(&self) -> &str {
|
||||
&self.value
|
||||
}
|
||||
|
||||
pub fn to_fs_path(&self, base: &Path) -> PathBuf {
|
||||
|
@ -362,10 +362,10 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_to_internal_string() {
|
||||
assert_eq!(RepoPath::root().to_internal_file_string(), "");
|
||||
assert_eq!(repo_path("dir").to_internal_file_string(), "dir");
|
||||
assert_eq!(repo_path("dir/file").to_internal_file_string(), "dir/file");
|
||||
fn test_as_internal_file_string() {
|
||||
assert_eq!(RepoPath::root().as_internal_file_string(), "");
|
||||
assert_eq!(repo_path("dir").as_internal_file_string(), "dir");
|
||||
assert_eq!(repo_path("dir/file").as_internal_file_string(), "dir/file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -204,7 +204,7 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) {
|
|||
assert_eq!(new_tree.id(), right_tree_id);
|
||||
|
||||
for (_left_kind, right_kind, path) in &files {
|
||||
let wc_path = workspace_root.join(path.to_internal_file_string());
|
||||
let wc_path = workspace_root.join(path.as_internal_file_string());
|
||||
let maybe_metadata = wc_path.symlink_metadata();
|
||||
match right_kind {
|
||||
Kind::Missing => {
|
||||
|
|
Loading…
Reference in a new issue