comparison tests/test-amend-subrepo.t @ 43913:4b7d5d10c45d

exchange: ensure all outgoing subrepo references are present before pushing We've run into occasional problems with people committing a repo, and then amending or rebasing in the subrepo. That makes it so that the revision in the parent can't be checked out, and the problem gets propagated on push. Mercurial already tries to defend against this sort of dangling reference by pushing *all* subrepo revisions first. This reuses the checks that trigger warnings in `hg verify` to bail on the push unless using `--force`. I thought about putting this on the server side, but at that point, all of the data has been transferred, only to bail out. Additionally, SCM Manager hosts subrepos in a location that isn't nested in the parent, so normal subrepo code would complain that the subrepo is missing when run on the server. Because the push command pushes subrepos before calling this exchange code, a subrepo will be pushed before the parent is verified. Not great, but no dangling references are exchanged, so it solves the problem. This code isn't in the loop that pushes the subrepos because: 1) the list of outgoing revisions is needed to limit the scope of the check 2) the loop only accesses the current revision, and therefore can miss subrepos that were dropped in previous commits 3) this code is called when pushing a subrepo, so the protection is recursive I'm not sure if there's a cheap check for the list of files in the outgoing bundle. If there is, that would provide a fast path to bypass this check for people not using subrepos (or if no subrepo changes were made). There's probably also room for verifying other references like tags. But since that doesn't break checkouts, it's much less of a problem. Differential Revision: https://phab.mercurial-scm.org/D7616
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 12 Dec 2019 12:30:15 -0500
parents 4ea21df312ec
children c84844cd523a
comparison
equal deleted inserted replaced
43912:a89381e04c58 43913:4b7d5d10c45d
162 $ hg status --change . 162 $ hg status --change .
163 M a 163 M a
164 R .hgsub 164 R .hgsub
165 R .hgsubstate 165 R .hgsubstate
166 166
167 broken repositories will refuse to push
168
169 #if obsstore-off
170 $ hg up -q -C 2
171 #else
172 $ hg up -q -C 6
173 #endif
174 $ echo c >> t/b
175 $ hg amend -q -R t
176
177 $ hg init ../dest
178 $ hg init ../dest/t
179 $ hg init ../dest/s
180 $ hg push -q ../dest
181 abort: subrepo 't' is hidden in revision 04aa62396ec6 (obsstore-on !)
182 abort: subrepo 't' not found in revision 04aa62396ec6 (obsstore-off !)
183 [255]
184
185 ... unless forced
186
187 $ hg push --force -q ../dest
188 $ hg verify -R ../dest
189 checking changesets
190 checking manifests
191 crosschecking files in changesets and manifests
192 checking files
193 checked 5 changesets with 12 changes to 4 files
194 checking subrepo links
195 subrepo 't' not found in revision 04aa62396ec6
196 subrepo 't' not found in revision 6bce99600681
197
167 $ cd .. 198 $ cd ..