changeset 49365:79b2c98ab7b4

branching: merge stable into default
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 16 Jun 2022 15:20:48 +0200
parents c2092612c424 (current diff) e8ea403b1c46 (diff)
children 259df3e3152c
files mercurial/commands.py mercurial/logcmdutil.py mercurial/merge.py relnotes/6.1 rust/hg-core/src/dirstate_tree/dirstate_map.rs rust/hg-core/src/dirstate_tree/on_disk.rs rust/hg-core/src/dirstate_tree/status.rs
diffstat 13 files changed, 131 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsigs	Sat Jun 11 00:26:25 2022 +0200
+++ b/.hgsigs	Thu Jun 16 15:20:48 2022 +0200
@@ -228,3 +228,4 @@
 5bd6bcd31dd1ebb63b8914b00064f96297267af7 0 iQHNBAABCgA3FiEEH2b4zfZU6QXBHaBhoR4BzQ4F2VYFAmJMXf0ZHGFscGhhcmVAcmFwaGFlbGdvbWVzLmRldgAKCRChHgHNDgXZVpSlC/sHnQTin4bLp+F6keT9gGCoDqx11cf4Npl6RmqM3V4SN3hP3k8gwo5JOMWNSYzwxuBuzJ24EBTtgV139NPdeHce3LEaDMMg+n5YlQjl3vqFnYPAkX973yHH1R1ijkdGNtM4KfWw6C7b8stNaKCQmnRBsKy7oxGKvHoL8ufiSmxVtkP8ImW3x9oiYUEueIWMVhaIvNANxOzsiU++yubo1ldFGXOnNAS91MALeeu7ikClaJQQLp6jMobnn0qI8TGzbe5LnexA81/qIltgFLyUAWA2d3NXVis7hFjwLToyBkObpZfq6X/7a9XhBHMwTM+O8ViYODraupcYw0vrqT93cbuBSN106sC1UERaVN2YNb1gsoyqXTZ2F8ho5QZWJphQw9cwKJkOn81SXJ8ZWr+L8WVm78mrbDV8zT6lQ/7IsmIXTQNWMBgeGc74qyReowyswP7hSbl9iQDcdKMus/4Gm9cqTnYg3Bt8jZ3lupeYMv9ZSFmKDG8A69QFLKYKzd/FFx0=
 0ddd5e1f5f67438af85d12e4ce6c39021dde9916 0 iQHNBAABCgA3FiEEH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USX3cBRiYKuGojxDMnXP5f1hW4YdDVCFhnwczeG7Q20fybjwWvB+QgYUkHzGbdCYSHCWE7f/HhTivEPSudYP4SdMnEdWNx2Rqvs+QsgFAEiIgc6lhupyZwyfIdhgxPJ/BAsjUDJnFR0dj86yVoWjoQfkEyf6toK3OjrHNLPEPfWX4Ac=
+0cc5f74ff7f0f4ac2427096bddbe102dbc2453ae 0 iQHNBAABCgA3FiEEH2b4zfZU6QXBHaBhoR4BzQ4F2VYFAmKrK5wZHGFscGhhcmVAcmFwaGFlbGdvbWVzLmRldgAKCRChHgHNDgXZVvSmC/93B3If9OY0eqbzScqY4S6XgtC1mR3tkQirYaUujCrrt75P8jlFABn1UdrOgXwjHhm+eVxxvlg/JoexSfro89j8UFFqlVzxvDXipVFFGj/n8AeRctkNiaLpDT8ejDQic7ED566gLSeAWlZ6TA14c4+O6SC1vQxr5BCEiQjBVM7bc91O4GB/VTf/31teCtdmjScv0wsISKMJdVBIOcjOaDM1dzSlWE2wNzK551hHr7D3T5v78NJ7+5NbgqzOScRpFxzO8ndDa9YCqVdpixOVbCt1PruxUc9gYjbHbCUnm+3iZ+MnGtSZdyM7XC6BLhg3IGBinzCxff3+K/1p0VR3pr53TGXdQLfkpkRiWVQlWxQUl2MFbGhpFtvqNACMKJrL/tyTFjC+2GWBTetju8OWeqpVKWmLroL6RZaotMQzNG3sRnNwDrVL9VufT1abP9LQm71Rj1c1SsvRNaFhgBannTnaQoz6UQXvM0Rr1foUESJudU5rKr4kiJdSGMqIAsH15z8=
--- a/.hgtags	Sat Jun 11 00:26:25 2022 +0200
+++ b/.hgtags	Thu Jun 16 15:20:48 2022 +0200
@@ -241,3 +241,4 @@
 5bd6bcd31dd1ebb63b8914b00064f96297267af7 6.1.1
 0ddd5e1f5f67438af85d12e4ce6c39021dde9916 6.1.2
 6b10151b962108f65bfa12b3918b1021ca334f73 6.1.3
+0cc5f74ff7f0f4ac2427096bddbe102dbc2453ae 6.1.4
--- a/mercurial/commands.py	Sat Jun 11 00:26:25 2022 +0200
+++ b/mercurial/commands.py	Thu Jun 16 15:20:48 2022 +0200
@@ -2086,10 +2086,17 @@
         extra[b'close'] = b'1'
 
         if repo[b'.'].closesbranch():
-            raise error.InputError(
-                _(b'current revision is already a branch closing head')
-            )
-        elif not bheads:
+            # Not ideal, but let us do an extra status early to prevent early
+            # bail out.
+            matcher = scmutil.match(repo[None], pats, opts)
+            s = repo.status(match=matcher)
+            if s.modified or s.added or s.removed:
+                bheads = repo.branchheads(branch, closed=True)
+            else:
+                msg = _(b'current revision is already a branch closing head')
+                raise error.InputError(msg)
+
+        if not bheads:
             raise error.InputError(
                 _(b'branch "%s" has no heads to close') % branch
             )
--- a/mercurial/logcmdutil.py	Sat Jun 11 00:26:25 2022 +0200
+++ b/mercurial/logcmdutil.py	Thu Jun 16 15:20:48 2022 +0200
@@ -376,10 +376,9 @@
         self._exthook(ctx)
 
         if self.ui.debugflag:
-            files = ctx.p1().status(ctx)
             for key, value in zip(
                 [b'files', b'files+', b'files-'],
-                [files.modified, files.added, files.removed],
+                [ctx.filesmodified(), ctx.filesadded(), ctx.filesremoved()],
             ):
                 if value:
                     self.ui.write(
@@ -511,11 +510,10 @@
             or b'added' in datahint
             or b'removed' in datahint
         ):
-            files = ctx.p1().status(ctx)
             fm.data(
-                modified=fm.formatlist(files.modified, name=b'file'),
-                added=fm.formatlist(files.added, name=b'file'),
-                removed=fm.formatlist(files.removed, name=b'file'),
+                modified=fm.formatlist(ctx.filesmodified(), name=b'file'),
+                added=fm.formatlist(ctx.filesadded(), name=b'file'),
+                removed=fm.formatlist(ctx.filesremoved(), name=b'file'),
             )
 
         verbose = not self.ui.debugflag and self.ui.verbose
--- a/mercurial/merge.py	Sat Jun 11 00:26:25 2022 +0200
+++ b/mercurial/merge.py	Thu Jun 16 15:20:48 2022 +0200
@@ -2436,6 +2436,7 @@
         status = repo.status(match=matcher, ignored=ignored, unknown=unknown)
 
         if confirm:
+            msg = None
             nb_ignored = len(status.ignored)
             nb_unknown = len(status.unknown)
             if nb_unknown and nb_ignored:
@@ -2457,12 +2458,12 @@
                         b"permanently delete at least %d empty directories?"
                     )
                     msg %= dir_count
-                else:
-                    # XXX we might be missing directory there
-                    return res
-            msg += b" (yN)$$ &Yes $$ &No"
-            if repo.ui.promptchoice(msg, default=1) == 1:
-                raise error.CanceledError(_(b'removal cancelled'))
+            if msg is None:
+                return res
+            else:
+                msg += b" (yN)$$ &Yes $$ &No"
+                if repo.ui.promptchoice(msg, default=1) == 1:
+                    raise error.CanceledError(_(b'removal cancelled'))
 
         if removefiles:
             for f in sorted(status.unknown + status.ignored):
--- a/relnotes/6.1	Sat Jun 11 00:26:25 2022 +0200
+++ b/relnotes/6.1	Thu Jun 16 15:20:48 2022 +0200
@@ -1,5 +1,18 @@
 '''This is the last release to support Python 2. Mercurial is Python 3 only starting with 6.2'''
 
