Show More
@@ -0,0 +1,120 b'' | |||||
|
1 | #require rhg | |||
|
2 | ||||
|
3 | $ NO_FALLBACK="env RHG_ON_UNSUPPORTED=abort" | |||
|
4 | ||||
|
5 | Rhg works well when sparse working copy is enabled. | |||
|
6 | ||||
|
7 | $ cd "$TESTTMP" | |||
|
8 | $ hg init repo-sparse | |||
|
9 | $ cd repo-sparse | |||
|
10 | $ cat > .hg/hgrc <<EOF | |||
|
11 | > [extensions] | |||
|
12 | > sparse= | |||
|
13 | > EOF | |||
|
14 | ||||
|
15 | $ echo a > show | |||
|
16 | $ echo x > hide | |||
|
17 | $ mkdir dir1 dir2 | |||
|
18 | $ echo x > dir1/x | |||
|
19 | $ echo y > dir1/y | |||
|
20 | $ echo z > dir2/z | |||
|
21 | ||||
|
22 | $ hg ci -Aqm 'initial' | |||
|
23 | $ hg debugsparse --include 'show' | |||
|
24 | $ ls -A | |||
|
25 | .hg | |||
|
26 | show | |||
|
27 | ||||
|
28 | $ tip=$(hg log -r . --template '{node}') | |||
|
29 | $ $NO_FALLBACK rhg files -r "$tip" | |||
|
30 | dir1/x | |||
|
31 | dir1/y | |||
|
32 | dir2/z | |||
|
33 | hide | |||
|
34 | show | |||
|
35 | $ $NO_FALLBACK rhg files | |||
|
36 | show | |||
|
37 | ||||
|
38 | $ $NO_FALLBACK rhg cat -r "$tip" hide | |||
|
39 | x | |||
|
40 | ||||
|
41 | $ cd .. | |||
|
42 | ||||
|
43 | We support most things when narrow is enabled, too, with a couple of caveats. | |||
|
44 | ||||
|
45 | $ . "$TESTDIR/narrow-library.sh" | |||
|
46 | $ real_hg=$RHG_FALLBACK_EXECUTABLE | |||
|
47 | ||||
|
48 | $ cat >> $HGRCPATH <<EOF | |||
|
49 | > [extensions] | |||
|
50 | > narrow= | |||
|
51 | > EOF | |||
|
52 | ||||
|
53 | $ hg clone --narrow ./repo-sparse repo-narrow --include dir1 | |||
|
54 | requesting all changes | |||
|
55 | adding changesets | |||
|
56 | adding manifests | |||
|
57 | adding file changes | |||
|
58 | added 1 changesets with 2 changes to 2 files | |||
|
59 | new changesets 6d714a4a2998 | |||
|
60 | updating to branch default | |||
|
61 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
62 | ||||
|
63 | $ cd repo-narrow | |||
|
64 | ||||
|
65 | $ $NO_FALLBACK rhg cat -r "$tip" dir1/x | |||
|
66 | x | |||
|
67 | $ "$real_hg" cat -r "$tip" dir1/x | |||
|
68 | x | |||
|
69 | ||||
|
70 | TODO: bad error message | |||
|
71 | ||||
|
72 | $ $NO_FALLBACK rhg cat -r "$tip" hide | |||
|
73 | abort: invalid revision identifier: 6d714a4a2998cbfd0620db44da58b749f6565d63 | |||
|
74 | [255] | |||
|
75 | $ "$real_hg" cat -r "$tip" hide | |||
|
76 | [1] | |||
|
77 | ||||
|
78 | A naive implementation of [rhg files] leaks the paths that are supposed to be | |||
|
79 | hidden by narrow, so we just fall back to hg. | |||
|
80 | ||||
|
81 | $ $NO_FALLBACK rhg files -r "$tip" | |||
|
82 | unsupported feature: rhg files -r <rev> is not supported in narrow clones | |||
|
83 | [252] | |||
|
84 | $ "$real_hg" files -r "$tip" | |||
|
85 | dir1/x | |||
|
86 | dir1/y | |||
|
87 | ||||
|
88 | Hg status needs to do some filtering based on narrow spec, so we don't | |||
|
89 | support it in rhg for narrow clones yet. | |||
|
90 | ||||
|
91 | $ mkdir dir2 | |||
|
92 | $ touch dir2/q | |||
|
93 | $ "$real_hg" status | |||
|
94 | $ $NO_FALLBACK rhg --config rhg.status=true status | |||
|
95 | unsupported feature: rhg status is not supported for sparse checkouts or narrow clones yet | |||
|
96 | [252] | |||
|
97 | ||||
|
98 | Adding "orphaned" index files: | |||
|
99 | ||||
|
100 | $ (cd ..; cp repo-sparse/.hg/store/data/hide.i repo-narrow/.hg/store/data/hide.i) | |||
|
101 | $ (cd ..; mkdir repo-narrow/.hg/store/data/dir2; cp repo-sparse/.hg/store/data/dir2/z.i repo-narrow/.hg/store/data/dir2/z.i) | |||
|
102 | $ "$real_hg" verify | |||
|
103 | checking changesets | |||
|
104 | checking manifests | |||
|
105 | crosschecking files in changesets and manifests | |||
|
106 | checking files | |||
|
107 | checked 1 changesets with 2 changes to 2 files | |||
|
108 | ||||
|
109 | $ "$real_hg" files -r "$tip" | |||
|
110 | dir1/x | |||
|
111 | dir1/y | |||
|
112 | ||||
|
113 | # TODO: even though [hg files] hides the orphaned dir2/z, [hg cat] still shows it. | |||
|
114 | # rhg has the same issue, but at least it's not specific to rhg. | |||
|
115 | # This is despite [hg verify] succeeding above. | |||
|
116 | ||||
|
117 | $ $NO_FALLBACK rhg cat -r "$tip" dir2/z | |||
|
118 | z | |||
|
119 | $ "$real_hg" cat -r "$tip" dir2/z | |||
|
120 | z |
@@ -248,6 +248,14 b' impl Repo {' | |||||
248 | .contains(requirements::DIRSTATE_V2_REQUIREMENT) |
|
248 | .contains(requirements::DIRSTATE_V2_REQUIREMENT) | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
|
251 | pub fn has_sparse(&self) -> bool { | |||
|
252 | self.requirements.contains(requirements::SPARSE_REQUIREMENT) | |||
|
253 | } | |||
|
254 | ||||
|
255 | pub fn has_narrow(&self) -> bool { | |||
|
256 | self.requirements.contains(requirements::NARROW_REQUIREMENT) | |||
|
257 | } | |||
|
258 | ||||
251 | fn dirstate_file_contents(&self) -> Result<Vec<u8>, HgError> { |
|
259 | fn dirstate_file_contents(&self) -> Result<Vec<u8>, HgError> { | |
252 | Ok(self |
|
260 | Ok(self | |
253 | .hg_vfs() |
|
261 | .hg_vfs() |
@@ -88,6 +88,10 b' const SUPPORTED: &[&str] = &[' | |||||
88 | // When it starts writing to the repository, it’ll need to either keep the |
|
88 | // When it starts writing to the repository, it’ll need to either keep the | |
89 | // persistent nodemap up to date or remove this entry: |
|
89 | // persistent nodemap up to date or remove this entry: | |
90 | NODEMAP_REQUIREMENT, |
|
90 | NODEMAP_REQUIREMENT, | |
|
91 | // Not all commands support `sparse` and `narrow`. The commands that do | |||
|
92 | // not should opt out by checking `has_sparse` and `has_narrow`. | |||
|
93 | SPARSE_REQUIREMENT, | |||
|
94 | NARROW_REQUIREMENT, | |||
91 | ]; |
|
95 | ]; | |
92 |
|
96 | |||
93 | // Copied from mercurial/requirements.py: |
|
97 | // Copied from mercurial/requirements.py: |
@@ -40,10 +40,38 b' pub fn run(invocation: &crate::CliInvoca' | |||||
40 | let rev = invocation.subcommand_args.value_of("rev"); |
|
40 | let rev = invocation.subcommand_args.value_of("rev"); | |
41 |
|
41 | |||
42 | let repo = invocation.repo?; |
|
42 | let repo = invocation.repo?; | |
|
43 | ||||
|
44 | // It seems better if this check is removed: this would correspond to | |||
|
45 | // automatically enabling the extension if the repo requires it. | |||
|
46 | // However we need this check to be in sync with vanilla hg so hg tests | |||
|
47 | // pass. | |||
|
48 | if repo.has_sparse() | |||
|
49 | && invocation.config.get(b"extensions", b"sparse").is_none() | |||
|
50 | { | |||
|
51 | return Err(CommandError::unsupported( | |||
|
52 | "repo is using sparse, but sparse extension is not enabled", | |||
|
53 | )); | |||
|
54 | } | |||
|
55 | ||||
43 | if let Some(rev) = rev { |
|
56 | if let Some(rev) = rev { | |
|
57 | if repo.has_narrow() { | |||
|
58 | return Err(CommandError::unsupported( | |||
|
59 | "rhg files -r <rev> is not supported in narrow clones", | |||
|
60 | )); | |||
|
61 | } | |||
44 | let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?; |
|
62 | let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?; | |
45 | display_files(invocation.ui, repo, files.iter()) |
|
63 | display_files(invocation.ui, repo, files.iter()) | |
46 | } else { |
|
64 | } else { | |
|
65 | // The dirstate always reflects the sparse narrowspec, so if | |||
|
66 | // we only have sparse without narrow all is fine. | |||
|
67 | // If we have narrow, then [hg files] needs to check if | |||
|
68 | // the store narrowspec is in sync with the one of the dirstate, | |||
|
69 | // so we can't support that without explicit code. | |||
|
70 | if repo.has_narrow() { | |||
|
71 | return Err(CommandError::unsupported( | |||
|
72 | "rhg files is not supported in narrow clones", | |||
|
73 | )); | |||
|
74 | } | |||
47 | let distate = Dirstate::new(repo)?; |
|
75 | let distate = Dirstate::new(repo)?; | |
48 | let files = distate.tracked_files()?; |
|
76 | let files = distate.tracked_files()?; | |
49 | display_files(invocation.ui, repo, files.into_iter().map(Ok)) |
|
77 | display_files(invocation.ui, repo, files.into_iter().map(Ok)) |
@@ -191,6 +191,13 b' pub fn run(invocation: &crate::CliInvoca' | |||||
191 | let no_status = args.is_present("no-status"); |
|
191 | let no_status = args.is_present("no-status"); | |
192 |
|
192 | |||
193 | let repo = invocation.repo?; |
|
193 | let repo = invocation.repo?; | |
|
194 | ||||
|
195 | if repo.has_sparse() || repo.has_narrow() { | |||
|
196 | return Err(CommandError::unsupported( | |||
|
197 | "rhg status is not supported for sparse checkouts or narrow clones yet" | |||
|
198 | )); | |||
|
199 | } | |||
|
200 | ||||
194 | let mut dmap = repo.dirstate_map_mut()?; |
|
201 | let mut dmap = repo.dirstate_map_mut()?; | |
195 |
|
202 | |||
196 | let options = StatusOptions { |
|
203 | let options = StatusOptions { |
@@ -593,7 +593,8 b' impl OnUnsupported {' | |||||
593 | } |
|
593 | } | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 |
const SUPPORTED_EXTENSIONS: &[&[u8]] = |
|
596 | const SUPPORTED_EXTENSIONS: &[&[u8]] = | |
|
597 | &[b"blackbox", b"share", b"sparse", b"narrow"]; | |||
597 |
|
598 | |||
598 | fn check_extensions(config: &Config) -> Result<(), CommandError> { |
|
599 | fn check_extensions(config: &Config) -> Result<(), CommandError> { | |
599 | let enabled = config.get_section_keys(b"extensions"); |
|
600 | let enabled = config.get_section_keys(b"extensions"); |
General Comments 0
You need to be logged in to leave comments.
Login now