D6771: py3: use pycompat.maplist() in chgserver
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY test-chg.t almost passes on py3 after this patch. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6771 AFFECTED FILES mercurial/chgserver.py CHANGE DETAILS diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -172,7 +172,7 @@ except OSError: # could be ENOENT, EPERM etc. not fatal in any case pass -return _hashlist(map(trystat, paths))[:12] +return _hashlist(pycompat.maplist(trystat, paths))[:12] class hashstate(object): """a structure storing confighash, mtimehash, paths used for mtimehash""" To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@42811: 2 new changesets (2 on stable)
2 new changesets (2 on stable) in mercurial: https://www.mercurial-scm.org/repo/hg/rev/cf9dbc7377de changeset: 42810:cf9dbc7377de branch: stable user:Navaneeth Suresh date:Sun Aug 18 02:47:32 2019 +0530 summary: tests: add test to demonstrate issue6159 https://www.mercurial-scm.org/repo/hg/rev/3332bde53714 changeset: 42811:3332bde53714 branch: stable tag: tip user:Navaneeth Suresh date:Sat Aug 17 01:49:28 2019 +0530 summary: exchange: abort on pushing bookmarks pointing to secret changesets (issue6159) -- Repository URL: https://www.mercurial-scm.org/repo/hg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6770: rust: fix warnings about trait objects without dyn being deprecated
valentin.gatienbaron created this revision. Herald added subscribers: mercurial-devel, kevincox, durin42. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6770 AFFECTED FILES rust/hg-cpython/src/ref_sharing.rs CHANGE DETAILS diff --git a/rust/hg-cpython/src/ref_sharing.rs b/rust/hg-cpython/src/ref_sharing.rs --- a/rust/hg-cpython/src/ref_sharing.rs +++ b/rust/hg-cpython/src/ref_sharing.rs @@ -345,7 +345,7 @@ $name, $leaked, Box< -Iterator +dyn Iterator + Send, >, $success_func, @@ -367,7 +367,7 @@ py_shared_iterator_impl!( $name, $leaked, -Box + Send>, +Box + Send>, $success_func, $success_type ); To: valentin.gatienbaron, #hg-reviewers Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6765: rustfilepatterns: shorter code for concatenating slices
valentin.gatienbaron added inline comments. valentin.gatienbaron marked 2 inline comments as done. INLINE COMMENTS > kevincox wrote in filepatterns.rs:161 > For the other ones I think the problem is that it gets the element type from > the first element as ``. I think a better approach then creating the > wrapper function is doing `[vec.as_slice(), b"foobar"].concat()`. I see. So the reason why the code above was accepted is because `pattern` was already a `&[u8]`, and not a ``. Thanks! REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6765/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6765 To: valentin.gatienbaron, #hg-reviewers, Alphare, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6765: rustfilepatterns: shorter code for concatenating slices
valentin.gatienbaron updated this revision to Diff 16330. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6765?vs=16328=16330 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6765/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6765 AFFECTED FILES rust/hg-core/src/filepatterns.rs CHANGE DETAILS diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -158,26 +158,20 @@ if pattern[0] == b'^' { return pattern.to_owned(); } -let mut res = b".*".to_vec(); -res.extend(pattern); -res +[b".*", pattern].concat() } PatternSyntax::Path | PatternSyntax::RelPath => { if pattern == b"." { return vec![]; } -let mut pattern = escape_pattern(pattern); -pattern.extend(b"(?:/|$)"); -pattern +[escape_pattern(pattern).as_slice(), b"(?:/|$)"].concat() } PatternSyntax::RootFiles => { let mut res = if pattern == b"." { vec![] } else { // Pattern is a directory name. -let mut as_vec: Vec = escape_pattern(pattern); -as_vec.push(b'/'); -as_vec +[escape_pattern(pattern).as_slice(), b"/"].concat() }; // Anything after the pattern must be a non-directory. @@ -185,24 +179,16 @@ res } PatternSyntax::RelGlob => { -let mut res: Vec = vec![]; let glob_re = glob_to_re(pattern); if let Some(rest) = glob_re.drop_prefix(b"[^/]*") { -res.extend(b".*"); -res.extend(rest); +[b".*", rest, globsuffix].concat() } else { -res.extend(b"(?:|.*/)"); -res.extend(glob_re); +[b"(?:|.*/)", glob_re.as_slice(), globsuffix].concat() } -res.extend(globsuffix.iter()); -res } PatternSyntax::Glob | PatternSyntax::RootGlob => { -let mut res: Vec = vec![]; -res.extend(glob_to_re(pattern)); -res.extend(globsuffix.iter()); -res +[glob_to_re(pattern).as_slice(), globsuffix].concat() } } } To: valentin.gatienbaron, #hg-reviewers, Alphare, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6765: rustfilepatterns: shorter code for concatenating slices
kevincox added inline comments. INLINE COMMENTS > valentin.gatienbaron wrote in filepatterns.rs:161 > Indeed, although it took a compiler upgrade. > I don't really understand why the compiler accepts the change here but not in > the other places. It seems a bit random to remove the borrow only here. What > do you think about the next commit? It would remove the `&_[..]` more > predictably. For the other ones I think the problem is that it gets the element type from the first element as ``. I think a better approach then creating the wrapper function is doing `[vec.as_slice(), b"foobar"].concat()`. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6765/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6765 To: valentin.gatienbaron, #hg-reviewers, Alphare, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6765: rustfilepatterns: shorter code for concatenating slices
valentin.gatienbaron added inline comments. INLINE COMMENTS > kevincox wrote in filepatterns.rs:161 > I don't think you need the `&_[..]`. https://rust.godbolt.org/z/Wo-vza Indeed, although it took a compiler upgrade. I don't really understand why the compiler accepts the change here but not in the other places. It seems a bit random to remove the borrow only here. What do you think about the next commit? It would remove the `&_[..]` more predictably. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6765/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6765 To: valentin.gatienbaron, #hg-reviewers, Alphare, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6764: match: simplify the regexps created for glob patterns
valentin.gatienbaron updated this revision to Diff 16327. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6764?vs=16320=16327 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6764/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6764 AFFECTED FILES mercurial/match.py rust/hg-core/src/filepatterns.rs tests/test-hgignore.t tests/test-walk.t CHANGE DETAILS diff --git a/tests/test-walk.t b/tests/test-walk.t --- a/tests/test-walk.t +++ b/tests/test-walk.t @@ -100,7 +100,7 @@ f mammals/skunk skunk $ hg debugwalk -v -I 'relglob:*k' * matcher: - + f beans/black../beans/black f fenugreek ../fenugreek f mammals/skunk skunk @@ -108,7 +108,7 @@ * matcher: , -m2=> +m2=> f mammals/skunk skunk $ hg debugwalk -v -I 're:.*k$' * matcher: diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t --- a/tests/test-hgignore.t +++ b/tests/test-hgignore.t @@ -177,7 +177,7 @@ ? a.c ? syntax $ hg debugignore - + $ cd .. $ echo > .hg/testhgignorerel @@ -224,7 +224,7 @@ A b.o $ hg debugignore - + $ hg debugignore b.o b.o is ignored diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -184,14 +184,22 @@ res.extend(b"[^/]+$"); res } +PatternSyntax::RelGlob => { +let mut res: Vec = vec![]; +let glob_re = glob_to_re(pattern); +if let Some(rest) = glob_re.drop_prefix(b"[^/]*") { +res.extend(b".*"); +res.extend(rest); +} else { +res.extend(b"(?:|.*/)"); +res.extend(glob_re); +} +res.extend(globsuffix.iter()); +res +} PatternSyntax::Glob -| PatternSyntax::RelGlob | PatternSyntax::RootGlob => { let mut res: Vec = vec![]; -if syntax == PatternSyntax::RelGlob { -res.extend(b"(?:|.*/)"); -} - res.extend(glob_to_re(pattern)); res.extend(globsuffix.iter()); res diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -1223,7 +1223,12 @@ # Anything after the pattern must be a non-directory. return escaped + '[^/]+$' if kind == 'relglob': -return '(?:|.*/)' + _globre(pat) + globsuffix +globre = _globre(pat) +if globre.startswith('[^/]*'): +# When pat has the form *XYZ (common), make the returned regex more +# legible by returning the regex for **XYZ instead of **/*XYZ. +return '.*' + globre[len('[^/]*'):] + globsuffix +return '(?:|.*/)' + globre + globsuffix if kind == 'relre': if pat.startswith('^'): return pat To: valentin.gatienbaron, #hg-reviewers Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6769: another way of implementing the parent
valentin.gatienbaron created this revision. Herald added subscribers: mercurial-devel, kevincox, durin42. Herald added a reviewer: hg-reviewers. REVISION SUMMARY I would drop this or fold it into the parent depending on reviewers' opinion. The problem is that byte literals can converted to slices implicitely, and concat can work on slices and other things, and it's too much for the typer to try to do both at the time. Providing a monomorphic version of the concat method avoids having to write [..]. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6769 AFFECTED FILES rust/hg-core/src/filepatterns.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 @@ -37,6 +37,10 @@ } } +pub fn concat(slices: &[&[u8]]) -> Vec { +slices.concat() +} + pub trait SliceExt { fn trim_end() -> fn trim_start() -> diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -8,7 +8,7 @@ //! Handling of Mercurial-specific patterns. use crate::{ -utils::{files::get_path_from_bytes, SliceExt}, +utils::{concat, files::get_path_from_bytes, SliceExt}, LineNumber, PatternError, PatternFileError, }; use lazy_static::lazy_static; @@ -158,20 +158,20 @@ if pattern[0] == b'^' { return pattern.to_owned(); } -[".*"[..], pattern].concat() +concat(&[b".*", pattern]) } PatternSyntax::Path | PatternSyntax::RelPath => { if pattern == b"." { return vec![]; } -[_pattern(pattern), "(?:/|$)"[..]].concat() +concat(&[_pattern(pattern), b"(?:/|$)"]) } PatternSyntax::RootFiles => { let mut res = if pattern == b"." { vec![] } else { // Pattern is a directory name. -[_pattern(pattern), "/"[..]].concat() +concat(&[_pattern(pattern), b"/"]) }; // Anything after the pattern must be a non-directory. @@ -181,14 +181,14 @@ PatternSyntax::RelGlob => { let glob_re = glob_to_re(pattern); if let Some(rest) = glob_re.drop_prefix(b"[^/]*") { -[".*"[..], rest, globsuffix].concat() +concat(&[b".*", rest, globsuffix]) } else { -["(?:|.*/)"[..], _re, globsuffix].concat() +concat(&[b"(?:|.*/)", _re, globsuffix]) } } PatternSyntax::Glob | PatternSyntax::RootGlob => { -[_to_re(pattern), globsuffix].concat() +concat(&[_to_re(pattern), globsuffix]) } } } To: valentin.gatienbaron, #hg-reviewers Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6765: rustfilepatterns: shorter code for concatenating slices
valentin.gatienbaron updated this revision to Diff 16328. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6765?vs=16321=16328 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6765/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6765 AFFECTED FILES rust/hg-core/src/filepatterns.rs CHANGE DETAILS diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -158,26 +158,20 @@ if pattern[0] == b'^' { return pattern.to_owned(); } -let mut res = b".*".to_vec(); -res.extend(pattern); -res +[".*"[..], pattern].concat() } PatternSyntax::Path | PatternSyntax::RelPath => { if pattern == b"." { return vec![]; } -let mut pattern = escape_pattern(pattern); -pattern.extend(b"(?:/|$)"); -pattern +[_pattern(pattern), "(?:/|$)"[..]].concat() } PatternSyntax::RootFiles => { let mut res = if pattern == b"." { vec![] } else { // Pattern is a directory name. -let mut as_vec: Vec = escape_pattern(pattern); -as_vec.push(b'/'); -as_vec +[_pattern(pattern), "/"[..]].concat() }; // Anything after the pattern must be a non-directory. @@ -185,24 +179,16 @@ res } PatternSyntax::RelGlob => { -let mut res: Vec = vec![]; let glob_re = glob_to_re(pattern); if let Some(rest) = glob_re.drop_prefix(b"[^/]*") { -res.extend(b".*"); -res.extend(rest); +[".*"[..], rest, globsuffix].concat() } else { -res.extend(b"(?:|.*/)"); -res.extend(glob_re); +["(?:|.*/)"[..], _re, globsuffix].concat() } -res.extend(globsuffix.iter()); -res } PatternSyntax::Glob | PatternSyntax::RootGlob => { -let mut res: Vec = vec![]; -res.extend(glob_to_re(pattern)); -res.extend(globsuffix.iter()); -res +[_to_re(pattern), globsuffix].concat() } } } To: valentin.gatienbaron, #hg-reviewers, Alphare, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6766: rustfilepatterns: refactor the pattern of removing a prefix from a &[u8]
valentin.gatienbaron updated this revision to Diff 16326. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6766?vs=16319=16326 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6766/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6766 AFFECTED FILES rust/hg-core/src/filepatterns.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 @@ -41,6 +41,7 @@ fn trim_end() -> fn trim_start() -> fn trim() -> +fn drop_prefix(, needle: ) -> Option<>; } fn is_not_whitespace(c: ) -> bool { @@ -81,4 +82,12 @@ fn trim() -> &[u8] { self.trim_start().trim_end() } + +fn drop_prefix(, needle: ) -> Option<> { +if self.starts_with(needle) { +Some([needle.len()..]) +} else { +None +} +} } diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -59,8 +59,8 @@ match c { b'*' => { for (source, repl) in GLOB_REPLACEMENTS { -if input.starts_with(source) { -input = [source.len()..]; +if let Some(rest) = input.drop_prefix(source) { +input = rest; res.extend(*repl); break; } @@ -268,8 +268,8 @@ continue; } -if line.starts_with(b"syntax:") { -let syntax = line[b"syntax:".len()..].trim(); +if let Some(syntax) = line.drop_prefix(b"syntax:") { +let syntax = syntax.trim(); if let Some(rel_syntax) = SYNTAXES.get(syntax) { current_syntax = rel_syntax; @@ -282,13 +282,14 @@ let mut line_syntax: &[u8] = _syntax; for (s, rels) in SYNTAXES.iter() { -if line.starts_with(rels) { +if let Some(rest) = line.drop_prefix(rels) { line_syntax = rels; -line = [rels.len()..]; +line = rest; break; -} else if line.starts_with(&[s, b":".as_ref()].concat()) { +} +if let Some(rest) = line.drop_prefix(&[s, ":"[..]].concat()) { line_syntax = rels; -line = [s.len() + 1..]; +line = rest; break; } } To: valentin.gatienbaron, #hg-reviewers, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6766: rustfilepatterns: refactor the pattern of removing a prefix from a &[u8]
kevincox added inline comments. kevincox accepted this revision. INLINE COMMENTS > utils.rs:44 > fn trim() -> > +fn chop_prefix(, needle:) -> Option<>; > } I have a small preference for `drop_prefix`. > utils.rs:44 > fn trim() -> > +fn chop_prefix(, needle:) -> Option<>; > } Put a space in `needle: ` > utils.rs:86 > + > +fn chop_prefix(, needle:) -> Option<> { > +if self.starts_with(needle) { Put a space in needle: REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6766/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6766 To: valentin.gatienbaron, #hg-reviewers, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6765: rustfilepatterns: shorter code for concatenating slices
kevincox added inline comments. kevincox accepted this revision. INLINE COMMENTS > filepatterns.rs:161 > } > -let mut res = b".*".to_vec(); > -res.extend(pattern); > -res > +[".*"[..], pattern].concat() > } I don't think you need the `&_[..]`. https://rust.godbolt.org/z/Wo-vza REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6765/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6765 To: valentin.gatienbaron, #hg-reviewers, Alphare, kevincox Cc: durin42, kevincox, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel