Show More
@@ -1,116 +1,78 | |||
|
1 | 1 | use crate::error::CommandError; |
|
2 | use crate::utils::path_utils::resolve_file_args; | |
|
2 | 3 | use clap::Arg; |
|
3 | 4 | use format_bytes::format_bytes; |
|
4 | 5 | use hg::operations::cat; |
|
5 | use hg::utils::hg_path::HgPathBuf; | |
|
6 | 6 | use std::ffi::OsString; |
|
7 | use std::os::unix::prelude::OsStrExt; | |
|
8 | 7 | |
|
9 | 8 | pub const HELP_TEXT: &str = " |
|
10 | 9 | Output the current or given revision of files |
|
11 | 10 | "; |
|
12 | 11 | |
|
13 | 12 | pub fn args() -> clap::Command { |
|
14 | 13 | clap::command!("cat") |
|
15 | 14 | .arg( |
|
16 | 15 | Arg::new("rev") |
|
17 | 16 | .help("search the repository as it is in REV") |
|
18 | 17 | .short('r') |
|
19 | 18 | .long("rev") |
|
20 | 19 | .value_name("REV"), |
|
21 | 20 | ) |
|
22 | 21 | .arg( |
|
23 | 22 | clap::Arg::new("files") |
|
24 | 23 | .required(true) |
|
25 | 24 | .num_args(1..) |
|
26 | 25 | .value_name("FILE") |
|
27 | 26 | .value_parser(clap::value_parser!(std::ffi::OsString)) |
|
28 | 27 | .help("Files to output"), |
|
29 | 28 | ) |
|
30 | 29 | .about(HELP_TEXT) |
|
31 | 30 | } |
|
32 | 31 | |
|
33 | 32 | #[logging_timer::time("trace")] |
|
34 | 33 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
35 | 34 | let cat_enabled = invocation.config.get_bool(b"rhg", b"cat")?; |
|
36 | 35 | if !cat_enabled { |
|
37 | 36 | return Err(CommandError::unsupported( |
|
38 | 37 | "cat is disabled in rhg (enable it with 'rhg.cat = true' \ |
|
39 | 38 | or enable fallback with 'rhg.on-unsupported = fallback')", |
|
40 | 39 | )); |
|
41 | 40 | } |
|
42 | 41 | |
|
43 | let rev = invocation.subcommand_args.get_one::<String>("rev"); | |
|
44 | let file_args = | |
|
45 | match invocation.subcommand_args.get_many::<OsString>("files") { | |
|
46 | Some(files) => files | |
|
47 | .filter(|s| !s.is_empty()) | |
|
48 | .map(|s| s.as_os_str()) | |
|
49 | .collect(), | |
|
50 | None => vec![], | |
|
51 | }; | |
|
52 | ||
|
53 | 42 | let repo = invocation.repo?; |
|
54 | let cwd = hg::utils::current_dir()?; | |
|
55 | let working_directory = repo.working_directory_path(); | |
|
56 | let working_directory = cwd.join(working_directory); // Make it absolute | |
|
57 | ||
|
58 | let mut files = vec![]; | |
|
59 | for file in file_args { | |
|
60 | if file.as_bytes().starts_with(b"set:") { | |
|
61 | let message = "fileset"; | |
|
62 | return Err(CommandError::unsupported(message)); | |
|
63 | } | |
|
64 | 43 | |
|
65 | let normalized = cwd.join(file); | |
|
66 | // TODO: actually normalize `..` path segments etc? | |
|
67 | let dotted = normalized.components().any(|c| c.as_os_str() == ".."); | |
|
68 | if file.as_bytes() == b"." || dotted { | |
|
69 | let message = "`..` or `.` path segment"; | |
|
70 | return Err(CommandError::unsupported(message)); | |
|
71 | } | |
|
72 | let relative_path = working_directory | |
|
73 | .strip_prefix(&cwd) | |
|
74 | .unwrap_or(&working_directory); | |
|
75 | let stripped = normalized | |
|
76 | .strip_prefix(&working_directory) | |
|
77 | .map_err(|_| { | |
|
78 | CommandError::abort(format!( | |
|
79 | "abort: {} not under root '{}'\n(consider using '--cwd {}')", | |
|
80 | String::from_utf8_lossy(file.as_bytes()), | |
|
81 | working_directory.display(), | |
|
82 | relative_path.display(), | |
|
83 | )) | |
|
84 | })?; | |
|
85 | let hg_file = HgPathBuf::try_from(stripped.to_path_buf()) | |
|
86 | .map_err(|e| CommandError::abort(e.to_string()))?; | |
|
87 | files.push(hg_file); | |
|
88 | } | |
|
44 | let rev = invocation.subcommand_args.get_one::<String>("rev"); | |
|
45 | let files = match invocation.subcommand_args.get_many::<OsString>("files") | |
|
46 | { | |
|
47 | None => vec![], | |
|
48 | Some(files) => resolve_file_args(repo, files)?, | |
|
49 | }; | |
|
50 | ||
|
89 | 51 | let files = files.iter().map(|file| file.as_ref()).collect(); |
|
90 | 52 | // TODO probably move this to a util function like `repo.default_rev` or |
|
91 | 53 | // something when it's used somewhere else |
|
92 | 54 | let rev = match rev { |
|
93 | 55 | Some(r) => r.to_string(), |
|
94 | 56 | None => format!("{:x}", repo.dirstate_parents()?.p1), |
|
95 | 57 | }; |
|
96 | 58 | |
|
97 | 59 | let output = cat(repo, &rev, files)?; |
|
98 | 60 | for (_file, contents) in output.results { |
|
99 | 61 | invocation.ui.write_stdout(&contents)?; |
|
100 | 62 | } |
|
101 | 63 | if !output.missing.is_empty() { |
|
102 | 64 | let short = format!("{:x}", output.node.short()).into_bytes(); |
|
103 | 65 | for path in &output.missing { |
|
104 | 66 | invocation.ui.write_stderr(&format_bytes!( |
|
105 | 67 | b"{}: no such file in rev {}\n", |
|
106 | 68 | path.as_bytes(), |
|
107 | 69 | short |
|
108 | 70 | ))?; |
|
109 | 71 | } |
|
110 | 72 | } |
|
111 | 73 | if output.found_any { |
|
112 | 74 | Ok(()) |
|
113 | 75 | } else { |
|
114 | 76 | Err(CommandError::Unsuccessful) |
|
115 | 77 | } |
|
116 | 78 | } |
@@ -1,55 +1,96 | |||
|
1 | 1 | // path utils module |
|
2 | 2 | // |
|
3 | 3 | // This software may be used and distributed according to the terms of the |
|
4 | 4 | // GNU General Public License version 2 or any later version. |
|
5 | 5 | |
|
6 | 6 | use hg::errors::HgError; |
|
7 | 7 | use hg::repo::Repo; |
|
8 | 8 | use hg::utils::current_dir; |
|
9 | 9 | use hg::utils::files::{get_bytes_from_path, relativize_path}; |
|
10 | 10 | use hg::utils::hg_path::HgPath; |
|
11 | 11 | use hg::utils::hg_path::HgPathBuf; |
|
12 | 12 | use std::borrow::Cow; |
|
13 | use std::ffi::OsString; | |
|
14 | ||
|
15 | use crate::error::CommandError; | |
|
13 | 16 | |
|
14 | 17 | pub struct RelativizePaths { |
|
15 | 18 | repo_root: HgPathBuf, |
|
16 | 19 | cwd: HgPathBuf, |
|
17 | 20 | outside_repo: bool, |
|
18 | 21 | } |
|
19 | 22 | |
|
20 | 23 | impl RelativizePaths { |
|
21 | 24 | pub fn new(repo: &Repo) -> Result<Self, HgError> { |
|
22 | 25 | let cwd = current_dir()?; |
|
23 | 26 | let repo_root = repo.working_directory_path(); |
|
24 | 27 | let repo_root = cwd.join(repo_root); // Make it absolute |
|
25 | 28 | let repo_root_hgpath = |
|
26 | 29 | HgPathBuf::from(get_bytes_from_path(&repo_root)); |
|
27 | 30 | |
|
28 | 31 | if let Ok(cwd_relative_to_repo) = cwd.strip_prefix(&repo_root) { |
|
29 | 32 | // The current directory is inside the repo, so we can work with |
|
30 | 33 | // relative paths |
|
31 | 34 | Ok(Self { |
|
32 | 35 | repo_root: repo_root_hgpath, |
|
33 | 36 | cwd: HgPathBuf::from(get_bytes_from_path( |
|
34 | 37 | cwd_relative_to_repo, |
|
35 | 38 | )), |
|
36 | 39 | outside_repo: false, |
|
37 | 40 | }) |
|
38 | 41 | } else { |
|
39 | 42 | Ok(Self { |
|
40 | 43 | repo_root: repo_root_hgpath, |
|
41 | 44 | cwd: HgPathBuf::from(get_bytes_from_path(cwd)), |
|
42 | 45 | outside_repo: true, |
|
43 | 46 | }) |
|
44 | 47 | } |
|
45 | 48 | } |
|
46 | 49 | |
|
47 | 50 | pub fn relativize<'a>(&self, path: &'a HgPath) -> Cow<'a, [u8]> { |
|
48 | 51 | if self.outside_repo { |
|
49 | 52 | let joined = self.repo_root.join(path); |
|
50 | 53 | Cow::Owned(relativize_path(&joined, &self.cwd).into_owned()) |
|
51 | 54 | } else { |
|
52 | 55 | relativize_path(path, &self.cwd) |
|
53 | 56 | } |
|
54 | 57 | } |
|
55 | 58 | } |
|
59 | ||
|
60 | /// Resolves `FILE ...` arguments to a list of paths in the repository. | |
|
61 | pub fn resolve_file_args<'a>( | |
|
62 | repo: &Repo, | |
|
63 | file_args: impl Iterator<Item = &'a OsString>, | |
|
64 | ) -> Result<Vec<HgPathBuf>, CommandError> { | |
|
65 | let cwd = hg::utils::current_dir()?; | |
|
66 | let root = cwd.join(repo.working_directory_path()); | |
|
67 | let mut result = Vec::new(); | |
|
68 | for pattern in file_args { | |
|
69 | // TODO: Support all the formats in `hg help patterns`. | |
|
70 | if pattern.as_encoded_bytes().contains(&b':') { | |
|
71 | return Err(CommandError::unsupported( | |
|
72 | "rhg does not support file patterns", | |
|
73 | )); | |
|
74 | } | |
|
75 | // TODO: use hg::utils::files::canonical_path (currently doesn't work). | |
|
76 | let path = cwd.join(pattern); | |
|
77 | let dotted = path.components().any(|c| c.as_os_str() == ".."); | |
|
78 | if pattern.as_encoded_bytes() == b"." || dotted { | |
|
79 | let message = "`..` or `.` path segment"; | |
|
80 | return Err(CommandError::unsupported(message)); | |
|
81 | } | |
|
82 | let relative_path = root.strip_prefix(&cwd).unwrap_or(&root); | |
|
83 | let stripped = path.strip_prefix(&root).map_err(|_| { | |
|
84 | CommandError::abort(format!( | |
|
85 | "abort: {} not under root '{}'\n(consider using '--cwd {}')", | |
|
86 | String::from_utf8_lossy(pattern.as_encoded_bytes()), | |
|
87 | root.display(), | |
|
88 | relative_path.display(), | |
|
89 | )) | |
|
90 | })?; | |
|
91 | let hg_file = HgPathBuf::try_from(stripped.to_path_buf()) | |
|
92 | .map_err(|e| CommandError::abort(e.to_string()))?; | |
|
93 | result.push(hg_file); | |
|
94 | } | |
|
95 | Ok(result) | |
|
96 | } |
@@ -1,458 +1,458 | |||
|
1 | 1 | #require rhg |
|
2 | 2 | |
|
3 | 3 | $ NO_FALLBACK="env RHG_ON_UNSUPPORTED=abort" |
|
4 | 4 | |
|
5 | 5 | Unimplemented command |
|
6 | 6 | $ $NO_FALLBACK rhg unimplemented-command |
|
7 | 7 | unsupported feature: error: unrecognized subcommand 'unimplemented-command' |
|
8 | 8 | |
|
9 | 9 | Usage: rhg [OPTIONS] <COMMAND> |
|
10 | 10 | |
|
11 | 11 | For more information, try '--help'. |
|
12 | 12 | |
|
13 | 13 | [252] |
|
14 | 14 | $ rhg unimplemented-command --config rhg.on-unsupported=abort-silent |
|
15 | 15 | [252] |
|
16 | 16 | |
|
17 | 17 | Finding root |
|
18 | 18 | $ $NO_FALLBACK rhg root |
|
19 | 19 | abort: no repository found in '$TESTTMP' (.hg not found)! |
|
20 | 20 | [255] |
|
21 | 21 | |
|
22 | 22 | $ hg init repository |
|
23 | 23 | $ cd repository |
|
24 | 24 | $ $NO_FALLBACK rhg root |
|
25 | 25 | $TESTTMP/repository |
|
26 | 26 | |
|
27 | 27 | Reading and setting configuration |
|
28 | 28 | $ echo "[ui]" >> $HGRCPATH |
|
29 | 29 | $ echo "username = user1" >> $HGRCPATH |
|
30 | 30 | $ echo "[extensions]" >> $HGRCPATH |
|
31 | 31 | $ echo "sparse =" >> $HGRCPATH |
|
32 | 32 | $ $NO_FALLBACK rhg config ui.username |
|
33 | 33 | user1 |
|
34 | 34 | $ echo "[ui]" >> .hg/hgrc |
|
35 | 35 | $ echo "username = user2" >> .hg/hgrc |
|
36 | 36 | $ $NO_FALLBACK rhg config ui.username |
|
37 | 37 | user2 |
|
38 | 38 | $ $NO_FALLBACK rhg --config ui.username=user3 config ui.username |
|
39 | 39 | user3 |
|
40 | 40 | |
|
41 | 41 | Unwritable file descriptor |
|
42 | 42 | $ $NO_FALLBACK rhg root > /dev/full |
|
43 | 43 | abort: No space left on device (os error 28) |
|
44 | 44 | [255] |
|
45 | 45 | |
|
46 | 46 | Deleted repository |
|
47 | 47 | $ rm -rf `pwd` |
|
48 | 48 | $ $NO_FALLBACK rhg root |
|
49 | 49 | abort: error getting current working directory: $ENOENT$ |
|
50 | 50 | [255] |
|
51 | 51 | |
|
52 | 52 | Listing tracked files |
|
53 | 53 | $ cd $TESTTMP |
|
54 | 54 | $ hg init repository |
|
55 | 55 | $ cd repository |
|
56 | 56 | $ for i in 1 2 3; do |
|
57 | 57 | > echo $i >> file$i |
|
58 | 58 | > hg add file$i |
|
59 | 59 | > done |
|
60 | 60 | > hg commit -m "commit $i" -q |
|
61 | 61 | |
|
62 | 62 | Listing tracked files from root |
|
63 | 63 | $ $NO_FALLBACK rhg files |
|
64 | 64 | file1 |
|
65 | 65 | file2 |
|
66 | 66 | file3 |
|
67 | 67 | |
|
68 | 68 | Listing tracked files from subdirectory |
|
69 | 69 | $ mkdir -p path/to/directory |
|
70 | 70 | $ cd path/to/directory |
|
71 | 71 | $ $NO_FALLBACK rhg files |
|
72 | 72 | ../../../file1 |
|
73 | 73 | ../../../file2 |
|
74 | 74 | ../../../file3 |
|
75 | 75 | |
|
76 | 76 | $ $NO_FALLBACK rhg files --config ui.relative-paths=legacy |
|
77 | 77 | ../../../file1 |
|
78 | 78 | ../../../file2 |
|
79 | 79 | ../../../file3 |
|
80 | 80 | |
|
81 | 81 | $ $NO_FALLBACK rhg files --config ui.relative-paths=false |
|
82 | 82 | file1 |
|
83 | 83 | file2 |
|
84 | 84 | file3 |
|
85 | 85 | |
|
86 | 86 | $ $NO_FALLBACK rhg files --config ui.relative-paths=true |
|
87 | 87 | ../../../file1 |
|
88 | 88 | ../../../file2 |
|
89 | 89 | ../../../file3 |
|
90 | 90 | |
|
91 | 91 | Listing tracked files through broken pipe |
|
92 | 92 | $ $NO_FALLBACK rhg files | head -n 1 |
|
93 | 93 | ../../../file1 |
|
94 | 94 | |
|
95 | 95 | Status with --rev and --change |
|
96 | 96 | $ cd $TESTTMP/repository |
|
97 | 97 | $ $NO_FALLBACK rhg status --change null |
|
98 | 98 | $ $NO_FALLBACK rhg status --change 0 |
|
99 | 99 | A file1 |
|
100 | 100 | A file2 |
|
101 | 101 | A file3 |
|
102 | 102 | $ $NO_FALLBACK rhg status --rev null --rev 0 |
|
103 | 103 | A file1 |
|
104 | 104 | A file2 |
|
105 | 105 | A file3 |
|
106 | 106 | |
|
107 | 107 | Status with --change --copies |
|
108 | 108 | $ hg copy file2 file2copy |
|
109 | 109 | $ hg rename file3 file3rename |
|
110 | 110 | $ hg commit -m "commit 4" -q |
|
111 | 111 | $ $NO_FALLBACK rhg status --change . --copies |
|
112 | 112 | A file2copy |
|
113 | 113 | file2 |
|
114 | 114 | A file3rename |
|
115 | 115 | file3 |
|
116 | 116 | R file3 |
|
117 | 117 | |
|
118 | 118 | Debuging data in inline index |
|
119 | 119 | $ cd $TESTTMP |
|
120 | 120 | $ rm -rf repository |
|
121 | 121 | $ hg init repository |
|
122 | 122 | $ cd repository |
|
123 | 123 | $ for i in 1 2 3 4 5 6; do |
|
124 | 124 | > echo $i >> file-$i |
|
125 | 125 | > hg add file-$i |
|
126 | 126 | > hg commit -m "Commit $i" -q |
|
127 | 127 | > done |
|
128 | 128 | $ $NO_FALLBACK rhg debugdata -c 2 |
|
129 | 129 | 8d0267cb034247ebfa5ee58ce59e22e57a492297 |
|
130 | 130 | test |
|
131 | 131 | 0 0 |
|
132 | 132 | file-3 |
|
133 | 133 | |
|
134 | 134 | Commit 3 (no-eol) |
|
135 | 135 | $ $NO_FALLBACK rhg debugdata -m 2 |
|
136 | 136 | file-1\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc) |
|
137 | 137 | file-2\x005d9299349fc01ddd25d0070d149b124d8f10411e (esc) |
|
138 | 138 | file-3\x002661d26c649684b482d10f91960cc3db683c38b4 (esc) |
|
139 | 139 | |
|
140 | 140 | Debuging with full node id |
|
141 | 141 | $ $NO_FALLBACK rhg debugdata -c `hg log -r 0 -T '{node}'` |
|
142 | 142 | d1d1c679d3053e8926061b6f45ca52009f011e3f |
|
143 | 143 | test |
|
144 | 144 | 0 0 |
|
145 | 145 | file-1 |
|
146 | 146 | |
|
147 | 147 | Commit 1 (no-eol) |
|
148 | 148 | |
|
149 | 149 | Specifying revisions by changeset ID |
|
150 | 150 | $ hg log -T '{node}\n' |
|
151 | 151 | c6ad58c44207b6ff8a4fbbca7045a5edaa7e908b |
|
152 | 152 | d654274993d0149eecc3cc03214f598320211900 |
|
153 | 153 | f646af7e96481d3a5470b695cf30ad8e3ab6c575 |
|
154 | 154 | cf8b83f14ead62b374b6e91a0e9303b85dfd9ed7 |
|
155 | 155 | 91c6f6e73e39318534dc415ea4e8a09c99cd74d6 |
|
156 | 156 | 6ae9681c6d30389694d8701faf24b583cf3ccafe |
|
157 | 157 | $ $NO_FALLBACK rhg files -r cf8b83 |
|
158 | 158 | file-1 |
|
159 | 159 | file-2 |
|
160 | 160 | file-3 |
|
161 | 161 | $ $NO_FALLBACK rhg cat -r cf8b83 file-2 |
|
162 | 162 | 2 |
|
163 | 163 | $ $NO_FALLBACK rhg cat --rev cf8b83 file-2 |
|
164 | 164 | 2 |
|
165 | 165 | $ $NO_FALLBACK rhg cat -r c file-2 |
|
166 | 166 | abort: ambiguous revision identifier: c |
|
167 | 167 | [255] |
|
168 | 168 | $ $NO_FALLBACK rhg cat -r d file-2 |
|
169 | 169 | 2 |
|
170 | 170 | $ $NO_FALLBACK rhg cat -r 0000 file-2 |
|
171 | 171 | file-2: no such file in rev 000000000000 |
|
172 | 172 | [1] |
|
173 | 173 | |
|
174 | 174 | Cat files |
|
175 | 175 | $ cd $TESTTMP |
|
176 | 176 | $ rm -rf repository |
|
177 | 177 | $ hg init repository |
|
178 | 178 | $ cd repository |
|
179 | 179 | $ echo "original content" > original |
|
180 | 180 | $ hg add original |
|
181 | 181 | $ hg commit -m "add original" original |
|
182 | 182 | Without `--rev` |
|
183 | 183 | $ $NO_FALLBACK rhg cat original |
|
184 | 184 | original content |
|
185 | 185 | With `--rev` |
|
186 | 186 | $ $NO_FALLBACK rhg cat -r 0 original |
|
187 | 187 | original content |
|
188 | 188 | Cat copied file should not display copy metadata |
|
189 | 189 | $ hg copy original copy_of_original |
|
190 | 190 | $ hg commit -m "add copy of original" |
|
191 | 191 | $ $NO_FALLBACK rhg cat original |
|
192 | 192 | original content |
|
193 | 193 | $ $NO_FALLBACK rhg cat -r 1 copy_of_original |
|
194 | 194 | original content |
|
195 | 195 | |
|
196 | 196 | |
|
197 | 197 | Fallback to Python |
|
198 | 198 | $ $NO_FALLBACK rhg cat original --exclude="*.rs" |
|
199 | 199 | unsupported feature: error: unexpected argument '--exclude' found |
|
200 | 200 | |
|
201 | 201 | tip: to pass '--exclude' as a value, use '-- --exclude' |
|
202 | 202 | |
|
203 | 203 | Usage: rhg cat <FILE>... |
|
204 | 204 | |
|
205 | 205 | For more information, try '--help'. |
|
206 | 206 | |
|
207 | 207 | [252] |
|
208 | 208 | $ rhg cat original --exclude="*.rs" |
|
209 | 209 | original content |
|
210 | 210 | |
|
211 | 211 | Check that `fallback-immediately` overrides `$NO_FALLBACK` |
|
212 | 212 | $ $NO_FALLBACK rhg cat original --exclude="*.rs" --config rhg.fallback-immediately=1 |
|
213 | 213 | original content |
|
214 | 214 | |
|
215 | 215 | $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original --exclude="*.rs") |
|
216 | 216 | abort: 'rhg.on-unsupported=fallback' without 'rhg.fallback-executable' set. |
|
217 | 217 | [255] |
|
218 | 218 | |
|
219 | 219 | $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original) |
|
220 | 220 | original content |
|
221 | 221 | |
|
222 | 222 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=false |
|
223 | 223 | [1] |
|
224 | 224 | |
|
225 | 225 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=hg-non-existent |
|
226 | 226 | abort: invalid fallback 'hg-non-existent': cannot find binary path |
|
227 | 227 | [253] |
|
228 | 228 | |
|
229 | 229 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=rhg |
|
230 | 230 | Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config points to `rhg` itself. |
|
231 | 231 | unsupported feature: error: unexpected argument '--exclude' found |
|
232 | 232 | |
|
233 | 233 | tip: to pass '--exclude' as a value, use '-- --exclude' |
|
234 | 234 | |
|
235 | 235 | Usage: rhg cat <FILE>... |
|
236 | 236 | |
|
237 | 237 | For more information, try '--help'. |
|
238 | 238 | |
|
239 | 239 | [252] |
|
240 | 240 | |
|
241 | 241 | Fallback with shell path segments |
|
242 | 242 | $ $NO_FALLBACK rhg cat . |
|
243 | 243 | unsupported feature: `..` or `.` path segment |
|
244 | 244 | [252] |
|
245 | 245 | $ $NO_FALLBACK rhg cat .. |
|
246 | 246 | unsupported feature: `..` or `.` path segment |
|
247 | 247 | [252] |
|
248 | 248 | $ $NO_FALLBACK rhg cat ../.. |
|
249 | 249 | unsupported feature: `..` or `.` path segment |
|
250 | 250 | [252] |
|
251 | 251 | |
|
252 | 252 | Fallback with filesets |
|
253 | 253 | $ $NO_FALLBACK rhg cat "set:c or b" |
|
254 |
unsupported feature: |
|
|
254 | unsupported feature: rhg does not support file patterns | |
|
255 | 255 | [252] |
|
256 | 256 | |
|
257 | 257 | Fallback with generic hooks |
|
258 | 258 | $ $NO_FALLBACK rhg cat original --config hooks.pre-cat=something |
|
259 | 259 | unsupported feature: pre-cat hook defined |
|
260 | 260 | [252] |
|
261 | 261 | |
|
262 | 262 | $ $NO_FALLBACK rhg cat original --config hooks.post-cat=something |
|
263 | 263 | unsupported feature: post-cat hook defined |
|
264 | 264 | [252] |
|
265 | 265 | |
|
266 | 266 | $ $NO_FALLBACK rhg cat original --config hooks.fail-cat=something |
|
267 | 267 | unsupported feature: fail-cat hook defined |
|
268 | 268 | [252] |
|
269 | 269 | |
|
270 | 270 | Fallback with [defaults] |
|
271 | 271 | $ $NO_FALLBACK rhg cat original --config "defaults.cat=-r null" |
|
272 | 272 | unsupported feature: `defaults` config set |
|
273 | 273 | [252] |
|
274 | 274 | |
|
275 | 275 | |
|
276 | 276 | Requirements |
|
277 | 277 | $ $NO_FALLBACK rhg debugrequirements |
|
278 | 278 | dotencode |
|
279 | 279 | fncache |
|
280 | 280 | generaldelta |
|
281 | 281 | persistent-nodemap |
|
282 | 282 | revlog-compression-zstd (zstd !) |
|
283 | 283 | revlogv1 |
|
284 | 284 | share-safe |
|
285 | 285 | sparserevlog |
|
286 | 286 | store |
|
287 | 287 | |
|
288 | 288 | $ echo indoor-pool >> .hg/requires |
|
289 | 289 | $ $NO_FALLBACK rhg files |
|
290 | 290 | unsupported feature: repository requires feature unknown to this Mercurial: indoor-pool |
|
291 | 291 | [252] |
|
292 | 292 | |
|
293 | 293 | $ $NO_FALLBACK rhg cat -r 1 copy_of_original |
|
294 | 294 | unsupported feature: repository requires feature unknown to this Mercurial: indoor-pool |
|
295 | 295 | [252] |
|
296 | 296 | |
|
297 | 297 | $ $NO_FALLBACK rhg debugrequirements |
|
298 | 298 | unsupported feature: repository requires feature unknown to this Mercurial: indoor-pool |
|
299 | 299 | [252] |
|
300 | 300 | |
|
301 | 301 | $ echo -e '\xFF' >> .hg/requires |
|
302 | 302 | $ $NO_FALLBACK rhg debugrequirements |
|
303 | 303 | abort: parse error in 'requires' file |
|
304 | 304 | [255] |
|
305 | 305 | |
|
306 | 306 | Persistent nodemap |
|
307 | 307 | $ cd $TESTTMP |
|
308 | 308 | $ rm -rf repository |
|
309 | 309 | $ hg --config format.use-persistent-nodemap=no init repository |
|
310 | 310 | $ cd repository |
|
311 | 311 | $ $NO_FALLBACK rhg debugrequirements | grep nodemap |
|
312 | 312 | [1] |
|
313 | 313 | $ hg debugbuilddag .+5000 --overwritten-file --config "storage.revlog.nodemap.mode=warn" |
|
314 | 314 | $ hg id -r tip |
|
315 | 315 | c3ae8dec9fad tip |
|
316 | 316 | $ ls .hg/store/00changelog* |
|
317 | 317 | .hg/store/00changelog.d |
|
318 | 318 | .hg/store/00changelog.i |
|
319 | 319 | $ $NO_FALLBACK rhg files -r c3ae8dec9fad |
|
320 | 320 | of |
|
321 | 321 | |
|
322 | 322 | $ cd $TESTTMP |
|
323 | 323 | $ rm -rf repository |
|
324 | 324 | $ hg --config format.use-persistent-nodemap=True init repository |
|
325 | 325 | $ cd repository |
|
326 | 326 | $ $NO_FALLBACK rhg debugrequirements | grep nodemap |
|
327 | 327 | persistent-nodemap |
|
328 | 328 | $ hg debugbuilddag .+5000 --overwritten-file --config "storage.revlog.nodemap.mode=warn" |
|
329 | 329 | $ hg id -r tip |
|
330 | 330 | c3ae8dec9fad tip |
|
331 | 331 | $ ls .hg/store/00changelog* |
|
332 | 332 | .hg/store/00changelog-*.nd (glob) |
|
333 | 333 | .hg/store/00changelog.d |
|
334 | 334 | .hg/store/00changelog.i |
|
335 | 335 | .hg/store/00changelog.n |
|
336 | 336 | |
|
337 | 337 | Rhg status on a sparse repo with nodemap (this specific combination used to crash in 6.5.2) |
|
338 | 338 | |
|
339 | 339 | $ hg debugsparse -X excluded-dir |
|
340 | 340 | $ $NO_FALLBACK rhg status |
|
341 | 341 | |
|
342 | 342 | Specifying revisions by changeset ID |
|
343 | 343 | $ $NO_FALLBACK rhg files -r c3ae8dec9fad |
|
344 | 344 | of |
|
345 | 345 | $ $NO_FALLBACK rhg cat -r c3ae8dec9fad of |
|
346 | 346 | r5000 |
|
347 | 347 | |
|
348 | 348 | Crate a shared repository |
|
349 | 349 | |
|
350 | 350 | $ echo "[extensions]" >> $HGRCPATH |
|
351 | 351 | $ echo "share = " >> $HGRCPATH |
|
352 | 352 | |
|
353 | 353 | $ cd $TESTTMP |
|
354 | 354 | $ hg init repo1 |
|
355 | 355 | $ echo a > repo1/a |
|
356 | 356 | $ hg -R repo1 commit -A -m'init' |
|
357 | 357 | adding a |
|
358 | 358 | |
|
359 | 359 | $ hg share repo1 repo2 |
|
360 | 360 | updating working directory |
|
361 | 361 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
362 | 362 | |
|
363 | 363 | And check that basic rhg commands work with sharing |
|
364 | 364 | |
|
365 | 365 | $ $NO_FALLBACK rhg files -R repo2 |
|
366 | 366 | repo2/a |
|
367 | 367 | $ $NO_FALLBACK rhg -R repo2 cat -r 0 repo2/a |
|
368 | 368 | a |
|
369 | 369 | |
|
370 | 370 | Same with relative sharing |
|
371 | 371 | |
|
372 | 372 | $ hg share repo2 repo3 --relative |
|
373 | 373 | updating working directory |
|
374 | 374 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
375 | 375 | |
|
376 | 376 | $ $NO_FALLBACK rhg files -R repo3 |
|
377 | 377 | repo3/a |
|
378 | 378 | $ $NO_FALLBACK rhg -R repo3 cat -r 0 repo3/a |
|
379 | 379 | a |
|
380 | 380 | |
|
381 | 381 | Same with share-safe |
|
382 | 382 | |
|
383 | 383 | $ echo "[format]" >> $HGRCPATH |
|
384 | 384 | $ echo "use-share-safe = True" >> $HGRCPATH |
|
385 | 385 | |
|
386 | 386 | $ cd $TESTTMP |
|
387 | 387 | $ hg init repo4 |
|
388 | 388 | $ cd repo4 |
|
389 | 389 | $ echo a > a |
|
390 | 390 | $ hg commit -A -m'init' |
|
391 | 391 | adding a |
|
392 | 392 | |
|
393 | 393 | $ cd .. |
|
394 | 394 | $ hg share repo4 repo5 |
|
395 | 395 | updating working directory |
|
396 | 396 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
397 | 397 | |
|
398 | 398 | And check that basic rhg commands work with sharing |
|
399 | 399 | |
|
400 | 400 | $ cd repo5 |
|
401 | 401 | $ $NO_FALLBACK rhg files |
|
402 | 402 | a |
|
403 | 403 | $ $NO_FALLBACK rhg cat -r 0 a |
|
404 | 404 | a |
|
405 | 405 | |
|
406 | 406 | The blackbox extension is supported |
|
407 | 407 | |
|
408 | 408 | $ echo "[extensions]" >> $HGRCPATH |
|
409 | 409 | $ echo "blackbox =" >> $HGRCPATH |
|
410 | 410 | $ echo "[blackbox]" >> $HGRCPATH |
|
411 | 411 | $ echo "maxsize = 1" >> $HGRCPATH |
|
412 | 412 | $ $NO_FALLBACK rhg files > /dev/null |
|
413 | 413 | $ cat .hg/blackbox.log |
|
414 | 414 | ????-??-?? ??:??:??.??? * @d3873e73d99ef67873dac33fbcc66268d5d2b6f4 (*)> (rust) files exited 0 after * seconds (glob) |
|
415 | 415 | $ cat .hg/blackbox.log.1 |
|
416 | 416 | ????-??-?? ??:??:??.??? * @d3873e73d99ef67873dac33fbcc66268d5d2b6f4 (*)> (rust) files (glob) |
|
417 | 417 | |
|
418 | 418 | Subrepos are not supported |
|
419 | 419 | |
|
420 | 420 | $ touch .hgsub |
|
421 | 421 | $ $NO_FALLBACK rhg files |
|
422 | 422 | unsupported feature: subrepos (.hgsub is present) |
|
423 | 423 | [252] |
|
424 | 424 | $ rhg files |
|
425 | 425 | a |
|
426 | 426 | $ rm .hgsub |
|
427 | 427 | |
|
428 | 428 | The `:required` extension suboptions are correctly ignored |
|
429 | 429 | |
|
430 | 430 | $ echo "[extensions]" >> $HGRCPATH |
|
431 | 431 | $ echo "blackbox:required = yes" >> $HGRCPATH |
|
432 | 432 | $ rhg files |
|
433 | 433 | a |
|
434 | 434 | $ echo "*:required = yes" >> $HGRCPATH |
|
435 | 435 | $ rhg files |
|
436 | 436 | a |
|
437 | 437 | |
|
438 | 438 | Check that we expand both user and environment in ignore includes (HOME is TESTTMP) |
|
439 | 439 | |
|
440 | 440 | $ echo "specificprefix" > ~/ignore.expected-extension |
|
441 | 441 | $ touch specificprefix |
|
442 | 442 | $ $NO_FALLBACK rhg st |
|
443 | 443 | ? specificprefix |
|
444 | 444 | $ $NO_FALLBACK RHG_EXT_TEST=expected-extension rhg st --config 'ui.ignore=~/ignore.${RHG_EXT_TEST}' |
|
445 | 445 | |
|
446 | 446 | We can ignore all extensions at once |
|
447 | 447 | |
|
448 | 448 | $ echo "[extensions]" >> $HGRCPATH |
|
449 | 449 | $ echo "thisextensionbetternotexist=" >> $HGRCPATH |
|
450 | 450 | $ echo "thisextensionbetternotexisteither=" >> $HGRCPATH |
|
451 | 451 | $ $NO_FALLBACK rhg files |
|
452 | 452 | unsupported feature: extensions: thisextensionbetternotexist, thisextensionbetternotexisteither (consider adding them to 'rhg.ignored-extensions' config) |
|
453 | 453 | [252] |
|
454 | 454 | |
|
455 | 455 | $ echo "[rhg]" >> $HGRCPATH |
|
456 | 456 | $ echo "ignored-extensions=*" >> $HGRCPATH |
|
457 | 457 | $ $NO_FALLBACK rhg files |
|
458 | 458 | a |
General Comments 0
You need to be logged in to leave comments.
Login now