+= Mercurial 6.1.4 =
+
+ * url: raise error if CONNECT request to proxy was unsuccessful
+ * docker: avoid /tmp write access issues by fixing permissions
+ * logcmdutil: use the same data as {file*} template keywords (issue6642)
+ * commit: allow to close branch when committing change over a closed head
+ * rust-status: don't trigger dirstate v1 rewrite when only v2 data is changed
+ * purge: prevent a silly crash with --confirm --files
+ * rust: relax im-rc dependency to allow minor updates"
+ * Improve PyPy support
+ * Improve Py3 error handling
+ * Documentation fixes
+
 = Mercurial 6.1.3 =
 
 '''security: '''
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Sat Jun 11 00:26:25 2022 +0200
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Thu Jun 16 15:20:48 2022 +0200
@@ -31,6 +31,13 @@
 /// anymore) is less than this fraction of the total amount of existing data.
 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5;
 
+#[derive(Debug, PartialEq, Eq)]
+/// Version of the on-disk format
+pub enum DirstateVersion {
+    V1,
+    V2,
+}
+
 #[derive(Debug)]
 pub struct DirstateMap<'on_disk> {
     /// Contents of the `.hg/dirstate` file
@@ -54,6 +61,8 @@
     /// Size of the data used to first load this `DirstateMap`. Used in case
     /// we need to write some new metadata, but no new data on disk.
     pub(super) old_data_size: usize,
+
+    pub(super) dirstate_version: DirstateVersion,
 }
 
 /// Using a plain `HgPathBuf` of the full path from the repository root as a
@@ -441,6 +450,7 @@
             ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN],
             unreachable_bytes: 0,
             old_data_size: 0,
+            dirstate_version: DirstateVersion::V1,
         }
     }
 
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Sat Jun 11 00:26:25 2022 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Thu Jun 16 15:20:48 2022 +0200
@@ -3,6 +3,7 @@
 //! See `mercurial/helptext/internals/dirstate-v2.txt`
 
 use crate::dirstate::{DirstateV2Data, TruncatedTimestamp};
+use crate::dirstate_tree::dirstate_map::DirstateVersion;
 use crate::dirstate_tree::dirstate_map::{self, DirstateMap, NodeRef};
 use crate::dirstate_tree::path_with_basename::WithBasename;
 use crate::errors::HgError;
@@ -276,7 +277,9 @@
     metadata: &[u8],
 ) -> Result<DirstateMap<'on_disk>, DirstateV2ParseError> {
     if on_disk.is_empty() {
-        return Ok(DirstateMap::empty(on_disk));
+        let mut map = DirstateMap::empty(on_disk);
+        map.dirstate_version = DirstateVersion::V2;
+        return Ok(map);
     }
     let (meta, _) = TreeMetadata::from_bytes(metadata)
         .map_err(|_| DirstateV2ParseError)?;
@@ -291,6 +294,7 @@
         ignore_patterns_hash: meta.ignore_patterns_hash,
         unreachable_bytes: meta.unreachable_bytes.get(),
         old_data_size: on_disk.len(),
+        dirstate_version: DirstateVersion::V2,
     };
     Ok(dirstate_map)
 }
--- a/rust/hg-core/src/dirstate_tree/status.rs	Sat Jun 11 00:26:25 2022 +0200
+++ b/rust/hg-core/src/dirstate_tree/status.rs	Thu Jun 16 15:20:48 2022 +0200
@@ -4,6 +4,7 @@
 use crate::dirstate_tree::dirstate_map::BorrowedPath;
 use crate::dirstate_tree::dirstate_map::ChildNodesRef;
 use crate::dirstate_tree::dirstate_map::DirstateMap;
+use crate::dirstate_tree::dirstate_map::DirstateVersion;
 use crate::dirstate_tree::dirstate_map::NodeRef;
 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
 use crate::matchers::get_ignore_function;
