##// END OF EJS Templates
branches: correctly show inactive multiheaded branches...
branches: correctly show inactive multiheaded branches Issue being fixed here: `hg branches` incorrectly renders inactive multiheaded branches as active if they have closed heads. Example: ``` $ hg log --template '{rev}:{node|short} "{desc}" ({branch}) [parents: {parents}]\n' 4:2e2fa7af8357 "merge" (default) [parents: 0:c94e548c8c7d 3:7be622ae5832 ] 3:7be622ae5832 "2" (somebranch) [parents: 1:81c1d9458987 ] 2:be82cf30409c "close" (somebranch) [parents: ] 1:81c1d9458987 "1" (somebranch) [parents: ] 0:c94e548c8c7d "initial" (default) [parents: ] $ hg branches default 4:2e2fa7af8357 somebranch 3:7be622ae5832 ``` Branch `somebranch` have two heads, the 1st one being closed (rev 2) and the other one being merged into default (rev 3). This branch should be shown as inactive one. This happens because we intersect branch heads with repo heads to check branch activity. In this case intersection in a set with one node (rev 2). This head is closed but the branch is marked as active nevertheless. Fix is to check branch activity by intersecting only open heads set. Fixed output: ``` $ hg branches default 4:2e2fa7af8357 somebranch 3:7be622ae5832 (inactive) ``` Relevant tests for multihead branches added to test-branches suite. Implentation note about adding `iteropen` method: At first I have tried to modify `iterbranches` is such a way that it would filter out closed heads itself. For example it could have `closed=False` parameter. But in this case we would have to filter closed tips as well. Reasoning in terms of `hg branches` we actually are not allowed to do this. Also, we need to do heads filtering only if tip is not closed itself. But if it is - we are ok to skip filtering, because branch is already known to be inactive. So we can't implement heads filtering in `iterbranches` in elegant way, because we will end up with something like `closed_heads=False` or even `closed_heads_is_tip_is_open`. Finally I decided to move this logic to the `branches` function, adding `iteropen` helper method. Differential Revision: https://phab.mercurial-scm.org/D583

File last commit:

