comparison hgext/inhibit.py @ 1233:63ee05dd557a

inhibit: ensure no visible changesets are obsolete after an update When updating to a commit we want to inhibit any obsolete commit affecting the changeset we are updating to. In other words we don't want any visible commit to be obsolete.
author Laurent Charignon <lcharignon@fb.com>
date Mon, 30 Mar 2015 11:45:17 -0700
parents 37c00aeb4762
children c15d4677f2ba
comparison
equal deleted inserted replaced
1232:37c00aeb4762 1233:63ee05dd557a
26 from mercurial import cmdutil 26 from mercurial import cmdutil
27 from mercurial import scmutil 27 from mercurial import scmutil
28 from mercurial import repoview 28 from mercurial import repoview
29 from mercurial import revset 29 from mercurial import revset
30 from mercurial import error 30 from mercurial import error
31 from mercurial import commands
31 32
32 cmdtable = {} 33 cmdtable = {}
33 command = cmdutil.command(cmdtable) 34 command = cmdutil.command(cmdtable)
34 35
35 def reposetup(ui, repo): 36 def reposetup(ui, repo):
45 obsinhibit.add(raw[i:i+20]) 46 obsinhibit.add(raw[i:i+20])
46 return obsinhibit 47 return obsinhibit
47 48
48 repo.__class__ = obsinhibitedrepo 49 repo.__class__ = obsinhibitedrepo
49 repo._explicitaccess = set() 50 repo._explicitaccess = set()
51
52
53 def _update(orig, ui, repo, *args, **kwargs):
54 """
55 When moving to a commit we want to inhibit any obsolete commit affecting
56 the changeset we are updating to. In other words we don't want any visible
57 commit to be obsolete.
58 """
59 res = orig(ui, repo, *args, **kwargs)
60 newhead = repo['.'].node()
61 _inhibitmarkers(repo, [newhead])
62 return res
63
50 64
51 # obsolescence inhibitor 65 # obsolescence inhibitor
52 ######################## 66 ########################
53 67
54 def _schedulewrite(tr, obsinhibit): 68 def _schedulewrite(tr, obsinhibit):
135 obsolete.cachefuncs['bumped'] = lambda repo: set() 149 obsolete.cachefuncs['bumped'] = lambda repo: set()
136 # wrap create marker to make it able to lift the inhibition 150 # wrap create marker to make it able to lift the inhibition
137 extensions.wrapfunction(obsolete, 'createmarkers', _createmarkers) 151 extensions.wrapfunction(obsolete, 'createmarkers', _createmarkers)
138 extensions.wrapfunction(repoview, '_getdynamicblockers', _accessvisible) 152 extensions.wrapfunction(repoview, '_getdynamicblockers', _accessvisible)
139 extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook) 153 extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook)
154 # wrap update to make sure that no obsolete commit is visible after an
155 # update
156 extensions.wrapcommand(commands.table, 'update', _update)
140 157
141 def gethashsymbols(tree): 158 def gethashsymbols(tree):
142 # Returns the list of symbols of the tree that look like hashes 159 # Returns the list of symbols of the tree that look like hashes
143 # for example for the revset 3::abe3ff it will return ('abe3ff') 160 # for example for the revset 3::abe3ff it will return ('abe3ff')
144 if not tree: 161 if not tree: