Failed pipeline for branch/stable | mercurial-devel | 6171db0a
Pipeline #18456 has failed! Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel ) Branch: branch/stable ( https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/stable ) Commit: 6171db0a ( https://foss.heptapod.net/octobus/mercurial-devel/-/commit/6171db0a5b00666d571a867001a0a306910060eb ) Commit Message: tests: accept output changes by 33350debb480 D... Commit Author: Sushil Khanchi ( https://foss.heptapod.net/khanchi97 ) Pipeline #18456 ( https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/18456 ) triggered by Administrator ( https://foss.heptapod.net/root ) had 3 failed builds. Job #170527 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/170527/raw ) Stage: tests Name: test-py3-pure Job #170520 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/170520/raw ) Stage: tests Name: checks-py2 Job #170521 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/170521/raw ) Stage: tests Name: checks-py3 -- You're receiving this email because of your account on foss.heptapod.net. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10078: rhg: Bug fix: with share-safe, always read store requirements
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY That is, the `store/requires` file, regardless of whether the repository is a shared. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10078 AFFECTED FILES rust/hg-core/src/repo.rs CHANGE DETAILS diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs --- a/rust/hg-core/src/repo.rs +++ b/rust/hg-core/src/repo.rs @@ -116,9 +116,6 @@ let store_path; if !shared { store_path = dot_hg.join("store"); -if share_safe { -reqs.extend(requirements::load(Vfs { base: _path })?); -} } else { let bytes = hg_vfs.read("sharedpath")?; let mut shared_path = get_path_from_bytes().to_owned(); @@ -166,6 +163,9 @@ repo_config_files.insert(0, shared_path.join("hgrc")) } } +if share_safe { +reqs.extend(requirements::load(Vfs { base: _path })?); +} let repo_config = config.combine_with_repo(_config_files)?; To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10077: rhg: Don’t attempt to read persistent nodemap without .hg/requires opt-in
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10077 AFFECTED FILES rust/hg-core/src/revlog/nodemap_docket.rs CHANGE DETAILS diff --git a/rust/hg-core/src/revlog/nodemap_docket.rs b/rust/hg-core/src/revlog/nodemap_docket.rs --- a/rust/hg-core/src/revlog/nodemap_docket.rs +++ b/rust/hg-core/src/revlog/nodemap_docket.rs @@ -1,4 +1,5 @@ use crate::errors::{HgError, HgResultExt}; +use crate::requirements; use bytes_cast::{unaligned, BytesCast}; use memmap::Mmap; use std::path::{Path, PathBuf}; @@ -38,6 +39,14 @@ repo: , index_path: , ) -> Result, RevlogError> { +if !repo +.requirements() +.contains(requirements::NODEMAP_REQUIREMENT) +{ +// If .hg/requires does not opt it, don’t try to open a nodemap +return Ok(None); +} + let docket_path = index_path.with_extension("n"); let docket_bytes = if let Some(bytes) = repo.store_vfs().read(_path).io_not_found_as_none()? @@ -88,6 +97,8 @@ Err(HgError::corrupted("persistent nodemap too short").into()) } } else { +// Even if .hg/requires opted in, some revlogs are deemed small +// enough to not need a persistent nodemap. Ok(None) } } To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10076: rhg: Check .hg/requires for absence of required features
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Some old repository layouts are not supported. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10076 AFFECTED FILES rust/hg-core/src/requirements.rs rust/hg-core/src/utils.rs CHANGE DETAILS diff --git a/rust/hg-core/src/utils.rs b/rust/hg-core/src/utils.rs --- a/rust/hg-core/src/utils.rs +++ b/rust/hg-core/src/utils.rs @@ -11,6 +11,8 @@ use crate::utils::hg_path::HgPath; use im_rc::ordmap::DiffItem; use im_rc::ordmap::OrdMap; +use std::cell::Cell; +use std::fmt; use std::{io::Write, ops::Deref}; pub mod files; @@ -378,3 +380,43 @@ right } } + +/// Join items of the iterable with the given separator, similar to Python’s +/// `separator.join(iter)`. +/// +/// Formatting the return value consumes the iterator. +/// Formatting it again will produce an empty string. +pub fn join_display( +iter: impl IntoIterator, +separator: impl fmt::Display, +) -> impl fmt::Display { +JoinDisplay { +iter: Cell::new(Some(iter.into_iter())), +separator, +} +} + +struct JoinDisplay { +iter: Cell>, +separator: S, +} + +impl fmt::Display for JoinDisplay +where +I: Iterator, +T: fmt::Display, +S: fmt::Display, +{ +fn fmt(, f: fmt::Formatter<'_>) -> fmt::Result { +if let Some(mut iter) = self.iter.take() { +if let Some(first) = iter.next() { +first.fmt(f)?; +} +for value in iter { +self.separator.fmt(f)?; +value.fmt(f)?; +} +} +Ok(()) +} +} diff --git a/rust/hg-core/src/requirements.rs b/rust/hg-core/src/requirements.rs --- a/rust/hg-core/src/requirements.rs +++ b/rust/hg-core/src/requirements.rs @@ -1,5 +1,6 @@ use crate::errors::{HgError, HgResultExt}; use crate::repo::{Repo, Vfs}; +use crate::utils::join_display; use std::collections::HashSet; fn parse(bytes: &[u8]) -> Result, HgError> { @@ -42,34 +43,48 @@ } pub(crate) fn check(repo: ) -> Result<(), HgError> { -for feature in repo.requirements() { -if !SUPPORTED.contains(_str()) { -// TODO: collect and all unknown features and include them in the -// error message? -return Err(HgError::UnsupportedFeature(format!( -"repository requires feature unknown to this Mercurial: {}", -feature -))); -} +let unknown: Vec<_> = repo +.requirements() +.iter() +.map(String::as_str) +// .filter(|feature| !ALL_SUPPORTED.contains(feature.as_str())) +.filter(|feature| { +!REQUIRED.contains(feature) && !SUPPORTED.contains(feature) +}) +.collect(); +if !unknown.is_empty() { +return Err(HgError::unsupported(format!( +"repository requires feature unknown to this Mercurial: {}", +join_display(, ", ") +))); +} +let missing: Vec<_> = REQUIRED +.iter() +.filter(|&| !repo.requirements().contains(feature)) +.collect(); +if !missing.is_empty() { +return Err(HgError::unsupported(format!( +"repository is missing feature required by this Mercurial: {}", +join_display(, ", ") +))); } Ok(()) } -// TODO: set this to actually-supported features +/// rhg does not support repositories that are *missing* any of these features +const REQUIRED: &[] = &["revlogv1", "store", "fncache", "dotencode"]; + +/// rhg supports repository with or without these const SUPPORTED: &[] = &[ -"dotencode", -"fncache", "generaldelta", -"revlogv1", SHARED_REQUIREMENT, SHARESAFE_REQUIREMENT, SPARSEREVLOG_REQUIREMENT, RELATIVE_SHARED_REQUIREMENT, -"store", // As of this writing everything rhg does is read-only. // When it starts writing to the repository, it’ll need to either keep the // persistent nodemap up to date or remove this entry: -"persistent-nodemap", +NODEMAP_REQUIREMENT, ]; // Copied from mercurial/requirements.py: To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10075: ci: hook network-io tests into the pipeline
joerg.sonnenberger created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This runs the "pip install" tests once for Python 2 and 3 each. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10075 AFFECTED FILES contrib/heptapod-ci.yml CHANGE DETAILS diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml --- a/contrib/heptapod-ci.yml +++ b/contrib/heptapod-ci.yml @@ -8,6 +8,7 @@ PYTHON: python TEST_HGMODULEPOLICY: "allow" HG_CI_IMAGE_TAG: "latest" +TEST_HGTESTS_ALLOW_NETIO: "0" .runtests_template: stage: tests @@ -23,7 +24,7 @@ script: - echo "python used, $PYTHON" - echo "$RUNTEST_ARGS" -- HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" tests/run-tests.py --color=always $RUNTEST_ARGS +- HGTESTS_ALLOW_NETIO="$TEST_HGTESTS_ALLOW_NETIO" HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" tests/run-tests.py --color=always $RUNTEST_ARGS .rust_template: @@ -69,6 +70,7 @@ variables: RUNTEST_ARGS: " --no-rust --blacklist /tmp/check-tests.txt" TEST_HGMODULEPOLICY: "c" +TEST_HGTESTS_ALLOW_NETIO: "1" test-py3: <<: *runtests @@ -76,6 +78,7 @@ RUNTEST_ARGS: " --no-rust --blacklist /tmp/check-tests.txt" PYTHON: python3 TEST_HGMODULEPOLICY: "c" +TEST_HGTESTS_ALLOW_NETIO: "1" test-py2-pure: <<: *runtests To: joerg.sonnenberger, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10074: wireprotov1peer: don't raise internal errors in some cases
valentin.gatienbaron created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Specifically, when the peer is closed in the middle of a batch of rpcs. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10074 AFFECTED FILES mercurial/scmutil.py mercurial/wireprotov1peer.py tests/test-ssh-batch.t CHANGE DETAILS diff --git a/tests/test-ssh-batch.t b/tests/test-ssh-batch.t --- a/tests/test-ssh-batch.t +++ b/tests/test-ssh-batch.t @@ -9,5 +9,7 @@ fails (thus causing the sshpeer to be stopped), the errors from the further lookups don't result in tracebacks. - $ hg pull -r b0 -r nosuchbookmark $(for i in $($TESTDIR/seq.py 1 20); do echo -r b$i; done) -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/$(pwd)/../a |& tail -n 1 - StopIteration + $ hg pull -r b0 -r nosuchbookmark $(for i in $($TESTDIR/seq.py 1 20); do echo -r b$i; done) -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/$(pwd)/../a + pulling from ssh://user@dummy/$TESTTMP/b/../a + abort: unknown revision 'nosuchbookmark' + [255] diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py --- a/mercurial/wireprotov1peer.py +++ b/mercurial/wireprotov1peer.py @@ -310,7 +310,7 @@ if not f.done(): f.set_exception( error.ResponseError( -_(b'unfulfilled batch command response') +_(b'unfulfilled batch command response'), None ) ) @@ -322,16 +322,27 @@ for command, f, batchable, fremote in states: # Grab raw result off the wire and teach the internal future # about it. -remoteresult = next(wireresults) -fremote.set(remoteresult) +try: +remoteresult = next(wireresults) +except StopIteration: +# This can happen in particular because next(batchable) +# in the previous iteration can call peer._abort, which +# may close the peer. +f.set_exception( +error.ResponseError( +_(b'unfulfilled batch command response'), None +) +) +else: +fremote.set(remoteresult) -# And ask the coroutine to decode that value. -try: -result = next(batchable) -except Exception: -pycompat.future_set_exception_info(f, sys.exc_info()[1:]) -else: -f.set_result(result) +# And ask the coroutine to decode that value. +try: +result = next(batchable) +except Exception: +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) +else: +f.set_result(result) @interfaceutil.implementer( diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -201,7 +201,9 @@ msg = inst.args[1] if isinstance(msg, type(u'')): msg = pycompat.sysbytes(msg) -if not isinstance(msg, bytes): +if msg is None: +ui.error(b"\n") +elif not isinstance(msg, bytes): ui.error(b" %r\n" % (msg,)) elif not msg: ui.error(_(b" empty string\n")) To: valentin.gatienbaron, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10073: sshpeer: don't fail forwarding output from closed connections
valentin.gatienbaron created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY The test still shows an internal error, but one that happens further along. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10073 AFFECTED FILES mercurial/sshpeer.py tests/test-ssh-batch.t CHANGE DETAILS diff --git a/tests/test-ssh-batch.t b/tests/test-ssh-batch.t --- a/tests/test-ssh-batch.t +++ b/tests/test-ssh-batch.t @@ -10,4 +10,4 @@ further lookups don't result in tracebacks. $ hg pull -r b0 -r nosuchbookmark $(for i in $($TESTDIR/seq.py 1 20); do echo -r b$i; done) -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/$(pwd)/../a |& tail -n 1 - ValueError: I/O operation on closed file + StopIteration diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -40,7 +40,7 @@ """display all data currently available on pipe as remote output. This is non blocking.""" -if pipe: +if pipe and not pipe.closed: s = procutil.readpipe(pipe) if s: display = ui.warn if warn else ui.status To: valentin.gatienbaron, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10072: test: show internal exception with batchable rpcs over ssh
valentin.gatienbaron created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10072 AFFECTED FILES tests/test-ssh-batch.t CHANGE DETAILS diff --git a/tests/test-ssh-batch.t b/tests/test-ssh-batch.t new file mode 100644 --- /dev/null +++ b/tests/test-ssh-batch.t @@ -0,0 +1,13 @@ + $ hg init a + $ cd a + $ touch a; hg commit -qAm_ + $ hg bookmark $(for i in $($TESTDIR/seq.py 0 20); do echo b$i; done) + $ hg clone . ../b -q + $ cd ../b + +Checking that when lookup multiple bookmarks in one go, if one of them +fails (thus causing the sshpeer to be stopped), the errors from the +further lookups don't result in tracebacks. + + $ hg pull -r b0 -r nosuchbookmark $(for i in $($TESTDIR/seq.py 1 20); do echo -r b$i; done) -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/$(pwd)/../a |& tail -n 1 + ValueError: I/O operation on closed file To: valentin.gatienbaron, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10071: copies-rust: add a macro-based unit-testing framework
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY `compare_values`, `merge_copies_dict`, and `CombineChangesetCopies` are APIs whose signatures involve non-trivial types. Calling them directly in unit tests would involve a lot of verbose setup code that obscures the meaningful parts of a given test case. This adds a macro-based test-harness with pseudo-syntax to tersely create arguments and expected return values in the correct types. For now there is only one (not particularly meaningful) test case per tested function, just to exercize the macros. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10071 AFFECTED FILES rust/hg-core/src/copy_tracing.rs rust/hg-core/src/copy_tracing/tests.rs rust/hg-core/src/copy_tracing/tests_support.rs CHANGE DETAILS diff --git a/rust/hg-core/src/copy_tracing/tests_support.rs b/rust/hg-core/src/copy_tracing/tests_support.rs new file mode 100644 --- /dev/null +++ b/rust/hg-core/src/copy_tracing/tests_support.rs @@ -0,0 +1,199 @@ +//! Supporting macros for `tests.rs` in the same directory. +//! See comments there for usage. + +/// Python-like set literal +macro_rules! set { +( +$Type: ty { +$( $value: expr ),* $(,)? +} +) => {{ +#[allow(unused_mut)] +let mut set = <$Type>::new(); +$( set.insert($value); )* +set +}} +} + +/// `{key => value}` map literal +macro_rules! map { +( +$Type: ty { +$( $key: expr => $value: expr ),* $(,)? +} +) => {{ +#[allow(unused_mut)] +let mut set = <$Type>::new(); +$( set.insert($key, $value); )* +set +}} +} + +macro_rules! copy_source { +($rev: expr, $path: expr, $overwritten: tt) => { +CopySource { +rev: $rev, +path: $path, +overwritten: set!(OrdSet $overwritten), +} +}; +} + +macro_rules! compare_value { +( +$merge_revision: expr, +$merge_case_for_dest: ident, +($min_rev: expr, $min_path: expr, $min_overwrite: tt), +($maj_rev: expr, $maj_path: expr, $maj_overwrite: tt) $(,)? +) => { +compare_value( +$merge_revision, +|| $merge_case_for_dest, +_source!($min_rev, $min_path, $min_overwrite), +_source!($maj_rev, $maj_path, $maj_overwrite), +) +}; +} + +macro_rules! tokenized_path_copies { +( +$path_map: ident, {$( +$dest: expr => ( +$src_rev: expr, +$src_path: expr, +$src_overwrite: tt +) +),*} +$(,)* +) => { +map!(InternalPathCopies {$( +$path_map.tokenize(HgPath::new($dest)) => +copy_source!( +$src_rev, +Option::map($src_path, |p: | { +$path_map.tokenize(HgPath::new(p)) +}), +$src_overwrite +) +)*}) +} +} + +macro_rules! merge_case_callback { +( +$( $merge_path: expr => $merge_case: ident ),* +$(,)? +) => { +#[allow(unused)] +|merge_path| -> MergeCase { +$( +if (merge_path == HgPath::new($merge_path)) { +return $merge_case +} +)* +MergeCase::Normal +} +}; +} + +macro_rules! merge_copies_dict { +( +$current_merge: expr, +$minor_copies: tt, +$major_copies: tt, +$get_merge_case: tt $(,)? +) => { +{ +#[allow(unused_mut)] +let mut map = TwoWayPathMap::default(); +let minor = tokenized_path_copies!(map, $minor_copies); +let major = tokenized_path_copies!(map, $major_copies); +merge_copies_dict( +, $current_merge, minor, major, +merge_case_callback! $get_merge_case, +) +.into_iter() +.map(|(token, source)| { +( +map.untokenize(token).to_string(), +( +source.rev, +source.path.map(|t| map.untokenize(t).to_string()), +source.overwritten.into_iter().collect(), +), +) +}) +.collect::>() +} +}; +} + +macro_rules! internal_path_copies { +( +$( +$dest: expr => ( +$src_rev: expr, +$src_path: expr, +$src_overwrite: tt $(,)? +) +),* +$(,)* +) => { +map!(OrdMap<_, _> {$( +String::from($dest) => ( +$src_rev, +$src_path, +set!(OrdSet $src_overwrite) +) +),*}) +
D10070: copies-rust: pass closures and iterators instead of ``
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY … to some functions that only use one method. This will makes it easier to unit-test them. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10070 AFFECTED FILES rust/hg-core/src/copy_tracing.rs CHANGE DETAILS diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs --- a/rust/hg-core/src/copy_tracing.rs +++ b/rust/hg-core/src/copy_tracing.rs @@ -387,6 +387,21 @@ p2: Revision, changes: ChangedFiles<'_>, ) { +self.add_revision_inner(rev, p1, p2, changes.iter_actions(), |path| { +changes.get_merge_case(path) +}) +} + +/// Separated out from `add_revsion` so that unit tests can call this +/// without synthetizing a `ChangedFiles` in binary format. +fn add_revision_inner<'a>( + self, +rev: Revision, +p1: Revision, +p2: Revision, +copy_actions: impl Iterator>, +get_merge_case: impl Fn() -> MergeCase + Copy, +) { // Retrieve data computed in a previous iteration let p1_copies = match p1 { NULL_REVISION => None, @@ -409,7 +424,7 @@ self.path_map, p1_copies, p2_copies, -, +copy_actions, rev, ); let copies = match (p1_copies, p2_copies) { @@ -421,7 +436,7 @@ rev, p2_copies, p1_copies, -, +get_merge_case, )), }; if let Some(c) = copies { @@ -476,11 +491,11 @@ /// Combine ChangedFiles with some existing PathCopies information and return /// the result -fn chain_changes( +fn chain_changes<'a>( path_map: TwoWayPathMap, base_p1_copies: Option, base_p2_copies: Option, -changes: , +copy_actions: impl Iterator>, current_rev: Revision, ) -> (Option, Option) { // Fast path the "nothing to do" case. @@ -490,7 +505,7 @@ let mut p1_copies = base_p1_copies.clone(); let mut p2_copies = base_p2_copies.clone(); -for action in changes.iter_actions() { +for action in copy_actions { match action { Action::CopiedFromP1(path_dest, path_source) => { match p1_copies { @@ -613,16 +628,14 @@ current_merge: Revision, minor: InternalPathCopies, major: InternalPathCopies, -changes: , +get_merge_case: impl Fn() -> MergeCase + Copy, ) -> InternalPathCopies { use crate::utils::{ordmap_union_with_merge, MergeResult}; ordmap_union_with_merge(minor, major, |, src_minor, src_major| { let (pick, overwrite) = compare_value( -path_map, current_merge, -changes, -dest, +|| get_merge_case(path_map.untokenize(dest)), src_minor, src_major, ); @@ -649,6 +662,7 @@ /// represent the side that should prevail when merging two /// InternalPathCopies +#[derive(Debug, PartialEq)] enum MergePick { /// The "major" (p1) side prevails Major, @@ -661,10 +675,8 @@ /// decide which side prevails in case of conflicting values #[allow(clippy::if_same_then_else)] fn compare_value( -path_map: , current_merge: Revision, -changes: , -dest: PathToken, +merge_case_for_dest: impl Fn() -> MergeCase, src_minor: , src_major: , ) -> (MergePick, bool) { @@ -693,8 +705,7 @@ } } else { debug_assert!(src_major.rev != src_major.rev); -let dest_path = path_map.untokenize(dest); -let action = changes.get_merge_case(dest_path); +let action = merge_case_for_dest(); if src_minor.path.is_some() && src_major.path.is_none() && action == MergeCase::Salvaged To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10069: copies-rust: pass `PathToken` around by value
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY It’s just a `usize`. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10069 AFFECTED FILES rust/hg-core/src/copy_tracing.rs CHANGE DETAILS diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs --- a/rust/hg-core/src/copy_tracing.rs +++ b/rust/hg-core/src/copy_tracing.rs @@ -617,7 +617,7 @@ ) -> InternalPathCopies { use crate::utils::{ordmap_union_with_merge, MergeResult}; -ordmap_union_with_merge(minor, major, |dest, src_minor, src_major| { +ordmap_union_with_merge(minor, major, |, src_minor, src_major| { let (pick, overwrite) = compare_value( path_map, current_merge, @@ -664,7 +664,7 @@ path_map: , current_merge: Revision, changes: , -dest: , +dest: PathToken, src_minor: , src_major: , ) -> (MergePick, bool) { @@ -693,7 +693,7 @@ } } else { debug_assert!(src_major.rev != src_major.rev); -let dest_path = path_map.untokenize(*dest); +let dest_path = path_map.untokenize(dest); let action = changes.get_merge_case(dest_path); if src_minor.path.is_some() && src_major.path.is_none() To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D10068: copies-rust: rewrite ChangedFiles binary parsing
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY by using the new from-bytes-safe crate and a custom struct that encodes the expected data structure. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10068 AFFECTED FILES rust/hg-core/src/copy_tracing.rs CHANGE DETAILS diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs --- a/rust/hg-core/src/copy_tracing.rs +++ b/rust/hg-core/src/copy_tracing.rs @@ -3,13 +3,13 @@ use crate::Revision; use crate::NULL_REVISION; +use bytes_cast::{unaligned, BytesCast}; use im_rc::ordmap::Entry; use im_rc::ordmap::OrdMap; use im_rc::OrdSet; use std::cmp::Ordering; use std::collections::HashMap; -use std::convert::TryInto; pub type PathCopies = HashMap; @@ -110,18 +110,6 @@ /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation) type InternalPathCopies = OrdMap; -/// represent the files affected by a changesets -/// -/// This hold a subset of mercurial.metadata.ChangingFiles as we do not need -/// all the data categories tracked by it. -/// This hold a subset of mercurial.metadata.ChangingFiles as we do not need -/// all the data categories tracked by it. -pub struct ChangedFiles<'a> { -nb_items: u32, -index: &'a [u8], -data: &'a [u8], -} - /// Represent active changes that affect the copy tracing. enum Action<'a> { /// The parent ? children edge is removing a file @@ -148,9 +136,6 @@ Normal, } -type FileChange<'a> = (u8, &'a HgPath, &'a HgPath); - -const EMPTY: &[u8] = b""; const COPY_MASK: u8 = 3; const P1_COPY: u8 = 2; const P2_COPY: u8 = 3; @@ -159,141 +144,94 @@ const MERGED: u8 = 8; const SALVAGED: u8 = 16; -impl<'a> ChangedFiles<'a> { -const INDEX_START: usize = 4; -const ENTRY_SIZE: u32 = 9; -const FILENAME_START: u32 = 1; -const COPY_SOURCE_START: u32 = 5; +#[derive(BytesCast)] +#[repr(C)] +struct ChangedFilesIndexEntry { +flags: u8, -pub fn new(data: &'a [u8]) -> Self { -assert!( -data.len() >= 4, -"data size ({}) is too small to contain the header (4)", -data.len() -); -let nb_items_raw: [u8; 4] = ([0..=3]) -.try_into() -.expect("failed to turn 4 bytes into 4 bytes"); -let nb_items = u32::from_be_bytes(nb_items_raw); +/// Only the end position is stored. The start is at the end of the +/// previous entry. +destination_path_end_position: unaligned::U32Be, -let index_size = (nb_items * Self::ENTRY_SIZE) as usize; -let index_end = Self::INDEX_START + index_size; +source_index_entry_position: unaligned::U32Be, +} + +fn _static_assert_size_of() { +let _ = std::mem::transmute::; +} -assert!( -data.len() >= index_end, -"data size ({}) is too small to fit the index_data ({})", -data.len(), -index_end -); +/// Represents the files affected by a changeset. +/// +/// This hold a subset of `mercurial.metadata.ChangingFiles` as we do not need +/// all the data categories tracked by it. +pub struct ChangedFiles<'a> { +index: &'a [ChangedFilesIndexEntry], +paths: &'a [u8], +} -let ret = ChangedFiles { -nb_items, -index: [Self::INDEX_START..index_end], -data: [index_end..], -}; -let max_data = ret.filename_end(nb_items - 1) as usize; -assert!( -ret.data.len() >= max_data, -"data size ({}) is too small to fit all data ({})", -data.len(), -index_end + max_data -); -ret +impl<'a> ChangedFiles<'a> { +pub fn new(data: &'a [u8]) -> Self { +let (header, rest) = unaligned::U32Be::from_bytes(data).unwrap(); +let nb_index_entries = header.get() as usize; +let (index, paths) = +ChangedFilesIndexEntry::slice_from_bytes(rest, nb_index_entries) +.unwrap(); +Self { index, paths } } pub fn new_empty() -> Self { ChangedFiles { -nb_items: 0, -index: EMPTY, -data: EMPTY, +index: &[], +paths: &[], } } -/// internal function to return an individual entry at a given index -fn entry(&'a self, idx: u32) -> FileChange<'a> { -if idx >= self.nb_items { -panic!( -"index for entry is higher that the number of file {} >= {}", -idx, self.nb_items -) -} -let flags = self.flags(idx); -let filename = self.filename(idx); -let copy_idx = self.copy_idx(idx); -let copy_source = self.filename(copy_idx); -(flags, filename, copy_source) -} - -/// internal function to return the filename of the entry at a given index -fn filename(, idx:
D10067: tests: accept output changes by 33350debb480
khanchi97 created this revision. Herald added a reviewer: durin42. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH stable REVISION DETAIL https://phab.mercurial-scm.org/D10067 AFFECTED FILES tests/test-diff-upgrade.t tests/test-diffstat.t tests/test-git-export.t tests/test-log-linerange.t CHANGE DETAILS diff --git a/tests/test-log-linerange.t b/tests/test-log-linerange.t --- a/tests/test-log-linerange.t +++ b/tests/test-log-linerange.t @@ -1114,7 +1114,7 @@ diff --git a/dir/binary b/dir/binary new file mode 100644 - index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c2e1fbed209fe919b3f189a6a31950e9adf61e45 + index ..c2e1fbed209fe919b3f189a6a31950e9adf61e45 GIT binary patch literal 17 Wc$_QA$SmdpqC~Ew%)G>+N(KNlNClYy diff --git a/tests/test-git-export.t b/tests/test-git-export.t --- a/tests/test-git-export.t +++ b/tests/test-git-export.t @@ -346,7 +346,7 @@ $ cat b.diff diff --git a/binfile.bin b/binfile.bin new file mode 100644 - index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..37ba3d1c6f17137d9c5f5776fa040caf5fe73ff9 + index ..37ba3d1c6f17137d9c5f5776fa040caf5fe73ff9 GIT binary patch literal 593 zc$@)I0https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@46547: 25 new changesets (3 on stable)
25 new changesets (3 on stable) in mercurial: https://www.mercurial-scm.org/repo/hg/rev/359bdd8fc60a changeset: 46523:359bdd8fc60a parent: 46520:c82d6363bc9e user:Martin von Zweigbergk date:Tue Feb 23 12:26:52 2021 -0800 summary: build: make version from .hg_archival.txt consistent with that from .hg/ https://www.mercurial-scm.org/repo/hg/rev/e3f23814bac7 changeset: 46524:e3f23814bac7 user:Martin von Zweigbergk date:Tue Feb 23 12:29:41 2021 -0800 summary: windows: fix parsing of version number to match format from D9955 https://www.mercurial-scm.org/repo/hg/rev/636853347e14 changeset: 46525:636853347e14 user:Pulkit Goyal <7895pul...@gmail.com> date:Mon Feb 15 15:13:20 2021 +0530 summary: upgrade: write nodemap for manifests too https://www.mercurial-scm.org/repo/hg/rev/67b5fafd3a46 changeset: 46526:67b5fafd3a46 user:Pulkit Goyal <7895pul...@gmail.com> date:Wed Feb 10 17:08:34 2021 +0530 summary: upgrade: speed up when we have only nodemap to downgrade https://www.mercurial-scm.org/repo/hg/rev/018d622e814d changeset: 46527:018d622e814d user:Pierre-Yves David date:Thu Dec 10 14:25:36 2020 +0100 summary: test-copies: reinstall initial identical (empty) files for chained copied https://www.mercurial-scm.org/repo/hg/rev/df44bac9413d changeset: 46528:df44bac9413d branch: stable parent: 46522:6c8faeea6652 user:Sushil khanchi date:Tue Feb 16 15:37:19 2021 +0530 summary: tests: add a test to demonstrate a bug in `hg diff --git` (issue6486) https://www.mercurial-scm.org/repo/hg/rev/33350debb480 changeset: 46529:33350debb480 branch: stable user:Sushil khanchi date:Tue Feb 16 15:44:51 2021 +0530 summary: patch: make diff --git to differentiate b/w file is empty or doesn't exists https://www.mercurial-scm.org/repo/hg/rev/b994db7c4d1e changeset: 46530:b994db7c4d1e branch: stable user:Raphaël Gomès date:Fri Feb 19 17:52:04 2021 +0100 summary: narrow: fix flaky behavior described in issue6150 https://www.mercurial-scm.org/repo/hg/rev/d46885119f90 changeset: 46531:d46885119f90 parent: 46527:018d622e814d user:Pierre-Yves David date:Mon Feb 22 18:48:45 2021 +0100 summary: test-copies: don't use empty file for "same content" cases https://www.mercurial-scm.org/repo/hg/rev/c9f502721783 changeset: 46532:c9f502721783 user:Pierre-Yves David date:Tue Feb 16 05:19:23 2021 +0100 summary: test-copies: use intermediate variable some commit descriptions https://www.mercurial-scm.org/repo/hg/rev/e20977208924 changeset: 46533:e20977208924 user:Pierre-Yves David date:Tue Feb 16 05:26:46 2021 +0100 summary: test-copies: improve description of the A+B case https://www.mercurial-scm.org/repo/hg/rev/979838adc46b changeset: 46534:979838adc46b user:Pierre-Yves David date:Tue Feb 16 05:29:04 2021 +0100 summary: test-copies: improve description of the B+C case https://www.mercurial-scm.org/repo/hg/rev/9a58f9eed303 changeset: 46535:9a58f9eed303 user:Pierre-Yves David date:Tue Feb 16 05:32:20 2021 +0100 summary: test-copies: improve description of the B+D case https://www.mercurial-scm.org/repo/hg/rev/19f490690880 changeset: 46536:19f490690880 user:Pierre-Yves David date:Tue Feb 16 05:35:18 2021 +0100 summary: test-copies: improve description of the A+E case https://www.mercurial-scm.org/repo/hg/rev/1e96fdcc8bc1 changeset: 46537:1e96fdcc8bc1 user:Pierre-Yves David date:Tue Feb 16 05:39:22 2021 +0100 summary: test-copies: improve description of the D+G case https://www.mercurial-scm.org/repo/hg/rev/2f99dedf96b1 changeset: 46538:2f99dedf96b1 user:Pierre-Yves David date:Tue Feb 16 05:46:32 2021 +0100 summary: test-copies: improve description of the G+F case https://www.mercurial-scm.org/repo/hg/rev/a1a06dca6941 changeset: 46539:a1a06dca6941 user:Pierre-Yves David date:Tue Feb 16 05:54:55 2021 +0100 summary: test-copies: improve description of the G+C case https://www.mercurial-scm.org/repo/hg/rev/311a18777f45 changeset: 46540:311a18777f45 user:Pierre-Yves David date:Tue Feb 16 05:58:22 2021 +0100 summary: test-copies: improve description of the B+C "revert/restore" case https://www.mercurial-scm.org/repo/hg/rev/60c52bdb1784 changeset: 46541:60c52bdb1784 user:Pierre-Yves David date:Tue Feb 16 06:02:09 2021 +0100 summary: test-copies: improve description of the C+H case https://www.mercurial-scm.org/repo/hg/rev/ff5c8c50 changeset: 46542:ff5c8c50 user:Pierre-Yves David date:Thu Feb 18 12:45:16 2021 +0100 summary: test-copies: improve description of the B+F case https://www.mercurial-scm.org/repo/hg/rev/f01696d45d1e changeset: