Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/repo.rs @ 47407:6e49769b7f97
rhg: add exit code to HgError::Abort()
My previous attempts to have rhg end with correct exit code was more of bug
hunting. I found cases which were failing and fixed them. But as one might
expect, more tests started failing.
Let's add exit code `HgError::Abort()` and make it users explicitly tell what
exit code they want.
Differential Revision: https://phab.mercurial-scm.org/D10838
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 07 Jun 2021 17:27:49 +0530 |
parents | 88119fffecc8 |
children | ff97e793ed36 |
comparison
equal
deleted
inserted
replaced
47406:3237ed4dcda4 | 47407:6e49769b7f97 |
---|---|
1 use crate::config::{Config, ConfigError, ConfigParseError}; | 1 use crate::config::{Config, ConfigError, ConfigParseError}; |
2 use crate::errors::{HgError, IoErrorContext, IoResultExt}; | 2 use crate::errors::{HgError, IoErrorContext, IoResultExt}; |
3 use crate::exit_codes; | |
3 use crate::requirements; | 4 use crate::requirements; |
4 use crate::utils::files::get_path_from_bytes; | 5 use crate::utils::files::get_path_from_bytes; |
5 use crate::utils::SliceExt; | 6 use crate::utils::SliceExt; |
6 use memmap::{Mmap, MmapOptions}; | 7 use memmap::{Mmap, MmapOptions}; |
7 use std::collections::HashSet; | 8 use std::collections::HashSet; |
148 .get(b"share", b"safe-mismatch.source-not-safe") | 149 .get(b"share", b"safe-mismatch.source-not-safe") |
149 { | 150 { |
150 Some(b"abort") | None => HgError::abort( | 151 Some(b"abort") | None => HgError::abort( |
151 "abort: share source does not support share-safe requirement\n\ | 152 "abort: share source does not support share-safe requirement\n\ |
152 (see `hg help config.format.use-share-safe` for more information)", | 153 (see `hg help config.format.use-share-safe` for more information)", |
154 exit_codes::ABORT, | |
153 ), | 155 ), |
154 _ => HgError::unsupported("share-safe downgrade"), | 156 _ => HgError::unsupported("share-safe downgrade"), |
155 } | 157 } |
156 .into()); | 158 .into()); |
157 } else if source_is_share_safe && !share_safe { | 159 } else if source_is_share_safe && !share_safe { |
159 match config.get(b"share", b"safe-mismatch.source-safe") { | 161 match config.get(b"share", b"safe-mismatch.source-safe") { |
160 Some(b"abort") | None => HgError::abort( | 162 Some(b"abort") | None => HgError::abort( |
161 "abort: version mismatch: source uses share-safe \ | 163 "abort: version mismatch: source uses share-safe \ |
162 functionality while the current share does not\n\ | 164 functionality while the current share does not\n\ |
163 (see `hg help config.format.use-share-safe` for more information)", | 165 (see `hg help config.format.use-share-safe` for more information)", |
166 exit_codes::ABORT, | |
164 ), | 167 ), |
165 _ => HgError::unsupported("share-safe upgrade"), | 168 _ => HgError::unsupported("share-safe upgrade"), |
166 } | 169 } |
167 .into(), | 170 .into(), |
168 ); | 171 ); |