- Use '/' key to quickly access this field.
- Enter a name of repository, or repository group for quick search.
- Prefix query to allow special search:
user:admin, to search for usernames, always global
user_group:devops, to search for user groups, always global
pr:303, to search for pull request number, title, or description, always global
commit:efced4, to search for commits, scoped to repositories or groups
file:models.py, to search for file paths, scoped to repositories or groups
For advanced full text search visit: repository search
rhg: Don’t compare ambiguous files one byte at a time...
rhg: Don’t compare ambiguous files one byte at a time
Even though the use of `BufReader` reduces the number of syscalls to read
the file from disk, `.bytes()` yields a separate `Result` for every byte.
Creating those results and dispatching on them is most likely costly.
Instead, this commit opts for simplicity by reading the entire file into memory
and comparing a single pair of byte strings. Note that memory already needs to
contain the entire previous contents of the file, as read from the filelog.
So with an extremely large file this doubles memory use but does not make it
grow by orders of magnitude.
At first I wrote code that still avoids reading the entire file into memory
and compares one buffer at a time with `BufReader`. Find this code below for
posterity. However its correctness is subtle. I ended up preferring the
simplicity of the obviously-correct single comparison.
```rust
let mut reader = BufReader::new(fobj);
let mut expected = &contents_in_p1[..];
loop {
let buf = reader.fill_buf().when_reading_file(&fs_path)?;
if buf.is_empty() {
// Found EOF
return Ok(expected.is_empty());
} else if let Some(rest) = expected.drop_prefix(buf) {
// What we read so far matches the expected content, continue reading
let buf_len = buf.len();
reader.consume(buf_len);
expected = rest
} else {
// Found different content
return Ok(false);
}
}
```
Differential Revision: https://phab.mercurial-scm.org/D11412