D11885: filemerge: stop returning always-`True` value

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Now that we've removed some more leftovers from "merge driver", it's
  clear that the first element of `filemerge()`'s return value is always
  `True`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11885

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/filemerge.py
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -354,7 +354,7 @@
 self._restore_backup(wctx[dfile], localkey, flags)
 else:
 wctx[dfile].remove(ignoremissing=True)
-complete, merge_ret, deleted = filemerge.filemerge(
+merge_ret, deleted = filemerge.filemerge(
 self._repo,
 wctx,
 self._local,
@@ -371,26 +371,25 @@
 elif not merge_ret:
 self.mark(dfile, MERGE_RECORD_RESOLVED)
 
-if complete:
-action = None
-if deleted:
-if fcd.isabsent():
-# dc: local picked. Need to drop if present, which may
-# happen on re-resolves.
-action = ACTION_FORGET
+action = None
+if deleted:
+if fcd.isabsent():
+# dc: local picked. Need to drop if present, which may
+# happen on re-resolves.
+action = ACTION_FORGET
+else:
+# cd: remote picked (or otherwise deleted)
+action = ACTION_REMOVE
+else:
+if fcd.isabsent():  # dc: remote picked
+action = ACTION_GET
+elif fco.isabsent():  # cd: local picked
+if dfile in self.localctx:
+action = ACTION_ADD_MODIFIED
 else:
-# cd: remote picked (or otherwise deleted)
-action = ACTION_REMOVE
-else:
-if fcd.isabsent():  # dc: remote picked
-action = ACTION_GET
-elif fco.isabsent():  # cd: local picked
-if dfile in self.localctx:
-action = ACTION_ADD_MODIFIED
-else:
-action = ACTION_ADD
-# else: regular merges (no action necessary)
-self._results[dfile] = merge_ret, action
+action = ACTION_ADD
+# else: regular merges (no action necessary)
+self._results[dfile] = merge_ret, action
 
 return merge_ret
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -1032,7 +1032,7 @@
 a boolean indicating whether the file was deleted from disk."""
 
 if not fco.cmp(fcd):  # files identical?
-return True, None, False
+return None, False
 
 ui = repo.ui
 fd = fcd.path()
@@ -1090,8 +1090,7 @@
 toolconf = tool, toolpath, binary, symlink, scriptfn
 
 if mergetype == nomerge:
-r, deleted = func(repo, mynode, fcd, fco, fca, toolconf, labels)
-return True, r, deleted
+return func(repo, mynode, fcd, fco, fca, toolconf, labels)
 
 if orig != fco.path():
 ui.status(
@@ -1110,7 +1109,7 @@
 b'in-memory merge does not support merge conflicts'
 )
 ui.warn(onfailure % fduipath)
-return True, 1, False
+return 1, False
 
 backup = _makebackup(repo, ui, wctx, fcd)
 r = 1
@@ -1151,7 +1150,7 @@
 )
 # we're done if premerge was successful (r is 0)
 if not r:
-return not r, r, False
+return r, False
 
 needcheck, r, deleted = func(
 repo,
@@ -1178,7 +1177,7 @@
 ui.warn(onfailure % fduipath)
 _onfilemergefailure(ui)
 
-return True, r, deleted
+return r, deleted
 finally:
 if not r and backup is not None:
 backup.remove()
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -695,7 +695,7 @@
 )
 ):
 repo.wwrite(fcd.path(), fco.data(), fco.flags())
-return True, 0, False
+return 0, False
 
 
 @eh.wrapfunction(copiesmod, b'pathcopies')



To: martinvonz, #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


D11887: simplemerge: make `localorother` a "mode" instead of a separate thing

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `simplemerge()` takes a `mode` argument, which can be "union", "merge"
  or "mergediff", and a `localorother` argument, which can be `None`,
  "local", or "other". The two options are not at all orthogonal -- most
  combinations don't make sense. Also, at least "union", "local", and
  "other" are very closely related. Therefore, it makes sense to combine
  them into one.
  
  It probably makes sense to split the `mode` argument into `resolve`
  and `marker_style`, where the former can be `None`, "union", "local",
  or "other", and the latter can be "merge", "merge3", "mergediff", or
  "minimize". This is a good step in that direction whether or not we
  end up doing that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11887

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -516,13 +516,17 @@
 
 m3 = Merge3Text(basetext, localtext, othertext)
 extrakwargs = {
-"localorother": opts.get("localorother", None),
+"localorother": None,
 'minimize': True,
 }
 if mode == b'union':
 extrakwargs['start_marker'] = None
 extrakwargs['mid_marker'] = None
 extrakwargs['end_marker'] = None
+elif mode == b'local':
+extrakwargs['localorother'] = b'local'
+elif mode == b'other':
+extrakwargs['localorother'] = b'other'
 elif name_base is not None:
 extrakwargs['base_marker'] = b'|||'
 extrakwargs['name_base'] = name_base
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -579,43 +579,28 @@
 )
 
 
-def _imergeauto(
-repo,
-mynode,
-fcd,
-fco,
-fca,
-toolconf,
-backup,
-labels=None,
-localorother=None,
+@internaltool(b'merge-local', mergeonly, precheck=_mergecheck)
+def _imergelocal(
+repo, mynode, fcd, fco, fca, toolconf, backup, labels=None
 ):
 """
-Generic driver for _imergelocal and _imergeother
-"""
-assert localorother is not None
-r = simplemerge.simplemerge(
-repo.ui, fcd, fca, fco, label=labels, localorother=localorother
-)
-return True, r
-
-
-@internaltool(b'merge-local', mergeonly, precheck=_mergecheck)
-def _imergelocal(*args, **kwargs):
-"""
 Like :merge, but resolve all conflicts non-interactively in favor
 of the local `p1()` changes."""
-success, status = _imergeauto(localorother=b'local', *args, **kwargs)
-return success, status, False
+return _merge(
+repo, mynode, fcd, fco, fca, toolconf, backup, labels, b'local'
+)
 
 
 @internaltool(b'merge-other', mergeonly, precheck=_mergecheck)
-def _imergeother(*args, **kwargs):
+def _imergeother(
+repo, mynode, fcd, fco, fca, toolconf, backup, labels=None
+):
 """
 Like :merge, but resolve all conflicts non-interactively in favor
 of the other `p2()` changes."""
-success, status = _imergeauto(localorother=b'other', *args, **kwargs)
-return success, status, False
+return _merge(
+repo, mynode, fcd, fco, fca, toolconf, backup, labels, b'other'
+)
 
 
 @internaltool(



To: martinvonz, #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


D11886: simplemerge: avoid a call to `pycompat.strkwargs()`

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D11886

AFFECTED FILES
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -516,25 +516,23 @@
 
 m3 = Merge3Text(basetext, localtext, othertext)
 extrakwargs = {
-b"localorother": opts.get("localorother", None),
-b'minimize': True,
+"localorother": opts.get("localorother", None),
+'minimize': True,
 }
 if mode == b'union':
-extrakwargs[b'start_marker'] = None
-extrakwargs[b'mid_marker'] = None
-extrakwargs[b'end_marker'] = None
+extrakwargs['start_marker'] = None
+extrakwargs['mid_marker'] = None
+extrakwargs['end_marker'] = None
 elif name_base is not None:
-extrakwargs[b'base_marker'] = b'|||'
-extrakwargs[b'name_base'] = name_base
-extrakwargs[b'minimize'] = False
+extrakwargs['base_marker'] = b'|||'
+extrakwargs['name_base'] = name_base
+extrakwargs['minimize'] = False
 
 if mode == b'mergediff':
 lines, conflicts = _mergediff(m3, name_a, name_b, name_base)
 else:
 lines = list(
-m3.merge_lines(
-name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs)
-)
+m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs)
 )
 conflicts = m3.conflicts and not mode == b'union'
 



To: martinvonz, #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


D11883: directaccess: fix uses of commands.status() that don't go through flag parsing

2021-12-07 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When `commands.commit.post-status` is enabled, after commit/amend,
  commands.status() is called without any revs argument, which means that status
  gets None instead of an empty list like it would receive if the user had 
invoked
  this on the commandline. With the `experimental.directaccess` config enabled,
  this gets passed to `unhidehashlikerevs`, which didn't previously handle None,
  but now should.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11883

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -2197,6 +2197,9 @@
 
 returns a repo object with the required changesets unhidden
 """
+if not specs:
+return repo
+
 if not repo.filtername or not repo.ui.configbool(
 b'experimental', b'directaccess'
 ):



To: spectral, #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


D11884: status: when extracting arguments from `opts`, use the same default values

2021-12-07 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Sometimes other code, such as commit when using `commands.commit.post-status`,
  calls `commands.status()` without going through the normal dispatch mechanism
  that would typically fill in the args to be something besides None. As a
  "defense in depth" mechanism for a bug where Mercurial would crash if both
  `commands.commit.post-status` and `experimental.directaccess` were enabled,
  let's sanitize these values to be identical to the values they would have when
  the user invoked this method from the commandline.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11884

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6897,9 +6897,9 @@
 
 cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
 opts = pycompat.byteskwargs(opts)
-revs = opts.get(b'rev')
-change = opts.get(b'change')
-terse = opts.get(b'terse')
+revs = opts.get(b'rev', [])
+change = opts.get(b'change', b'')
+terse = opts.get(b'terse', _NOTTERSE)
 if terse is _NOTTERSE:
 if revs:
 terse = b''



To: spectral, #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


mercurial-devel | Failed pipeline for branch/stable | 27ed4da6

2021-12-07 Thread Heptapod


Pipeline #29981 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/stable ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/stable )

Commit: 27ed4da6 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/27ed4da68c50cf9f56250067ba604579ff6c9266
 )
Commit Message: downgrade: don't assume existence of nodemap fi...
Commit Author: Raphaël Gomès

Pipeline #29981 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29981 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 3 failed jobs.

Job #272141 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272141/raw )

Stage: tests
Name: windows-py3-pyox
Job #272140 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272140/raw )

Stage: tests
Name: windows-py3
Job #272132 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272132/raw )

Stage: tests
Name: test-py2-pure

-- 
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


D11882: rhg: fix a crash on non-generaldelta revlogs

2021-12-07 Thread aalekseyev (Arseniy Alekseyev)
aalekseyev created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11882

AFFECTED FILES
  rust/hg-core/src/revlog/index.rs
  rust/hg-core/src/revlog/revlog.rs
  tests/test-rhg-no-generaldelta.t

CHANGE DETAILS

diff --git a/tests/test-rhg-no-generaldelta.t b/tests/test-rhg-no-generaldelta.t
--- a/tests/test-rhg-no-generaldelta.t
+++ b/tests/test-rhg-no-generaldelta.t
@@ -22,9 +22,7 @@
 1   120prev 14143 93   
0.6503593 00.0
 2   131prev 12141105   
0.74468   105 00.0
 
-rhg breaks on non-generaldelta revlogs:
+rhg works on non-generaldelta revlogs:
 
   $ $NO_FALLBACK hg cat f -r . | f --sha256 --size
-  abort: corrupted revlog (rhg !)
-  size=0, 
sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 (rhg !)
-  size=141, 
sha256=1a7fe778e33d64d5e14a9a126b77038b328356e67bacf308797bc0e39bf204f3 (no-rhg 
!)
+  size=141, 
sha256=1a7fe778e33d64d5e14a9a126b77038b328356e67bacf308797bc0e39bf204f3
diff --git a/rust/hg-core/src/revlog/revlog.rs 
b/rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/revlog.rs
+++ b/rust/hg-core/src/revlog/revlog.rs
@@ -191,11 +191,20 @@
 // Todo return -> Cow
 let mut entry = self.get_entry(rev)?;
 let mut delta_chain = vec![];
-while let Some(base_rev) = entry.base_rev {
-delta_chain.push(entry);
-entry = self
-.get_entry(base_rev)
-.map_err(|_| RevlogError::corrupted())?;
+
+if self.index.uses_generaldelta() {
+while let Some(base_rev) = entry.base_rev_or_base_of_delta_chain {
+delta_chain.push(entry);
+entry = self.get_entry_internal(base_rev)?;
+}
+} else {
+if let Some(base_rev) = entry.base_rev_or_base_of_delta_chain {
+delta_chain.push(entry);
+entry = self.get_entry_internal(base_rev)?;
+for rev in (base_rev + 1..rev).rev() {
+delta_chain.push(self.get_entry_internal(rev)?);
+}
+}
 }
 
 // TODO do not look twice in the index
@@ -291,14 +300,26 @@
 bytes: data,
 compressed_len: index_entry.compressed_len(),
 uncompressed_len: index_entry.uncompressed_len(),
-base_rev: if index_entry.base_revision() == rev {
+base_rev_or_base_of_delta_chain: if index_entry
+.base_revision_or_base_of_delta_chain()
+== rev
+{
 None
 } else {
-Some(index_entry.base_revision())
+Some(index_entry.base_revision_or_base_of_delta_chain())
 },
 };
 Ok(entry)
 }
+
+// when resolving internal references within revlog, any errors
+// should be reported as corruption, instead of e.g. "invalid revision"
+fn get_entry_internal(
+,
+rev: Revision,
+) -> Result {
+return self.get_entry(rev).map_err(|_| RevlogError::corrupted());
+}
 }
 
 /// The revlog entry's bytes and the necessary informations to extract
