##// END OF EJS Templates
singlehead: introduce special handling of closed heads...
marmoute -
r43239:76608f9f default
parent child Browse files
Show More
@@ -645,6 +645,9 b" coreconfigitem('experimental', 'server.s"
645 coreconfigitem('experimental', 'single-head-per-branch',
645 coreconfigitem('experimental', 'single-head-per-branch',
646 default=False,
646 default=False,
647 )
647 )
648 coreconfigitem('experimental', 'single-head-per-branch:account-closed-heads',
649 default=False,
650 )
648 coreconfigitem('experimental', 'sshserver.support-v2',
651 coreconfigitem('experimental', 'sshserver.support-v2',
649 default=False,
652 default=False,
650 )
653 )
@@ -1920,8 +1920,13 b' class localrepository(object):'
1920 # gating.
1920 # gating.
1921 tracktags(tr2)
1921 tracktags(tr2)
1922 repo = reporef()
1922 repo = reporef()
1923 if repo.ui.configbool('experimental', 'single-head-per-branch'):
1923
1924 scmutil.enforcesinglehead(repo, tr2, desc)
1924 r = repo.ui.configsuboptions('experimental',
1925 'single-head-per-branch')
1926 singlehead, singleheadsub = r
1927 if singlehead:
1928 accountclosed = singleheadsub.get("account-closed-heads", False)
1929 scmutil.enforcesinglehead(repo, tr2, desc, accountclosed)
1925 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1930 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1926 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1931 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1927 args = tr.hookargs.copy()
1932 args = tr.hookargs.copy()
@@ -1895,14 +1895,16 b' def nodesummaries(repo, nodes, maxnumnod'
1895 first = ' '.join(short(h) for h in nodes[:maxnumnodes])
1895 first = ' '.join(short(h) for h in nodes[:maxnumnodes])
1896 return _("%s and %d others") % (first, len(nodes) - maxnumnodes)
1896 return _("%s and %d others") % (first, len(nodes) - maxnumnodes)
1897
1897
1898 def enforcesinglehead(repo, tr, desc):
1898 def enforcesinglehead(repo, tr, desc, accountclosed=False):
1899 """check that no named branch has multiple heads"""
1899 """check that no named branch has multiple heads"""
1900 if desc in ('strip', 'repair'):
1900 if desc in ('strip', 'repair'):
1901 # skip the logic during strip
1901 # skip the logic during strip
1902 return
1902 return
1903 visible = repo.filtered('visible')
1903 visible = repo.filtered('visible')
1904 # possible improvement: we could restrict the check to affected branch
1904 # possible improvement: we could restrict the check to affected branch
1905 for name, heads in visible.branchmap().iteritems():
1905 bm = visible.branchmap()
1906 for name in bm:
1907 heads = bm.branchheads(name, closed=accountclosed)
1906 if len(heads) > 1:
1908 if len(heads) > 1:
1907 msg = _('rejecting multiple heads on branch "%s"')
1909 msg = _('rejecting multiple heads on branch "%s"')
1908 msg %= name
1910 msg %= name
@@ -200,3 +200,62 b' actual stripping'
200 $ hg strip --config extensions.strip= --rev 'desc("c_dH0")'
200 $ hg strip --config extensions.strip= --rev 'desc("c_dH0")'
201 saved backup bundle to $TESTTMP/client/.hg/strip-backup/fe47ea669cea-a41bf5a9-backup.hg
201 saved backup bundle to $TESTTMP/client/.hg/strip-backup/fe47ea669cea-a41bf5a9-backup.hg
202
202
203 Test that closing heads are ignored by default
204 -----------------------------------------------
205
206 $ hg up 'desc("c_aG0")'
207 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
208 $ mkcommit c_aJ0
209 created new head
210
211 pushing the new head should fails
212
213 $ hg push -f
214 pushing to $TESTTMP/single-head-server
215 searching for changes
216 adding changesets
217 adding manifests
218 adding file changes
219 transaction abort!
220 rollback completed
221 abort: rejecting multiple heads on branch "branch_A"
222 (2 heads: 49003e504178 468bd81ccc5d)
223 [255]
224
225
226 closing the head and pushing should succeed
227
228 $ mkcommit c_aK0 --close-branch
229 $ hg push -f
230 pushing to $TESTTMP/single-head-server
231 searching for changes
232 adding changesets
233 adding manifests
234 adding file changes
235 added 4 changesets with 4 changes to 4 files (-1 heads)
236
237
238 Test that closing heads can be explicitly accounted for
239 -------------------------------------------------------
240
241 $ cat <<EOF >> $TESTTMP/single-head-server/.hg/hgrc
242 > [experimental]
243 > single-head-per-branch:account-closed-heads = yes
244 > EOF
245
246 $ hg up 'desc("c_aG0")'
247 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
248 $ mkcommit c_aL0
249 created new head
250 $ mkcommit c_aM0 --close-branch
251 $ hg push -f
252 pushing to $TESTTMP/single-head-server
253 searching for changes
254 adding changesets
255 adding manifests
256 adding file changes
257 transaction abort!
258 rollback completed
259 abort: rejecting multiple heads on branch "branch_A"
260 (3 heads: 49003e504178 5254bcccab93 42b9fe70a3c1)
261 [255]
General Comments 0
You need to be logged in to leave comments. Login now