diff mercurial/commit.py @ 45757:067707e026b4 stable

commit: don't change phases for preexisting commits I noticed when pulling with hg-git in a repository that already had the changes, but pulled from another Mercurial repository. This meant that hg-git would re-create exact matches of the changesets, and if they were public, they'd get reverted to drafts. Differential Revision: https://phab.mercurial-scm.org/D9253
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 29 Oct 2020 07:51:13 +0100
parents 0428978bca22
children 330c258fe7ca
line wrap: on
line diff
--- a/mercurial/commit.py	Thu Oct 22 18:38:41 2020 -0400
+++ b/mercurial/commit.py	Thu Oct 29 07:51:13 2020 +0100
@@ -79,6 +79,9 @@
         if repo.changelog._copiesstorage == b'extra':
             extra = _extra_with_copies(repo, extra, files)
 
+        # save the tip to check whether we actually committed anything
+        oldtip = repo.changelog.tiprev()
+
         # update changelog
         repo.ui.note(_(b"committing changelog\n"))
         repo.changelog.delayupdate(tr)
@@ -99,7 +102,11 @@
         )
         # set the new commit is proper phase
         targetphase = subrepoutil.newcommitphase(repo.ui, ctx)
-        if targetphase:
+
+        # prevent unmarking changesets as public on recommit
+        waspublic = oldtip == repo.changelog.tiprev() and not repo[n].phase()
+
+        if targetphase and not waspublic:
             # retract boundary do not alter parent changeset.
             # if a parent have higher the resulting phase will
             # be compliant anyway