##// END OF EJS Templates
rhg: Sort `rhg status` output correctly...
Simon Sapin -
r48112:62225f9d default
parent child Browse files
Show More
@@ -181,7 +181,7 b' pub fn run(invocation: &crate::CliInvoca'
181 181 collect_traversed_dirs: false,
182 182 };
183 183 let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded
184 let (ds_status, pattern_warnings) = hg::status(
184 let (mut ds_status, pattern_warnings) = hg::status(
185 185 &dmap,
186 186 &AlwaysMatcher,
187 187 repo.working_directory_path().to_owned(),
@@ -201,53 +201,49 b' pub fn run(invocation: &crate::CliInvoca'
201 201 &ds_status.unsure
202 202 );
203 203 }
204 // TODO check ordering to match `hg status` output.
205 // (this is as in `hg help status`)
206 if display_states.modified {
207 display_status_paths(ui, &(ds_status.modified), b"M")?;
208 }
209 if !ds_status.unsure.is_empty() {
204 if !ds_status.unsure.is_empty()
205 && (display_states.modified || display_states.clean)
206 {
210 207 let p1: Node = parents
211 208 .expect(
212 209 "Dirstate with no parents should not list any file to
213 be rechecked for modifications",
210 be rechecked for modifications",
214 211 )
215 212 .p1
216 213 .into();
217 214 let p1_hex = format!("{:x}", p1);
218 let mut rechecked_modified: Vec<HgPathCow> = Vec::new();
219 let mut rechecked_clean: Vec<HgPathCow> = Vec::new();
220 215 for to_check in ds_status.unsure {
221 216 if cat_file_is_modified(repo, &to_check, &p1_hex)? {
222 rechecked_modified.push(to_check);
217 if display_states.modified {
218 ds_status.modified.push(to_check);
219 }
223 220 } else {
224 rechecked_clean.push(to_check);
221 if display_states.clean {
222 ds_status.clean.push(to_check);
223 }
225 224 }
226 225 }
227 if display_states.modified {
228 display_status_paths(ui, &rechecked_modified, b"M")?;
229 }
230 if display_states.clean {
231 display_status_paths(ui, &rechecked_clean, b"C")?;
232 }
226 }
227 if display_states.modified {
228 display_status_paths(ui, &mut ds_status.modified, b"M")?;
233 229 }
234 230 if display_states.added {
235 display_status_paths(ui, &(ds_status.added), b"A")?;
236 }
237 if display_states.clean {
238 display_status_paths(ui, &(ds_status.clean), b"C")?;
231 display_status_paths(ui, &mut ds_status.added, b"A")?;
239 232 }
240 233 if display_states.removed {
241 display_status_paths(ui, &(ds_status.removed), b"R")?;
234 display_status_paths(ui, &mut ds_status.removed, b"R")?;
242 235 }
243 236 if display_states.deleted {
244 display_status_paths(ui, &(ds_status.deleted), b"!")?;
237 display_status_paths(ui, &mut ds_status.deleted, b"!")?;
245 238 }
246 239 if display_states.unknown {
247 display_status_paths(ui, &(ds_status.unknown), b"?")?;
240 display_status_paths(ui, &mut ds_status.unknown, b"?")?;
248 241 }
249 242 if display_states.ignored {
250 display_status_paths(ui, &(ds_status.ignored), b"I")?;
243 display_status_paths(ui, &mut ds_status.ignored, b"I")?;
244 }
245 if display_states.clean {
246 display_status_paths(ui, &mut ds_status.clean, b"C")?;
251 247 }
252 248 Ok(())
253 249 }
@@ -256,9 +252,10 b' pub fn run(invocation: &crate::CliInvoca'
256 252 // harcode HgPathBuf, but probably not really useful at this point
257 253 fn display_status_paths(
258 254 ui: &Ui,
259 paths: &[HgPathCow],
255 paths: &mut [HgPathCow],
260 256 status_prefix: &[u8],
261 257 ) -> Result<(), CommandError> {
258 paths.sort_unstable();
262 259 for path in paths {
263 260 // Same TODO as in commands::root
264 261 let bytes: &[u8] = path.as_bytes();
General Comments 0
You need to be logged in to leave comments. Login now