comparison 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
comparison
equal deleted inserted replaced
45755:8ed69bd42f10 45757:067707e026b4
76 b'filesremoved', 76 b'filesremoved',
77 ): 77 ):
78 extra.pop(name, None) 78 extra.pop(name, None)
79 if repo.changelog._copiesstorage == b'extra': 79 if repo.changelog._copiesstorage == b'extra':
80 extra = _extra_with_copies(repo, extra, files) 80 extra = _extra_with_copies(repo, extra, files)
81
82 # save the tip to check whether we actually committed anything
83 oldtip = repo.changelog.tiprev()
81 84
82 # update changelog 85 # update changelog
83 repo.ui.note(_(b"committing changelog\n")) 86 repo.ui.note(_(b"committing changelog\n"))
84 repo.changelog.delayupdate(tr) 87 repo.changelog.delayupdate(tr)
85 n = repo.changelog.add( 88 n = repo.changelog.add(
97 repo.hook( 100 repo.hook(
98 b'pretxncommit', throw=True, node=hex(n), parent1=xp1, parent2=xp2, 101 b'pretxncommit', throw=True, node=hex(n), parent1=xp1, parent2=xp2,
99 ) 102 )
100 # set the new commit is proper phase 103 # set the new commit is proper phase
101 targetphase = subrepoutil.newcommitphase(repo.ui, ctx) 104 targetphase = subrepoutil.newcommitphase(repo.ui, ctx)
102 if targetphase: 105
106 # prevent unmarking changesets as public on recommit
107 waspublic = oldtip == repo.changelog.tiprev() and not repo[n].phase()
108
109 if targetphase and not waspublic:
103 # retract boundary do not alter parent changeset. 110 # retract boundary do not alter parent changeset.
104 # if a parent have higher the resulting phase will 111 # if a parent have higher the resulting phase will
105 # be compliant anyway 112 # be compliant anyway
106 # 113 #
107 # if minimal phase was 0 we don't need to retract anything 114 # if minimal phase was 0 we don't need to retract anything