@@ -309,7 +330,7 @@
 bytes: &'a [u8],
 compressed_len: usize,
 uncompressed_len: usize,
-base_rev: Option,
+base_rev_or_base_of_delta_chain: Option,
 }
 
 impl<'a> RevlogEntry<'a> {
@@ -375,7 +396,7 @@
 /// Tell if the entry is a snapshot or a delta
 /// (influences on decompression).
 fn is_delta() -> bool {
-self.base_rev.is_some()
+self.base_rev_or_base_of_delta_chain.is_some()
 }
 }
 
diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs
--- a/rust/hg-core/src/revlog/index.rs
+++ b/rust/hg-core/src/revlog/index.rs
@@ -85,6 +85,7 @@
 /// Offsets of starts of index blocks.
 /// Only needed when the index is interleaved with data.
 offsets: Option>,
+uses_generaldelta: bool,
 }
 
 impl Index {
@@ -101,6 +102,11 @@
 return Err(HgError::corrupted("unsupported revlog version"));
 }
 
+// This is only correct because we know version is REVLOGV1.
+// In v2 we always use generaldelta, while in v0 we never use
+// generaldelta. Similar for [is_inline] (it's only used in v1).
+let uses_generaldelta = header.format_flags().uses_generaldelta();
+
 if header.format_flags().is_inline() {
 let mut offset: usize = 0;
 let mut offsets = Vec::new();
@@ -120,6 +126,7 @@
 Ok(Self {
 bytes,
 offsets: Some(offsets),
+uses_generaldelta,
 })
 } else {
 Err(HgError::corrupted("unexpected 

D11881: rhg: centralize index header parsing

2021-12-07 Thread aalekseyev (Arseniy Alekseyev)
aalekseyev created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Centralize index header parsing, parse the generaldelta flag,
  and leave breadcrumbs to relate the code to python.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11881

AFFECTED FILES
  rust/hg-core/src/revlog/index.rs
  rust/hg-core/src/revlog/revlog.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/revlog/revlog.rs 
b/rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/revlog.rs
+++ b/rust/hg-core/src/revlog/revlog.rs
@@ -3,7 +3,6 @@
 use std::ops::Deref;
 use std::path::Path;
 
-use byteorder::{BigEndian, ByteOrder};
 use flate2::read::ZlibDecoder;
 use micro_timer::timed;
 use sha1::{Digest, Sha1};
@@ -74,13 +73,6 @@
 match repo.store_vfs().mmap_open_opt(_path)? {
 None => Index::new(Box::new(vec![])),
 Some(index_mmap) => {
-let version = get_version(_mmap)?;
-if version != 1 {
-// A proper new version should have had a repo/store
-// requirement.
-return Err(HgError::corrupted("corrupted revlog"));
-}
-
 let index = Index::new(Box::new(index_mmap))?;
 Ok(index)
 }
@@ -387,19 +379,6 @@
 }
 }
 
-/// Format version of the revlog.
-pub fn get_version(index_bytes: &[u8]) -> Result {
-if index_bytes.len() == 0 {
-return Ok(1);
-};
-if index_bytes.len() < 4 {
-return Err(HgError::corrupted(
-"corrupted revlog: can't read the index format header",
-));
-};
-Ok(BigEndian::read_u16(_bytes[2..=3]))
-}
-
 /// Calculate the hash of a revision given its data and its parents.
 fn hash(
 data: &[u8],
diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs
--- a/rust/hg-core/src/revlog/index.rs
+++ b/rust/hg-core/src/revlog/index.rs
@@ -9,6 +9,76 @@
 
 pub const INDEX_ENTRY_SIZE: usize = 64;
 
+pub struct IndexHeader {
+header_bytes: [u8; 4],
+}
+
+#[derive(Copy, Clone)]
+pub struct IndexHeaderFlags {
+flags: u16,
+}
+
+// Corresponds to the high bits of `_format_flags` in python
+impl IndexHeaderFlags {
+// Corresponds to FLAG_INLINE_DATA in python
+pub fn is_inline(self) -> bool {
+return self.flags & 1 != 0;
+}
+// Corresponds to FLAG_GENERALDELTA in python
+pub fn uses_generaldelta(self) -> bool {
+return self.flags & 2 != 0;
+}
+}
+
+// Corresponds to the INDEX_HEADER structure,
+// which is parsed as a `header` variable in `_loadindex` in `revlog.py`
+impl IndexHeader {
+fn format_flags() -> IndexHeaderFlags {
+// No "unknown flags" check here, unlike in python. Maybe there should
+// be.
+return IndexHeaderFlags {
+flags: BigEndian::read_u16(_bytes[0..2]),
+};
+}
+
+// The only revlog version currently supported by rhg.
+const REVLOGV1: u16 = 1;
+
+// Corresponds to `_format_version` in Python.
+// The only curently supported version is
+fn format_version() -> u16 {
+return BigEndian::read_u16(_bytes[2..4]);
+}
+
+const EMPTY_INDEX_HEADER: IndexHeader = IndexHeader {
+// We treat an empty file as a valid index with no entries.
+// Here we make an arbitrary choice of what we assume the format of the
+// index to be (V1, using generaldelta).
+// This doesn't matter too much, since we're only doing read-only
+// access. but the value corresponds to the `new_header` variable in
+// `revlog.py`, `_loadindex`
+header_bytes: [0, 3, 0, 1],
+};
+
+fn parse(index_bytes: &[u8]) -> Result {
+if index_bytes.len() == 0 {
+return Ok(IndexHeader::EMPTY_INDEX_HEADER);
+}
+if index_bytes.len() < 4 {
+return Err(HgError::corrupted(
+"corrupted revlog: can't read the index format header",
+));
+}
+return Ok(IndexHeader {
+header_bytes: {
+let bytes: [u8; 4] =
+index_bytes[0..4].try_into().expect("impossible");
+bytes
+},
+});
+}
+}
+
 /// A Revlog index
 pub struct Index {
 bytes: Box + Send>,
@@ -23,7 +93,15 @@
 pub fn new(
 bytes: Box + Send>,
 ) -> Result {
-if is_inline() {
+let header = IndexHeader::parse(bytes.as_ref())?;
+
+if header.format_version() != IndexHeader::REVLOGV1 {
+// A proper new version should have had a repo/store
+// requirement.
+return Err(HgError::corrupted("unsupported revlog version"));
+}
+
+if header.format_flags().is_inline() {
 let mut offset: usize = 0;
 let mut offsets = Vec::new();
 
@@ 

D11880: rhg: demonstrate that rhg breaks on non-generaldelta revlogs

2021-12-07 Thread aalekseyev (Arseniy Alekseyev)
aalekseyev created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11880

AFFECTED FILES
  tests/test-rhg-no-generaldelta.t

CHANGE DETAILS

diff --git a/tests/test-rhg-no-generaldelta.t b/tests/test-rhg-no-generaldelta.t
new file mode 100644
--- /dev/null
+++ b/tests/test-rhg-no-generaldelta.t
@@ -0,0 +1,30 @@
+
+  $ NO_FALLBACK="env RHG_ON_UNSUPPORTED=abort"
+
+  $ cat << EOF >> $HGRCPATH
+  > [format]
+  > sparse-revlog = no
+  > EOF
+
+  $ hg init repo --config format.generaldelta=no --config 
format.usegeneraldelta=no
+  $ cd repo
+  $ seq 50 > f
+  $ hg commit -q -Am initial
+  $ echo x >> f
+  $ hg commit -q -Am x
+  $ hg update .^
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ (seq 50; echo x) | (read; cat) > f
+  $ hg commit -q -Am y
+  $ hg debugdeltachain f
+  rev  chain# chainlen prev   delta   sizerawsize  chainsize   
  ratio   lindist extradist extraratio
+0   11   -1base 79141 79   
0.5602879 00.0
+1   120prev 14143 93   
0.6503593 00.0
+2   131prev 12141105   
0.74468   105 00.0
+
+rhg breaks on non-generaldelta revlogs:
+
+  $ $NO_FALLBACK hg cat f -r . | f --sha256 --size
+  abort: corrupted revlog (rhg !)
+  size=0, 
sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 (rhg !)
+  size=141, 
sha256=1a7fe778e33d64d5e14a9a126b77038b328356e67bacf308797bc0e39bf204f3 (no-rhg 
!)



To: aalekseyev, #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


mercurial-devel | Failed pipeline for branch/stable | 195e669a

2021-12-07 Thread Heptapod


Pipeline #29976 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/stable ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/stable )

Commit: 195e669a ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/195e669aa12592d4f49e63c47fc38bd5e7d72fe0
 )
Commit Message: fsmonitor: fix criteria for nonnormalset comput...
Commit Author: Raphaël Gomès

Pipeline #29976 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29976 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 2 failed jobs.

Job #272070 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272070/raw )

Stage: tests
Name: windows-py3
Job #272071 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272071/raw )

Stage: tests
Name: windows-py3-pyox

-- 
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


mercurial-devel | Failed pipeline for branch/default | c8d767db

2021-12-07 Thread Heptapod


Pipeline #29970 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default )

Commit: c8d767db ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/c8d767db37a73e878b62b89f5f34e6ffcbee537c
 )
Commit Message: rhg: don't run `blackbox` if not activated

You...
Commit Author: Raphaël Gomès

Pipeline #29970 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29970 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 1 failed job.

Job #272073 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272073/raw )

Stage: tests
Name: windows-py3-pyox

-- 
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


mercurial-devel | Failed pipeline for branch/default | e659aaf3

2021-12-07 Thread Heptapod


Pipeline #29973 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default )

Commit: e659aaf3 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/e659aaf30e3ca6703589b1041157f40d285c2ffd
 )
Commit Message: rhg: Update the dirstate on disk after status

...
Commit Author: Simon Sapin ( https://foss.heptapod.net/SimonSapin )

Pipeline #29973 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29973 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 2 failed jobs.

Job #272019 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272019/raw )

Stage: tests
Name: windows-py3-pyox
Job #272014 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/272014/raw )

Stage: tests
Name: test-py3-rhg

-- 
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


D11878: filemerge: remove unused `orig` argument from tool functions

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D11878

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -306,7 +306,7 @@
 
 
 @internaltool(b'prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, mynode, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
@@ -347,24 +347,24 @@
 choice = [b'local', b'other', b'unresolved'][index]
 
 if choice == b'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
+return _iother(repo, mynode, fcd, fco, fca, toolconf, labels)
 elif choice == b'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
+return _ilocal(repo, mynode, fcd, fco, fca, toolconf, labels)
 elif choice == b'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
+return _ifail(repo, mynode, fcd, fco, fca, toolconf, labels)
 except error.ResponseExpected:
 ui.write(b"\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
+return _ifail(repo, mynode, fcd, fco, fca, toolconf, labels)
 
 
 @internaltool(b'local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, mynode, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 
 @internaltool(b'other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, mynode, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -377,7 +377,7 @@
 
 
 @internaltool(b'fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, mynode, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -441,7 +441,7 @@
 return 1  # continue merging
 
 
-def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
+def _mergecheck(repo, mynode, fcd, fco, fca, toolconf):
 tool, toolpath, binary, symlink, scriptfn = toolconf
 uipathfn = scmutil.getuipathfn(repo)
 if symlink:
@@ -462,7 +462,7 @@
 return True
 
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels, mode):
+def _merge(repo, mynode, fcd, fco, fca, toolconf, backup, labels, mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -483,13 +483,13 @@
 ),
 precheck=_mergecheck,
 )
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
+def _iunion(repo, mynode, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
 return _merge(
-repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels, b'union'
+repo, mynode, fcd, fco, fca, toolconf, backup, labels, b'union'
 )
 
 
@@ -502,14 +502,14 @@
 ),
 precheck=_mergecheck,
 )
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
+def _imerge(repo, mynode, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two sections, one for each 
side
 of merge."""
 return _merge(
-repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels, b'merge'
+repo, mynode, fcd, fco, fca, toolconf, backup, labels, b'merge'
 )
 
 
@@ -522,7 +522,7 @@
 ),
 precheck=_mergecheck,
 )
-def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
+def _imerge3(repo, mynode, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -532,7 +532,7 @@
 labels = _defaultconflictlabels
 if len(labels) < 3:
 labels.append(b'base')
-return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, 

D11879: simplemerge: stop merging file flags

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As 384df4db6520 
 
(merge: merge file flags together with file content,
  2013-01-09) explains, we shouldn't do a 3-way merge of the
  symlink. However, since 84614212ae39 
 
(flags: actually merge flags in
  simplemerge, 2020-05-16), we do that in
  `simplemerge.simplemerge()`. What's more, the merging of the
  executable flag there isn't actually necessary; it was made a no-op by
  the very next commit, i.e. 4234c9af515d 
 
(flags: read flag from
  dirstate/disk for workingcopyctx (issue5743), 2020-05-16).
  
  I found the overall flag-merging code (not the bit in
  `simplemerge.py`) very hard to follow, but I think I now finally
  understand how it works. `mergestate.resolve()` calculates the merged
  file flags and sets them on the local side of the merge (confusingly
  by calling `_restore_backup()`). Then it calls
  `filemerge.filemerge()`, which in turn calls
  `simplemerge.simplemerge()` (if premerge is enabled). That means that
  the flags on the local side `fcs.flags()` are already correct when the
  flag-merging code in `simplemerge.simplemerge()` runs. Interestingly,
  that code still works when the local side already has the merged
  value, it just doesn't change the value. Here's a truth table to
  explain why:
  
BLOMCAR
000
001
0101011
011
100
101
110
101
  
  B: Base
  L: Local
  O: Other
  M: Merged flags from `mergestate.resolve()`, i.e. what's called "local"
  
when we get to `simplemerge.simplemerge()`
  
  C: `commonflags` in `simplemerge.simplemerge()`, i.e. `M & O`
  A: `addedflags` in `simplemerge.simplemerge()`, i.e. `(M ^ O) - B`
  R: Re-merged flags `simplemerge.simplemerge()`, i.e. `C | A`
  
  As you can see, the re-merged flags are always unchanged compared to
  the initial merged flags (R equals M).
  
  Therefore, this patch effectively backs out 84614212ae39 
. 
(I might
  later refactor this code to have the flags explicitly passed in.)
  
  `simplemerge.simplemerge()` is also called from
  `contrib/simplemerge.py`, but that code never passes any flags.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11879

AFFECTED FILES
  mercurial/simplemerge.py

CHANGE DETAILS

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -19,12 +19,10 @@
 from __future__ import absolute_import
 
 from .i18n import _
-from .node import nullrev
 from . import (
 error,
 mdiff,
 pycompat,
-util,
 )
 from .utils import stringutil
 
@@ -424,12 +422,6 @@
 return result
 
 
-def is_not_null(ctx):
-if not util.safehasattr(ctx, "node"):
-return False
-return ctx.rev() != nullrev
-
-
 def _mergediff(m3, name_a, name_b, name_base):
 lines = []
 conflicts = False
@@ -546,21 +538,13 @@
 )
 conflicts = m3.conflicts and not mode == b'union'
 
-# merge flags if necessary
-flags = localctx.flags()
-localflags = set(pycompat.iterbytestr(flags))
-otherflags = set(pycompat.iterbytestr(otherctx.flags()))
-if is_not_null(basectx) and localflags != otherflags:
-baseflags = set(pycompat.iterbytestr(basectx.flags()))
-commonflags = localflags & otherflags
-addedflags = (localflags ^ otherflags) - baseflags
-flags = b''.join(sorted(commonflags | addedflags))
-
 mergedtext = b''.join(lines)
 if opts.get('print'):
 ui.fout.write(mergedtext)
 else:
-localctx.write(mergedtext, flags)
+# localctx.flags() already has the merged flags (done in
+# mergestate.resolve())
+localctx.write(mergedtext, localctx.flags())
 
 if conflicts:
 return 1



To: martinvonz, #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


D11877: filemerge: stop passing around 3 unused `None` values in `files` argument

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Since 67cfffbfb6a0 
 
(filemerge: eliminate most uses of tempfiles,
  2017-08-31), we have used only the last entry in the `files` tuple
  that gets passed around to various functions. That commit said
  "Emphasize that they're unused so we can more easily remove them
  later.". It's now "later".

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11877

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -399,11 +399,10 @@
 return filectx
 
 
-def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
+def _premerge(repo, fcd, fco, fca, toolconf, backup, labels=None):
 tool, toolpath, binary, symlink, scriptfn = toolconf
 if symlink or fcd.isabsent() or fco.isabsent():
 return 1
-unused, unused, unused, backup = files
 
 ui = repo.ui
 
@@ -463,7 +462,7 @@
 return True
 
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels, mode):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -484,13 +483,13 @@
 ),
 precheck=_mergecheck,
 )
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will use both left and right sides for conflict regions.
 No markers are inserted."""
 return _merge(
-repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, b'union'
+repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels, b'union'
 )
 
 
@@ -503,14 +502,14 @@
 ),
 precheck=_mergecheck,
 )
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
 the partially merged file. Markers will have two sections, one for each 
side
 of merge."""
 return _merge(
-repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, b'merge'
+repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels, b'merge'
 )
 
 
@@ -523,7 +522,7 @@
 ),
 precheck=_mergecheck,
 )
-def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Uses the internal non-interactive simple merge algorithm for merging
 files. It will fail if there are any conflicts and leave markers in
@@ -533,7 +532,7 @@
 labels = _defaultconflictlabels
 if len(labels) < 3:
 labels.append(b'base')
-return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
+return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels)
 
 
 @internaltool(
@@ -565,7 +564,7 @@
 precheck=_mergecheck,
 )
 def _imerge_diff(
-repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None
+repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None
 ):
 """
 Uses the internal non-interactive simple merge algorithm for merging
@@ -578,7 +577,16 @@
 if len(labels) < 3:
 labels.append(b'base')
 return _merge(
-repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, 
b'mergediff'
+repo,
+mynode,
+orig,
+fcd,
+fco,
+fca,
+toolconf,
+backup,
+labels,
+b'mergediff',
 )
 
 
@@ -590,7 +598,7 @@
 fco,
 fca,
 toolconf,
-files,
+backup,
 labels=None,
 localorother=None,
 ):
@@ -631,7 +639,9 @@
 b"tool of your choice)\n"
 ),
 )
-def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, 
labels=None):
+def _itagmerge(
+repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None
+):
 """
 Uses the internal tag merge algorithm (experimental).
 """
@@ -640,7 +650,7 @@
 
 
 @internaltool(b'dump', fullmerge, binary=True, symlink=True)
-def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, backup, labels=None):
 """
 Creates three versions of the files to merge, containing the
 contents of local, other and base. These files can then be used to
@@ -669,16 +679,20 @@
 
 
 

D11876: filemerge: rename backup variables from `back` to `backup`

2021-12-07 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `backup` seems like an obviously clearer name for something containing
  something related to a backup.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11876

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -293,9 +293,9 @@
 return None  # unknown
 
 
-def _matcheol(file, back):
+def _matcheol(file, backup):
 """Convert EOL markers in a file to match origfile"""
-tostyle = _eoltype(back.data())  # No repo.wread filters?
+tostyle = _eoltype(backup.data())  # No repo.wread filters?
 if tostyle:
 data = util.readfile(file)
 style = _eoltype(data)
@@ -403,7 +403,7 @@
 tool, toolpath, binary, symlink, scriptfn = toolconf
 if symlink or fcd.isabsent() or fco.isabsent():
 return 1
-unused, unused, unused, back = files
+unused, unused, unused, backup = files
 
 ui = repo.ui
 
@@ -438,7 +438,7 @@
 return 0
 if premerge not in validkeep:
 # restore from backup and try again
-_restorebackup(fcd, back)
+_restorebackup(fcd, backup)
 return 1  # continue merging
 
 
@@ -755,12 +755,12 @@
 % (tool, uipathfn(fcd.path()))
 )
 return False, 1, None
-unused, unused, unused, back = files
+unused, unused, unused, backup = files
 localpath = _workingpath(repo, fcd)
 args = _toolstr(repo.ui, tool, b"args")
 
 with _maketempfiles(
-repo, fco, fca, repo.wvfs.join(back.path()), b"$output" in args
+repo, fco, fca, repo.wvfs.join(backup.path()), b"$output" in args
 ) as temppaths:
 basepath, otherpath, localoutputpath = temppaths
 outpath = b""
@@ -918,10 +918,10 @@
 }
 
 
-def _restorebackup(fcd, back):
+def _restorebackup(fcd, backup):
 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
 # util.copy here instead.
-fcd.write(back.data(), fcd.flags())
+fcd.write(backup.data(), fcd.flags())
 
 
 def _makebackup(repo, ui, wctx, fcd):
@@ -941,15 +941,15 @@
 # merge -> filemerge). (I suspect the fileset import is the weakest link)
 from . import context
 
-back = scmutil.backuppath(ui, repo, fcd.path())
-inworkingdir = back.startswith(repo.wvfs.base) and not back.startswith(
+backup = scmutil.backuppath(ui, repo, fcd.path())
+inworkingdir = backup.startswith(repo.wvfs.base) and not backup.startswith(
 repo.vfs.base
 )
 if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
 # If the backup file is to be in the working directory, and we're
 # merging in-memory, we must redirect the backup to the memory context
 # so we don't disturb the working directory.
-relpath = back[len(repo.wvfs.base) + 1 :]
+relpath = backup[len(repo.wvfs.base) + 1 :]
 wctx[relpath].write(fcd.data(), fcd.flags())
 return wctx[relpath]
 else:
@@ -958,13 +958,13 @@
 # in-memory so we can use the fast path of ``util.copy`` if both are
 # on disk.
 if isinstance(fcd, context.overlayworkingfilectx):
-util.writefile(back, fcd.data())
+util.writefile(backup, fcd.data())
 else:
 a = _workingpath(repo, fcd)
-util.copyfile(a, back)
+util.copyfile(a, backup)
 # A arbitraryfilectx is returned, so we can run the same functions on
 # the backup context regardless of where it lives.
-return context.arbitraryfilectx(back, repo=repo)
+return context.arbitraryfilectx(backup, repo=repo)
 
 
 @contextlib.contextmanager
@@ -1119,8 +1119,8 @@
 ui.warn(onfailure % fduipath)
 return True, 1, False
 
-back = _makebackup(repo, ui, wctx, fcd)
-files = (None, None, None, back)
+backup = _makebackup(repo, ui, wctx, fcd)
+files = (None, None, None, backup)
 r = 1
 try:
 internalmarkerstyle = ui.config(b'ui', b'mergemarkers')
@@ -1189,8 +1189,8 @@
 
 return True, r, deleted
 finally:
-if not r and back is not None:
-back.remove()
+if not r and backup is not None:
+backup.remove()
 
 
 def _haltmerge():
@@ -1226,7 +1226,7 @@
 def _check(repo, r, ui, tool, fcd, files):
 fd = fcd.path()
 uipathfn = scmutil.getuipathfn(repo)
-unused, unused, unused, back = files
+unused, unused, unused, backup = files
 
 if not r and (
 _toolbool(ui, tool, b"checkconflicts")
@@ -1253,7 +1253,7 @@
 or b'changed' in _toollist(ui, tool, b"check")
 )
 ):
-if back is not None and not fcd.cmp(back):
+if backup is not None and not fcd.cmp(backup):
 if 

mercurial-devel | Failed pipeline for branch/default | c8d767db

2021-12-07 Thread Heptapod


Pipeline #29970 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default )

Commit: c8d767db ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/c8d767db37a73e878b62b89f5f34e6ffcbee537c
 )
Commit Message: rhg: don't run `blackbox` if not activated

You...
Commit Author: Raphaël Gomès

Pipeline #29970 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29970 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 1 failed job.

Job #271968 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/271968/raw )

Stage: tests
Name: windows-py3-pyox

-- 
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


mercurial-devel | Failed pipeline for branch/default | ebcdc1f8

2021-12-07 Thread Heptapod


Pipeline #29969 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default )

Commit: ebcdc1f8 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/ebcdc1f8ddd28c35c15a7f62af02059798dff9c8
 )
Commit Message: dirstate: remove unused method

Its last usage ...
Commit Author: Raphaël Gomès

Pipeline #29969 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29969 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 1 failed job.

Job #271950 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/271950/raw )

Stage: tests
Name: windows-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


mercurial-devel | Failed pipeline for branch/stable | 40e53390

2021-12-07 Thread Heptapod


Pipeline #29965 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel )
Branch: branch/stable ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/stable )

Commit: 40e53390 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/40e5339098b58f3699f5094c3b3c29c4db194263
 )
Commit Message: fsmonitor: incorporate fixes for Python 3.10 (i...
Commit Author: Raphaël Gomès

Pipeline #29965 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/29965 ) 
triggered by Administrator ( https://foss.heptapod.net/root )
had 2 failed jobs.

Job #271882 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/271882/raw )

Stage: tests
Name: windows-py3-pyox
Job #271881 ( 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/271881/raw )

Stage: tests
Name: windows-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


D11875: fsmonitor: fix criteria for nonnormalset computation

2021-12-07 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  ... oops.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11875

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -336,7 +336,7 @@
 nonnormalset = {
 f
 for f, e in self._map.items()
-if e.v1_state() != "n" or e.v1_mtime() == -1
+if e.v1_state() != b"n" or e.v1_mtime() == -1
 }
 
 copymap = self._map.copymap



To: Alphare, #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


D11874: rhg: support the new extension suboptions syntax

2021-12-07 Thread Raphaël Gomès
Alphare created this revision.
Alphare added a comment.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.


  Pending CI refresh

REVISION SUMMARY
  See inline comments

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11874

AFFECTED FILES
  rust/rhg/src/main.rs
  tests/test-rhg.t

CHANGE DETAILS

diff --git a/tests/test-rhg.t b/tests/test-rhg.t
--- a/tests/test-rhg.t
+++ b/tests/test-rhg.t
@@ -380,3 +380,13 @@
   $ rhg files
   a
   $ rm .hgsub
+
+The `:required` extension suboptions are correctly ignored
+
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "blackbox:required = yes" >> $HGRCPATH
+  $ rhg files
+  a
+  $ echo "*:required = yes" >> $HGRCPATH
+  $ rhg files
+  a
diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs
--- a/rust/rhg/src/main.rs
+++ b/rust/rhg/src/main.rs
@@ -11,6 +11,7 @@
 use hg::repo::{Repo, RepoError};
 use hg::utils::files::{get_bytes_from_os_str, get_path_from_bytes};
 use hg::utils::SliceExt;
+use std::collections::HashSet;
 use std::ffi::OsString;
 use std::path::PathBuf;
 use std::process::Command;
@@ -593,11 +594,23 @@
 }
 }
 
+/// The `*` extension is an edge-case for config sub-options that apply to all
+/// extensions. For now, only `:required` exists, but that may change in the
+/// future.
 const SUPPORTED_EXTENSIONS: &[&[u8]] =
-&[b"blackbox", b"share", b"sparse", b"narrow"];
+&[b"blackbox", b"share", b"sparse", b"narrow", b"*"];
 
 fn check_extensions(config: ) -> Result<(), CommandError> {
-let enabled = config.get_section_keys(b"extensions");
+let enabled: HashSet<&[u8]> = config
+.get_section_keys(b"extensions")
+.into_iter()
+.map(|extension| {
+// Ignore extension suboptions. Only `required` exists for now.
+// `rhg` either supports an extension or doesn't, so it doesn't
+// make sense to consider the loading of an extension.
+extension.split_2(b':').unwrap_or((extension, b"")).0
+})
+.collect();
 
 let mut unsupported = enabled;
 for supported in SUPPORTED_EXTENSIONS {



To: Alphare, #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


D11873: upgrade: don't use `dd status=none` in the test

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This breaks on Windows, so lets use `>2 /dev/null` like in the other tests.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11873

AFFECTED FILES
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1667,7 +1667,7 @@
   $ hg debugformat -v | grep dirstate-v2
   dirstate-v2:yes no  no
   $ hg status
-  $ dd status=none bs=12 count=1 if=.hg/dirstate
+  $ dd bs=12 count=1 if=.hg/dirstate 2> /dev/null
   dirstate-v2
 
 Downgrade from dirstate-v2



To: marmoute, #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


D11871: upgrade: only process revlogs that needs it by default

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We have more and more requirement that does not affect revlog or that only
  affect some of them. It is silly to force a full processing of all revlog to
  juste move the requirement around, or to simply rewrite the dirstate.
  
  So now, only the revlog that needs to be touched will be touched. Unless the
  --changelog & al flags are used.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11871

AFFECTED FILES
  mercurial/upgrade.py
  tests/test-share-safe.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -213,10 +213,7 @@
  preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, 
store (no-rust !)
  preserved: dotencode, fncache, generaldelta, persistent-nodemap, 
revlogv1, sparserevlog, store (rust !)
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   additional optimizations are available by specifying "--optimize ":
   
@@ -238,10 +235,7 @@
  preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, 
store (no-rust !)
  preserved: dotencode, fncache, generaldelta, persistent-nodemap, 
revlogv1, sparserevlog, store (rust !)
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
 
 --optimize can be used to add optimizations
@@ -963,7 +957,6 @@
   $ hg debugupgrade --optimize re-delta-parent --no-manifest --no-backup 
--quiet
   warning: ignoring  --no-manifest, as upgrade is changing: sparserevlog
   
-  ignoring revlogs selection flags, format requirements change: sparserevlog
   requirements
  preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
  preserved: dotencode, fncache, generaldelta, persistent-nodemap, 
revlogv1, store (rust !)
@@ -980,7 +973,6 @@
   note:selecting all-filelogs for processing to change: sparserevlog
   note:selecting changelog for processing to change: sparserevlog
   
-  ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
   
   requirements
@@ -1038,7 +1030,6 @@
   note:selecting all-filelogs for processing to change: sparserevlog
   note:selecting changelog for processing to change: sparserevlog
   
-  ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
   
   requirements
@@ -1695,10 +1686,7 @@
   dirstate-v2
  "hg status" will be faster
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -1724,10 +1712,7 @@
  preserved: * (glob)
  removed: dirstate-v2
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -1762,10 +1747,7 @@
   dirstate-v2
  "hg status" will be faster
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -1786,10 +1768,7 @@
  preserved: * (glob)
  removed: dirstate-v2
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -363,10 +363,7 @@
  preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, 
revlogv1, sparserevlog, store (dirstate-v2 !)
  added: share-safe
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   $ hg debugupgraderepo --run
   upgrade will perform the following actions:
@@ -379,10 +376,7 @@
   share-safe
  Upgrades a repository to share-safe format so that future shares of this 
repository share its requirements and configs.
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   beginning upgrade...
   repository locked and read-only
@@ -457,10 +451,7 @@
  preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, 
revlogv1, sparserevlog, store (dirstate-v2 !)
  removed: share-safe
   
-  processed revlogs:
-- all-filelogs
-- changelog
-- manifest
+  no revlogs to process
   
   $ hg debugupgraderepo --run
   upgrade will perform the following actions:
@@ -470,10 +461,7 @@
  preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, 
revlogv1, sparserevlog, store (dirstate-v2 !)
  removed: share-safe
   
-  processed 

D11872: upgrade: drop some dead code

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Everything done by this block is now done by earlier code. So we don't need 
it anymore.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11872

AFFECTED FILES
  mercurial/upgrade.py

CHANGE DETAILS

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -85,9 +85,6 @@
 )
 removed_actions = upgrade_actions.find_format_downgrades(repo)
 
-removedreqs = repo.requirements - newreqs
-addedreqs = newreqs - repo.requirements
-
 # check if we need to touch revlog and if so, which ones
 
 touched_revlogs = set()
@@ -161,20 +158,6 @@
 elif msg_issued >= 1:
 ui.status((b"\n"))
 
-# check the consistency of the revlog selection with the planned action
-
-if touched_revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS:
-incompatible = upgrade_actions.RECLONES_REQUIREMENTS & (
-removedreqs | addedreqs
-)
-if incompatible:
-msg = _(
-b'ignoring revlogs selection flags, format requirements '
-b'change: %s\n'
-)
-ui.warn(msg % b', '.join(sorted(incompatible)))
-touched_revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS
-
 upgrade_op = upgrade_actions.UpgradeOperation(
 ui,
 newreqs,



To: marmoute, #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


D11870: upgrade: issue a message when a revlog type has to be upgraded

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is more explicite and prepare for a smoother transition to smarter 
picking
  of the revlog we will process.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11870

AFFECTED FILES
  mercurial/upgrade.py
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -401,6 +401,10 @@
   [formatvariant.name.mismatchdefault|compression:   
][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special|   
zlib][formatvariant.default|zstd] (zstd !)
   [formatvariant.name.uptodate|compression-level: 
][formatvariant.repo.uptodate| default][formatvariant.config.default| 
default][formatvariant.default| default]
   $ hg debugupgraderepo
+  note:selecting all-filelogs for processing to change: dotencode
+  note:selecting manifestlog for processing to change: dotencode
+  note:selecting changelog for processing to change: dotencode
+  
   repository lacks features recommended by current config options:
   
   fncache
@@ -473,6 +477,10 @@
   
 
   $ hg --config format.dotencode=false debugupgraderepo
+  note:selecting all-filelogs for processing to change: fncache
+  note:selecting manifestlog for processing to change: fncache
+  note:selecting changelog for processing to change: fncache
+  
   repository lacks features recommended by current config options:
   
   fncache
@@ -567,6 +575,10 @@
   .hg/store/data/f2.i
 
   $ hg debugupgraderepo --run --config format.sparse-revlog=false
+  note:selecting all-filelogs for processing to change: generaldelta
+  note:selecting manifestlog for processing to change: generaldelta
+  note:selecting changelog for processing to change: generaldelta
+  
   upgrade will perform the following actions:
   
   requirements
@@ -671,6 +683,10 @@
 
   $ rm -rf .hg/upgradebackup.*/
   $ hg debugupgraderepo --run --no-backup
+  note:selecting all-filelogs for processing to change: sparserevlog
+  note:selecting manifestlog for processing to change: sparserevlog
+  note:selecting changelog for processing to change: sparserevlog
+  
   upgrade will perform the following actions:
   
   requirements
@@ -961,6 +977,9 @@
 - manifest
   
   $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup 
--debug --traceback
+  note:selecting all-filelogs for processing to change: sparserevlog
+  note:selecting changelog for processing to change: sparserevlog
+  
   ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
   
@@ -1016,6 +1035,9 @@
 
   $ echo "sparse-revlog=yes" >> .hg/hgrc
   $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup 
--debug --traceback
+  note:selecting all-filelogs for processing to change: sparserevlog
+  note:selecting changelog for processing to change: sparserevlog
+  
   ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
   
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -92,7 +92,8 @@
 
 touched_revlogs = set()
 overwrite_msg = _(b'warning: ignoring %14s, as upgrade is changing: %s\n')
-msg_issued = False
+select_msg = _(b'note:selecting %s for processing to change: %s\n')
+msg_issued = 0
 
 FL = upgrade_engine.UPGRADE_FILELOGS
 MN = upgrade_engine.UPGRADE_MANIFEST
@@ -108,24 +109,43 @@
 if not specified_revlogs[FL]:
 msg = overwrite_msg % (b'--no-filelogs', action.name)
 ui.warn(msg)
-msg_issued = True
+msg_issued = 2
+else:
+msg = select_msg % (b'all-filelogs', action.name)
+ui.status(msg)
+if not ui.quiet:
+msg_issued = 1
 touched_revlogs.add(FL)
+
 if action.touches_manifests and MN not in touched_revlogs:
 if MN in specified_revlogs:
 if not specified_revlogs[MN]:
 msg = overwrite_msg % (b'--no-manifest', action.name)
 ui.warn(msg)
-msg_issued = True
+msg_issued = 2
+else:
+msg = select_msg % (b'manifestlog', action.name)
+ui.status(msg)
+if not ui.quiet:
+msg_issued = 1
 touched_revlogs.add(MN)
+
 if action.touches_changelog and CL not in touched_revlogs:
 if CL in specified_revlogs:
 if not specified_revlogs[CL]:
 msg = overwrite_msg % (b'--no-changelog', 

D11869: upgrade: explicitly warn when a `--no-xxx` flag is overwritten

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Some format upgrade/downgrades -needs- revlog to be recomputed. So we now
  detect that individually and warn when it contradict explicitly passed flag.
  
  This is part of a large server to make `debugupgraderepo` smarter about which
  revlog it picks by default.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11869

AFFECTED FILES
  mercurial/upgrade.py
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -944,6 +944,22 @@
 
   $ echo "[format]" > .hg/hgrc
   $ echo "sparse-revlog=no" >> .hg/hgrc
+  $ hg debugupgrade --optimize re-delta-parent --no-manifest --no-backup 
--quiet
+  warning: ignoring  --no-manifest, as upgrade is changing: sparserevlog
+  
+  ignoring revlogs selection flags, format requirements change: sparserevlog
+  requirements
+ preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
+ preserved: dotencode, fncache, generaldelta, persistent-nodemap, 
revlogv1, store (rust !)
+ removed: sparserevlog
+  
+  optimisations: re-delta-parent
+  
+  processed revlogs:
+- all-filelogs
+- changelog
+- manifest
+  
   $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup 
--debug --traceback
   ignoring revlogs selection flags, format requirements change: sparserevlog
   upgrade will perform the following actions:
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -90,6 +90,43 @@
 
 # check if we need to touch revlog and if so, which ones
 
+touched_revlogs = set()
+overwrite_msg = _(b'warning: ignoring %14s, as upgrade is changing: %s\n')
+msg_issued = False
+
+FL = upgrade_engine.UPGRADE_FILELOGS
+MN = upgrade_engine.UPGRADE_MANIFEST
+CL = upgrade_engine.UPGRADE_CHANGELOG
+
+for action in sorted(up_actions + removed_actions, key=lambda a: a.name):
+# optimisation does not "requires anything, they just needs it.
+if action.type != upgrade_actions.FORMAT_VARIANT:
+continue
+
+if action.touches_filelogs and FL not in touched_revlogs:
+if FL in specified_revlogs:
+if not specified_revlogs[FL]:
+msg = overwrite_msg % (b'--no-filelogs', action.name)
+ui.warn(msg)
+msg_issued = True
+touched_revlogs.add(FL)
+if action.touches_manifests and MN not in touched_revlogs:
+if MN in specified_revlogs:
+if not specified_revlogs[MN]:
+msg = overwrite_msg % (b'--no-manifest', action.name)
+ui.warn(msg)
+msg_issued = True
+touched_revlogs.add(MN)
+if action.touches_changelog and CL not in touched_revlogs:
+if CL in specified_revlogs:
+if not specified_revlogs[CL]:
+msg = overwrite_msg % (b'--no-changelog', action.name)
+ui.warn(msg)
+msg_issued = True
+touched_revlogs.add(CL)
+if msg_issued:
+ui.warn((b"\n"))
+
 revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
 if specified_revlogs:
 # we have some limitation on revlogs to be recloned



To: marmoute, #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


D11868: upgrade: make the list of explicitly specified revlog a dict

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This makes various logic simpler and will help making future patch clearer.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11868

AFFECTED FILES
  mercurial/upgrade.py

CHANGE DETAILS

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -45,11 +45,13 @@
 optimize = {}
 repo = repo.unfiltered()
 
-specentries = (
-(upgrade_engine.UPGRADE_CHANGELOG, changelog),
-(upgrade_engine.UPGRADE_MANIFEST, manifest),
-(upgrade_engine.UPGRADE_FILELOGS, filelogs),
-)
+specified_revlogs = {}
+if changelog is not None:
+specified_revlogs[upgrade_engine.UPGRADE_CHANGELOG] = changelog
+if manifest is not None:
+specified_revlogs[upgrade_engine.UPGRADE_MANIFEST] = manifest
+if filelogs is not None:
+specified_revlogs[upgrade_engine.UPGRADE_FILELOGS] = filelogs
 
 # Ensure the repository can be upgraded.
 upgrade_actions.check_source_requirements(repo)
@@ -89,17 +91,16 @@
 # check if we need to touch revlog and if so, which ones
 
 revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
-specified = [(y, x) for (y, x) in specentries if x is not None]
-if specified:
+if specified_revlogs:
 # we have some limitation on revlogs to be recloned
-if any(x for y, x in specified):
+if any(specified_revlogs.values()):
 revlogs = set()
-for upgrade, enabled in specified:
+for upgrade, enabled in specified_revlogs.items():
 if enabled:
 revlogs.add(upgrade)
 else:
 # none are enabled
-for upgrade, __ in specified:
+for upgrade in specified_revlogs.keys():
 revlogs.discard(upgrade)
 
 # check the consistency of the revlog selection with the planned action



To: marmoute, #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


D11867: upgrade: move the revlog selection code longer down the chain

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We about about to make revlog section smarter. Moving the code around will 
make
  the next changesets clearer.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11867

AFFECTED FILES
  mercurial/upgrade.py

CHANGE DETAILS

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -45,24 +45,11 @@
 optimize = {}
 repo = repo.unfiltered()
 
-revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
 specentries = (
 (upgrade_engine.UPGRADE_CHANGELOG, changelog),
 (upgrade_engine.UPGRADE_MANIFEST, manifest),
 (upgrade_engine.UPGRADE_FILELOGS, filelogs),
 )
-specified = [(y, x) for (y, x) in specentries if x is not None]
-if specified:
-# we have some limitation on revlogs to be recloned
-if any(x for y, x in specified):
-revlogs = set()
-for upgrade, enabled in specified:
-if enabled:
-revlogs.add(upgrade)
-else:
-# none are enabled
-for upgrade, __ in specified:
-revlogs.discard(upgrade)
 
 # Ensure the repository can be upgraded.
 upgrade_actions.check_source_requirements(repo)
@@ -99,6 +86,24 @@
 removedreqs = repo.requirements - newreqs
 addedreqs = newreqs - repo.requirements
 
+# check if we need to touch revlog and if so, which ones
+
+revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
+specified = [(y, x) for (y, x) in specentries if x is not None]
+if specified:
+# we have some limitation on revlogs to be recloned
+if any(x for y, x in specified):
+revlogs = set()
+for upgrade, enabled in specified:
+if enabled:
+revlogs.add(upgrade)
+else:
+# none are enabled
+for upgrade, __ in specified:
+revlogs.discard(upgrade)
+
+# check the consistency of the revlog selection with the planned action
+
 if revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS:
 incompatible = upgrade_actions.RECLONES_REQUIREMENTS & (
 removedreqs | addedreqs



To: marmoute, #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


D11866: dirstate-v2: fix upgrade on an empty repository

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This used to crash as the dirstate file does not exist in this case.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11866

AFFECTED FILES
  mercurial/upgrade_utils/engine.py
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1701,3 +1701,66 @@
   $ hg debugformat -v | grep dirstate-v2
   dirstate-v2: no no  no
   $ hg status
+
+  $ cd ..
+
+dirstate-v2: upgrade and downgrade from and empty repository:
+-
+
+  $ hg init --config format.exp-rc-dirstate-v2=no dirstate-v2-empty
+  $ cd dirstate-v2-empty
+  $ hg debugformat | grep dirstate-v2
+  dirstate-v2: no
+
+upgrade
+
+  $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=yes
+  upgrade will perform the following actions:
+  
+  requirements
+ preserved: * (glob)
+ added: dirstate-v2
+  
+  dirstate-v2
+ "hg status" will be faster
+  
+  processed revlogs:
+- all-filelogs
+- changelog
+- manifest
+  
+  beginning upgrade...
+  repository locked and read-only
+  creating temporary repository to stage upgraded data: 
$TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
+  (it is safe to interrupt this process any time before data migration 
completes)
+  upgrading to dirstate-v2 from v1
+  replaced files will be backed up at 
$TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob)
+  removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
+  $ hg debugformat | grep dirstate-v2
+  dirstate-v2:yes
+
+downgrade
+
+  $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=no
+  upgrade will perform the following actions:
+  
+  requirements
+ preserved: * (glob)
+ removed: dirstate-v2
+  
+  processed revlogs:
+- all-filelogs
+- changelog
+- manifest
+  
+  beginning upgrade...
+  repository locked and read-only
+  creating temporary repository to stage upgraded data: 
$TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
+  (it is safe to interrupt this process any time before data migration 
completes)
+  downgrading from dirstate-v2 to v1
+  replaced files will be backed up at 
$TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob)
+  removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
+  $ hg debugformat | grep dirstate-v2
+  dirstate-v2: no
+
+  $ cd ..
diff --git a/mercurial/upgrade_utils/engine.py 
b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import errno
 import stat
 
 from ..i18n import _
@@ -633,16 +634,29 @@
 util.copyfile(
 srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires')
 )
-util.copyfile(
-srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate')
-)
+try:
+util.copyfile(
+srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate')
+)
+except (IOError, OSError) as e:
+# The dirstate does not exist on an empty repo or a repo with no
+# revision checked out
+if e.errno != errno.ENOENT:
+raise
 
 assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2')
 srcrepo.dirstate._map.preload()
 srcrepo.dirstate._use_dirstate_v2 = new == b'v2'
 srcrepo.dirstate._map._use_dirstate_v2 = srcrepo.dirstate._use_dirstate_v2
 srcrepo.dirstate._dirty = True
-srcrepo.vfs.unlink(b'dirstate')
+try:
+srcrepo.vfs.unlink(b'dirstate')
+except (IOError, OSError) as e:
+# The dirstate does not exist on an empty repo or a repo with no
+# revision checked out
+if e.errno != errno.ENOENT:
+raise
+
 srcrepo.dirstate.write(None)
 
 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)



To: marmoute, #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


D11865: dirstate-v2: test upgrade without rust too

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  There is no reason to gate this anymore.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11865

AFFECTED FILES
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1634,7 +1634,14 @@
   $ hg debugupgraderepo --run
   nothing to do
 
-#if rust
+#if no-rust
+
+  $ cat << EOF >> $HGRCPATH
+  > [storage]
+  > dirstate-v2.slow-path = allow
+  > EOF
+
+#endif
 
 Upgrade to dirstate-v2
 
@@ -1644,7 +1651,7 @@
   upgrade will perform the following actions:
   
   requirements
- preserved: dotencode, exp-revlogv2.2, fncache, generaldelta, 
persistent-nodemap, revlog-compression-zstd, sparserevlog, store
+ preserved: * (glob)
  added: dirstate-v2
   
   dirstate-v2
@@ -1676,7 +1683,7 @@
   upgrade will perform the following actions:
   
   requirements
- preserved: dotencode, exp-revlogv2.2, fncache, generaldelta, 
persistent-nodemap, revlog-compression-zstd, sparserevlog, store
+ preserved: * (glob)
  removed: dirstate-v2
   
   processed revlogs:
@@ -1694,5 +1701,3 @@
   $ hg debugformat -v | grep dirstate-v2
   dirstate-v2: no no  no
   $ hg status
-
-#endif



To: marmoute, #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


D11864: test-upgrade: narrow the `debugformat` call when upgrading to dirstate-v2

2021-12-07 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will make the test less noisy when new requirement are added.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11864

AFFECTED FILES
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1638,21 +1638,8 @@
 
 Upgrade to dirstate-v2
 
-  $ hg debugformat -v --config format.exp-rc-dirstate-v2=1
-  format-variant repo config default
-  fncache:yesyes yes
+  $ hg debugformat -v --config format.exp-rc-dirstate-v2=1 | grep dirstate-v2
   dirstate-v2: noyes  no
-  dotencode:  yesyes yes
-  generaldelta:   yesyes yes
-  share-safe:  no no  no
-  sparserevlog:   yesyes yes
-  persistent-nodemap: yesyes  no
-  copies-sdc:  no no  no
-  revlog-v2:  yesyes  no
-  changelog-v2:no no  no
-  plain-cl-delta: yesyes yes
-  compression:zstd   zstdzstd
-  compression-level:  default default default
   $ hg debugupgraderepo --config format.exp-rc-dirstate-v2=1 --run
   upgrade will perform the following actions:
   
@@ -1677,21 +1664,8 @@
   removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
   $ ls .hg/upgradebackup.*/dirstate
   .hg/upgradebackup.*/dirstate (glob)
-  $ hg debugformat -v
-  format-variant repo config default
-  fncache:yesyes yes
+  $ hg debugformat -v | grep dirstate-v2
   dirstate-v2:yes no  no
-  dotencode:  yesyes yes
-  generaldelta:   yesyes yes
-  share-safe:  no no  no
-  sparserevlog:   yesyes yes
-  persistent-nodemap: yesyes  no
-  copies-sdc:  no no  no
-  revlog-v2:  yesyes  no
-  changelog-v2:no no  no
-  plain-cl-delta: yesyes yes
-  compression:zstd   zstdzstd
-  compression-level:  default default default
   $ hg status
   $ dd status=none bs=12 count=1 if=.hg/dirstate
   dirstate-v2
@@ -1717,21 +1691,8 @@
   downgrading from dirstate-v2 to v1
   replaced files will be backed up at 
$TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
   removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
-  $ hg debugformat -v
-  format-variant repo config default
-  fncache:yesyes yes
+  $ hg debugformat -v | grep dirstate-v2
   dirstate-v2: no no  no
-  dotencode:  yesyes yes
-  generaldelta:   yesyes yes
-  share-safe:  no no  no
-  sparserevlog:   yesyes yes
-  persistent-nodemap: yesyes  no
-  copies-sdc:  no no  no
-  revlog-v2:  yesyes  no
-  changelog-v2:no no  no
-  plain-cl-delta: yesyes yes
-  compression:zstd   zstdzstd
-  compression-level:  default default default
   $ hg status
 
 #endif



To: marmoute, #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