r32377:c942c83a default
r34076:abf91c4f default
Show More
uisetup.py
204 lines | 8.7 KiB | text/x-python | PythonLexer
# Copyright 2009-2010 Gregory P. Ward
# Copyright 2009-2010 Intelerad Medical Systems Incorporated
# Copyright 2010-2011 Fog Creek Software
# Copyright 2010-2011 Unity Technologies
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
'''setup for largefiles extension: uisetup'''
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial.hgweb import (
hgweb_mod,
webcommands,
)
from mercurial import (
archival,
cmdutil,
commands,
copies,
exchange,
extensions,
filemerge,
hg,
httppeer,
merge,
scmutil,
sshpeer,
subrepo,
wireproto,
)
from . import (
overrides,
proto,
)
def uisetup(ui):
# Disable auto-status for some commands which assume that all
# files in the result are under Mercurial's control
entry = extensions.wrapcommand(commands.table, 'add',
overrides.overrideadd)
addopt = [('', 'large', None, _('add as largefile')),
('', 'normal', None, _('add as normal file')),
('', 'lfsize', '', _('add all files above this size '
'(in megabytes) as largefiles '
'(default: 10)'))]
entry[1].extend(addopt)
# The scmutil function is called both by the (trivial) addremove command,
# and in the process of handling commit -A (issue3542)
entry = extensions.wrapfunction(scmutil, 'addremove',
overrides.scmutiladdremove)
extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd)
extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove)
extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies)
# Subrepos call status function
entry = extensions.wrapcommand(commands.table, 'status',
overrides.overridestatus)
entry = extensions.wrapfunction(subrepo.hgsubrepo, 'status',
overrides.overridestatusfn)
entry = extensions.wrapcommand(commands.table, 'log',
overrides.overridelog)
entry = extensions.wrapcommand(commands.table, 'rollback',
overrides.overriderollback)
entry = extensions.wrapcommand(commands.table, 'verify',
overrides.overrideverify)
verifyopt = [('', 'large', None,
_('verify that all largefiles in current revision exists')),
('', 'lfa', None,
_('verify largefiles in all revisions, not just current')),
('', 'lfc', None,
_('verify local largefile contents, not just existence'))]
entry[1].extend(verifyopt)
entry = extensions.wrapcommand(commands.table, 'debugstate',
overrides.overridedebugstate)
debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
entry[1].extend(debugstateopt)
outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
entry[1].extend(outgoingopt)
cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
entry = extensions.wrapcommand(commands.table, 'summary',
overrides.overridesummary)
summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
entry[1].extend(summaryopt)
cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
entry = extensions.wrapcommand(commands.table, 'pull',
overrides.overridepull)
pullopt = [('', 'all-largefiles', None,
_('download all pulled versions of largefiles (DEPRECATED)')),
('', 'lfrev', [],
_('download largefiles for these revisions'), _('REV'))]
entry[1].extend(pullopt)
entry = extensions.wrapcommand(commands.table, 'push',
overrides.overridepush)
pushopt = [('', 'lfrev', [],
_('upload largefiles for these revisions'), _('REV'))]
entry[1].extend(pushopt)
entry = extensions.wrapfunction(exchange, 'pushoperation',
overrides.exchangepushoperation)
entry = extensions.wrapcommand(commands.table, 'clone',
overrides.overrideclone)
cloneopt = [('', 'all-largefiles', None,
_('download all versions of all largefiles'))]
entry[1].extend(cloneopt)
entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone)
entry = extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
entry = extensions.wrapcommand(commands.table, 'cat',
overrides.overridecat)
entry = extensions.wrapfunction(merge, '_checkunknownfile',
overrides.overridecheckunknownfile)
entry = extensions.wrapfunction(merge, 'calculateupdates',
overrides.overridecalculateupdates)
entry = extensions.wrapfunction(merge, 'recordupdates',
overrides.mergerecordupdates)
entry = extensions.wrapfunction(merge, 'update',
overrides.mergeupdate)
entry = extensions.wrapfunction(filemerge, '_filemerge',
overrides.overridefilemerge)
entry = extensions.wrapfunction(cmdutil, 'copy',
overrides.overridecopy)
# Summary calls dirty on the subrepos
entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty',
overrides.overridedirty)
entry = extensions.wrapfunction(cmdutil, 'revert',
overrides.overriderevert)
extensions.wrapcommand(commands.table, 'archive',
overrides.overridearchivecmd)
extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
overrides.hgsubrepoarchive)
extensions.wrapfunction(webcommands, 'archive',
overrides.hgwebarchive)
extensions.wrapfunction(cmdutil, 'bailifchanged',
overrides.overridebailifchanged)
extensions.wrapfunction(cmdutil, 'postcommitstatus',
overrides.postcommitstatus)
extensions.wrapfunction(scmutil, 'marktouched',
overrides.scmutilmarktouched)
# create the new wireproto commands ...
wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
# ... and wrap some existing ones
wireproto.commands['capabilities'] = (proto.capabilities, '')
wireproto.commands['heads'] = (proto.heads, '')
wireproto.commands['lheads'] = (wireproto.heads, '')
# make putlfile behave the same as push and {get,stat}lfile behave
# the same as pull w.r.t. permissions checks
hgweb_mod.perms['putlfile'] = 'push'
hgweb_mod.perms['getlfile'] = 'pull'
hgweb_mod.perms['statlfile'] = 'pull'
extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
# the hello wireproto command uses wireproto.capabilities, so it won't see
# our largefiles capability unless we replace the actual function as well.
proto.capabilitiesorig = wireproto.capabilities
wireproto.capabilities = proto.capabilities
# can't do this in reposetup because it needs to have happened before
# wirerepo.__init__ is called
proto.ssholdcallstream = sshpeer.sshpeer._callstream
proto.httpoldcallstream = httppeer.httppeer._callstream
sshpeer.sshpeer._callstream = proto.sshrepocallstream
httppeer.httppeer._callstream = proto.httprepocallstream
# override some extensions' stuff as well
for name, module in extensions.extensions():
if name == 'purge':
extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
overrides.overridepurge)
if name == 'rebase':
extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
overrides.overriderebase)
extensions.wrapfunction(module, 'rebase',
overrides.overriderebase)
if name == 'transplant':
extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
overrides.overridetransplant)