##// END OF EJS Templates
narrow: fix commits of empty files...
narrow: fix commits of empty files The problem is that when committing a new file with empty contents (or in general empty file with filelog p1 = -1), hg commit with narrow doesn't create a filelog revision at all, which causes failures in further commands. The problem seems to be that: - hg thinks that instead of creating a new filelog revision, it can use the filelog's p1 (the nullrev) - because it thinks the file contents is the same in that revision and in p1 - because `narrowfilelog.cmp(nullrev, b'')` is True (unlike with `filelog.cmp`) It's not clear to me which `cmp` behaves better. But I think it makes sense to change the commit code to not to "reuse" the null rev when adding an empty file with filelog p1 == filelog p2 == -1. This is consistent with never writing the null rev in the manifest, which `hg verify` claims is an invariant: ``` inside/c@4: manifest refers to unknown revision 000000000000 ``` Differential Revision: https://phab.mercurial-scm.org/D11400

File last commit:

r47166:b274aa2f default
r48770:5b9de38a stable
Show More
debugdata.rs
33 lines | 911 B | application/rls-services+xml | RustLexer
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 // debugdata.rs
//
// Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 use crate::repo::Repo;
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 use crate::revlog::revlog::{Revlog, RevlogError};
/// Kind of data to debug
#[derive(Debug, Copy, Clone)]
pub enum DebugDataKind {
Changelog,
Manifest,
}
/// Dump the contents data of a revision.
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 pub fn debug_data(
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 repo: &Repo,
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 revset: &str,
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 kind: DebugDataKind,
Simon Sapin
rust: remove three enums that were identical to `RevlogError`...
r47166 ) -> Result<Vec<u8>, RevlogError> {
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 let index_file = match kind {
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 DebugDataKind::Changelog => "00changelog.i",
DebugDataKind::Manifest => "00manifest.i",
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 };
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 let revlog = Revlog::open(repo, index_file, None)?;
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 let rev =
crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?;
let data = revlog.get_rev_data(rev)?;
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 Ok(data)
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 }