Skip to content

Commit 65bde93

Browse files
taidaiimeta-codesync[bot]
authored andcommitted
grepo: set PathTranslator trait for overlapping path resolution
Summary: Set optional `path_translator` field on `TreeManifest` to `GrepoPathTranslator` to handle overlapping paths. Reviewed By: quark-zju Differential Revision: D102906290 fbshipit-source-id: b2d669387d2a1bcee6ea06fc54cd33915353ce6b
1 parent 56f23d1 commit 65bde93

2 files changed

Lines changed: 24 additions & 31 deletions

File tree

eden/scm/lib/grepocompat/src/trees.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use types::HgId;
2121
use types::RepoPath;
2222
use types::RepoPathBuf;
2323

24-
/// Parse .repo manifest xml files and synthesizes repo projects as trees
24+
use crate::path::GrepoPathTranslator;
25+
26+
/// Parse .repo manifest xml files and synthesizes repo projects as trees.
2527
/// TODO: linkfile and copyfile support
2628
pub fn synthesize_grepo_projects(
2729
tree_store: &Arc<dyn TreeStore>,
@@ -39,6 +41,11 @@ pub fn synthesize_grepo_projects(
3941
let projects = parse_manifest(&xml_data)?.projects;
4042

4143
let mut new_manifest = TreeManifest::ephemeral(tree_store.clone());
44+
// Project paths are stored with suffix encoding so a path can be both
45+
// a file (GitSubmodule entry) and a directory (containing nested projects).
46+
// The returned manifest has a `PathTranslator` set so consumers see
47+
// decoded paths transparently.
48+
new_manifest.set_path_translator(Arc::new(GrepoPathTranslator));
4249

4350
for (path, project) in projects {
4451
if let Some(revision) = &project.revision {

eden/scm/tests/test-dotrepo.t

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -91,34 +91,27 @@ Sapling recognizes .repo identity
9191

9292
clean status
9393
$ sl status
94-
abort: synthesizing tree for root *: failure inserting 'vendor/a/sub/c' in manifest: 'vendor/a' is already a file (glob)
95-
[255]
9694

9795
$ sl log -r . -T "desc:\n {desc}\nfiles:\n{files % ' {file}\n'}"
98-
abort: synthesizing tree for root * (glob)
99-
100-
Caused by:
101-
0: failure inserting 'vendor/a/sub/c' in manifest
102-
1: 'vendor/a' is already a file
103-
[255]
96+
desc:
97+
add manifest
98+
files:
99+
frameworks/b
100+
vendor/a
101+
vendor/a/sub/c
104102

105103
modified outer project is reported by status
106104
$ cd vendor/a
107105
$ echo "project vendor/a" > README
108106
$ git add README && git commit -qm 'add README'
109107
$ cd ../..
110108
$ sl status
111-
abort: synthesizing tree for root *: failure inserting 'vendor/a/sub/c' in manifest: 'vendor/a' is already a file (glob)
112-
[255]
109+
M vendor/a
113110

114111
Diff shows subproject commit change for the outer project:
115112

116-
$ sl diff
117-
abort: synthesizing tree for root * (glob)
118-
119-
Caused by:
120-
0: failure inserting 'vendor/a/sub/c' in manifest
121-
1: 'vendor/a' is already a file
113+
$ sl diff
114+
abort: Is a directory: $TESTTMP/repodir/vendor/a
122115
[255]
123116

124117
Modified nested (overlapping) project is reported by status:
@@ -128,17 +121,13 @@ Modified nested (overlapping) project is reported by status:
128121
$ git add README && git commit -qm 'modify c'
129122
$ cd ../../../..
130123
$ sl status
131-
abort: synthesizing tree for root *: failure inserting 'vendor/a/sub/c' in manifest: 'vendor/a' is already a file (glob)
132-
[255]
124+
M vendor/a
125+
M vendor/a/sub/c
133126

134127
Exact-path diff also works for the nested overlapping project:
135128

136129
$ sl diff vendor/a/sub/c
137-
abort: synthesizing tree for root * (glob)
138-
139-
Caused by:
140-
0: failure inserting 'vendor/a/sub/c' in manifest
141-
1: 'vendor/a' is already a file
130+
abort: Is a directory: $TESTTMP/repodir/vendor/a/sub/c
142131
[255]
143132

144133
Modified non-overlapping project is reported by status:
@@ -148,15 +137,12 @@ Modified non-overlapping project is reported by status:
148137
$ git add README && git commit -qm 'modify b'
149138
$ cd ../..
150139
$ sl status
151-
abort: synthesizing tree for root *: failure inserting 'vendor/a/sub/c' in manifest: 'vendor/a' is already a file (glob)
152-
[255]
140+
M frameworks/b
141+
M vendor/a
142+
M vendor/a/sub/c
153143

154144
Exact-path diff also works for the non-overlapping project:
155145

156146
$ sl diff frameworks/b
157-
abort: synthesizing tree for root * (glob)
158-
159-
Caused by:
160-
0: failure inserting 'vendor/a/sub/c' in manifest
161-
1: 'vendor/a' is already a file
147+
abort: Is a directory: $TESTTMP/repodir/frameworks/b
162148
[255]

0 commit comments

Comments
 (0)