Show More
@@ -56,10 +56,14 pub fn run(invocation: &crate::CliInvoca | |||
|
56 | 56 | .map_err(|e| CommandError::abort(e.to_string()))?; |
|
57 | 57 | files.push(hg_file); |
|
58 | 58 | } |
|
59 | // TODO probably move this to a util function like `repo.default_rev` or | |
|
60 | // something when it's used somewhere else | |
|
61 | let rev = match rev { | |
|
62 | Some(r) => r.to_string(), | |
|
63 | None => format!("{:x}", repo.dirstate_parents()?.p1), | |
|
64 | }; | |
|
59 | 65 | |
|
60 | match rev { | |
|
61 | Some(rev) => { | |
|
62 | let output = cat(&repo, rev, &files).map_err(|e| (e, rev))?; | |
|
66 | let output = cat(&repo, &rev, &files).map_err(|e| (e, rev.as_str()))?; | |
|
63 | 67 |
|
|
64 | 68 |
|
|
65 | 69 |
|
@@ -77,8 +81,3 pub fn run(invocation: &crate::CliInvoca | |||
|
77 | 81 |
|
|
78 | 82 | } |
|
79 | 83 | } |
|
80 | None => Err(CommandError::unsupported( | |
|
81 | "`rhg cat` without `--rev` / `-r`", | |
|
82 | )), | |
|
83 | } | |
|
84 | } |
@@ -138,40 +138,65 Cat files | |||
|
138 | 138 | $ echo "original content" > original |
|
139 | 139 | $ hg add original |
|
140 | 140 | $ hg commit -m "add original" original |
|
141 | Without `--rev` | |
|
142 | $ $NO_FALLBACK rhg cat original | |
|
143 | original content | |
|
144 | With `--rev` | |
|
141 | 145 | $ $NO_FALLBACK rhg cat -r 0 original |
|
142 | 146 | original content |
|
143 | 147 | Cat copied file should not display copy metadata |
|
144 | 148 | $ hg copy original copy_of_original |
|
145 | 149 | $ hg commit -m "add copy of original" |
|
150 | $ $NO_FALLBACK rhg cat original | |
|
151 | original content | |
|
146 | 152 | $ $NO_FALLBACK rhg cat -r 1 copy_of_original |
|
147 | 153 | original content |
|
148 | 154 | |
|
155 | ||
|
149 | 156 | Fallback to Python |
|
150 | $ $NO_FALLBACK rhg cat original | |
|
151 | unsupported feature: `rhg cat` without `--rev` / `-r` | |
|
157 | $ $NO_FALLBACK rhg cat original --exclude="*.rs" | |
|
158 | unsupported feature: error: Found argument '--exclude' which wasn't expected, or isn't valid in this context | |
|
159 | ||
|
160 | USAGE: | |
|
161 | rhg cat [OPTIONS] <FILE>... | |
|
162 | ||
|
163 | For more information try --help | |
|
164 | ||
|
152 | 165 | [252] |
|
153 | $ rhg cat original | |
|
166 | $ rhg cat original --exclude="*.rs" | |
|
154 | 167 | original content |
|
155 | 168 | |
|
156 | 169 | $ FALLBACK_EXE="$RHG_FALLBACK_EXECUTABLE" |
|
157 | 170 | $ unset RHG_FALLBACK_EXECUTABLE |
|
158 | $ rhg cat original | |
|
171 | $ rhg cat original --exclude="*.rs" | |
|
159 | 172 | abort: 'rhg.on-unsupported=fallback' without 'rhg.fallback-executable' set. |
|
160 | 173 | [255] |
|
161 | 174 | $ RHG_FALLBACK_EXECUTABLE="$FALLBACK_EXE" |
|
162 | 175 | $ export RHG_FALLBACK_EXECUTABLE |
|
163 | 176 | |
|
164 | $ rhg cat original --config rhg.fallback-executable=false | |
|
177 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=false | |
|
165 | 178 | [1] |
|
166 | 179 | |
|
167 | $ rhg cat original --config rhg.fallback-executable=hg-non-existent | |
|
180 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=hg-non-existent | |
|
168 | 181 | tried to fall back to a 'hg-non-existent' sub-process but got error $ENOENT$ |
|
169 | unsupported feature: `rhg cat` without `--rev` / `-r` | |
|
182 | unsupported feature: error: Found argument '--exclude' which wasn't expected, or isn't valid in this context | |
|
183 | ||
|
184 | USAGE: | |
|
185 | rhg cat [OPTIONS] <FILE>... | |
|
186 | ||
|
187 | For more information try --help | |
|
188 | ||
|
170 | 189 | [252] |
|
171 | 190 | |
|
172 | $ rhg cat original --config rhg.fallback-executable=rhg | |
|
191 | $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=rhg | |
|
173 | 192 | Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config points to `rhg` itself. |
|
174 | unsupported feature: `rhg cat` without `--rev` / `-r` | |
|
193 | unsupported feature: error: Found argument '--exclude' which wasn't expected, or isn't valid in this context | |
|
194 | ||
|
195 | USAGE: | |
|
196 | rhg cat [OPTIONS] <FILE>... | |
|
197 | ||
|
198 | For more information try --help | |
|
199 | ||
|
175 | 200 | [252] |
|
176 | 201 | |
|
177 | 202 | Requirements |
General Comments 0
You need to be logged in to leave comments.
Login now