@@ -59,16 +60,29 @@
 
     let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) =
         if options.list_ignored || options.list_unknown {
-            let mut hasher = Sha1::new();
-            let (ignore_fn, warnings) = get_ignore_function(
-                ignore_files,
-                &root_dir,
-                &mut |pattern_bytes| hasher.update(pattern_bytes),
-            )?;
-            let new_hash = *hasher.finalize().as_ref();
-            let changed = new_hash != dmap.ignore_patterns_hash;
-            dmap.ignore_patterns_hash = new_hash;
-            (ignore_fn, warnings, Some(changed))
+            let (ignore_fn, warnings, changed) = match dmap.dirstate_version {
+                DirstateVersion::V1 => {
+                    let (ignore_fn, warnings) = get_ignore_function(
+                        ignore_files,
+                        &root_dir,
+                        &mut |_pattern_bytes| {},
+                    )?;
+                    (ignore_fn, warnings, None)
+                }
+                DirstateVersion::V2 => {
+                    let mut hasher = Sha1::new();
+                    let (ignore_fn, warnings) = get_ignore_function(
+                        ignore_files,
+                        &root_dir,
+                        &mut |pattern_bytes| hasher.update(pattern_bytes),
+                    )?;
+                    let new_hash = *hasher.finalize().as_ref();
+                    let changed = new_hash != dmap.ignore_patterns_hash;
+                    dmap.ignore_patterns_hash = new_hash;
+                    (ignore_fn, warnings, Some(changed))
+                }
+            };
+            (ignore_fn, warnings, changed)
         } else {
             (Box::new(|&_| true), vec![], None)
         };
@@ -133,7 +147,8 @@
 
     outcome.dirty = common.ignore_patterns_have_changed == Some(true)
         || !outdated.is_empty()
-        || !new_cachable.is_empty();
+        || (!new_cachable.is_empty()
+            && dmap.dirstate_version == DirstateVersion::V2);
 
     // Remove outdated mtimes before adding new mtimes, in case a given
     // directory is both
--- a/tests/test-branches.t	Sat Jun 11 00:26:25 2022 +0200
+++ b/tests/test-branches.t	Thu Jun 16 15:20:48 2022 +0200
@@ -283,6 +283,19 @@
   abort: current revision is already a branch closing head
   [10]
 
+  $ echo foo > b
+  $ hg commit -d '9 0' --close-branch -m 're-closing this branch'
+
+  $ echo bar > b
+  $ hg commit -d '9 0' --close-branch -m 're-closing this branch' bh1
+  abort: current revision is already a branch closing head
+  [10]
+  $ hg commit -d '9 0' --close-branch -m 're-closing this branch' b
+
+  $ hg debugstrip --rev 13: --no-backup
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg revert --all --no-backup
+
   $ hg log -r tip --debug
   changeset:   12:e3d49c0575d8fc2cb1cd6859c747c14f5f6d499f
   branch:      b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue6642.t	Thu Jun 16 15:20:48 2022 +0200
@@ -0,0 +1,35 @@
+hg log --debug shouldn't show different data than {file_*} template keywords
+https://bz.mercurial-scm.org/show_bug.cgi?id=6642
+
+  $ hg init issue6642
+  $ cd issue6642
+
+  $ echo a > a
+  $ hg ci -qAm a
+  $ echo b > b
+  $ hg ci -qAm b
+  $ hg up 0 -q
+  $ echo c > c
+  $ hg ci -qAm c
+  $ hg merge -q
+  $ hg ci -m merge
+
+  $ hg log -GT '{rev} {desc} file_adds: [{file_adds}], file_mods: [{file_mods}], file_dels: [{file_dels}], files: [{files}]\n'
+  @    3 merge file_adds: [], file_mods: [], file_dels: [], files: []
+  |\
+  | o  2 c file_adds: [c], file_mods: [], file_dels: [], files: [c]
+  | |
+  o |  1 b file_adds: [b], file_mods: [], file_dels: [], files: [b]
+  |/
+  o  0 a file_adds: [a], file_mods: [], file_dels: [], files: [a]
+  
+
+  $ hg log -r . --debug | grep files
+  [1]
+  $ hg log -r . --debug -T json | egrep '(added|removed|modified)'
+    "added": [],
+    "modified": [],
+    "removed": [],
+  $ hg log -r . --debug -T xml | grep path
+  <paths>
+  </paths>
--- a/tests/test-phases.t	Sat Jun 11 00:26:25 2022 +0200
+++ b/tests/test-phases.t	Thu Jun 16 15:20:48 2022 +0200
@@ -407,7 +407,6 @@
   manifest:    7:5e724ffacba267b2ab726c91fc8b650710deaaa8
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
-  files+:      C D E
   extra:       branch=default
   description:
   merge B' and E
--- a/tests/test-purge.t	Sat Jun 11 00:26:25 2022 +0200
+++ b/tests/test-purge.t	Thu Jun 16 15:20:48 2022 +0200
@@ -350,4 +350,9 @@
   .hg
   .hgignore
 
+Test some --confirm case that ended crashing
+
+  $ hg purge --confirm
+  $ hg purge --confirm --all --files
+
   $ cd ..