Mercurial > evolve
comparison hgext/inhibit.py @ 1541:23a34dce5131
inhibit: remove unused bookmark operation wrapping
Before this patch, inhibit was wrapping bookmarks.write and
bookmarks.recordchange. Since all the usage of bookmarks.write are not replaced
by bookmarks.recordchange all bookmarks operation happen in a transaction.
Inhibit already wraps the transaction mechanism to make sure that no revision
can end up being obsolete and visible. This makes the wrapping of
bookmarks.write superfluous.
Wrapping bookmarks.recordchange was wrong in the first place and redundant with
wrapping transactions.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Tue, 24 Nov 2015 17:16:27 -0800 |
parents | 72f50a177806 |
children | 333e056b3034 |
comparison
equal
deleted
inserted
replaced
1540:5a1cfb1160a6 | 1541:23a34dce5131 |
---|---|
19 from mercurial import extensions | 19 from mercurial import extensions |
20 from mercurial import cmdutil | 20 from mercurial import cmdutil |
21 from mercurial import scmutil | 21 from mercurial import scmutil |
22 from mercurial import commands | 22 from mercurial import commands |
23 from mercurial import lock as lockmod | 23 from mercurial import lock as lockmod |
24 from mercurial import bookmarks | |
25 from mercurial import util | 24 from mercurial import util |
26 from mercurial.i18n import _ | 25 from mercurial.i18n import _ |
27 | 26 |
28 cmdtable = {} | 27 cmdtable = {} |
29 command = cmdutil.command(cmdtable) | 28 command = cmdutil.command(cmdtable) |
69 newhead = repo['.'].node() | 68 newhead = repo['.'].node() |
70 _inhibitmarkers(repo, [newhead]) | 69 _inhibitmarkers(repo, [newhead]) |
71 return res | 70 return res |
72 finally: | 71 finally: |
73 lockmod.release(wlock) | 72 lockmod.release(wlock) |
74 | |
75 def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs): | |
76 """ Add inhibition markers to every obsolete bookmarks """ | |
77 repo = bkmstoreinst._repo | |
78 bkmstorenodes = [repo[v].node() for v in bkmstoreinst.values()] | |
79 _inhibitmarkers(repo, bkmstorenodes) | |
80 return orig(bkmstoreinst, *args, **kwargs) | |
81 | 73 |
82 def _bookmark(orig, ui, repo, *bookmarks, **opts): | 74 def _bookmark(orig, ui, repo, *bookmarks, **opts): |
83 """ Add a -D option to the bookmark command, map it to prune -B """ | 75 """ Add a -D option to the bookmark command, map it to prune -B """ |
84 haspruneopt = opts.get('prune', False) | 76 haspruneopt = opts.get('prune', False) |
85 if not haspruneopt: | 77 if not haspruneopt: |
239 # drop bumped computation since it is incompatible with "light revive" | 231 # drop bumped computation since it is incompatible with "light revive" |
240 obsolete.cachefuncs['bumped'] = lambda repo: set() | 232 obsolete.cachefuncs['bumped'] = lambda repo: set() |
241 # wrap update to make sure that no obsolete commit is visible after an | 233 # wrap update to make sure that no obsolete commit is visible after an |
242 # update | 234 # update |
243 extensions.wrapcommand(commands.table, 'update', _update) | 235 extensions.wrapcommand(commands.table, 'update', _update) |
244 # There are two ways to save bookmark changes during a transation, we | |
245 # wrap both to add inhibition markers. | |
246 extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged) | |
247 extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged) | |
248 # Add bookmark -D option | 236 # Add bookmark -D option |
249 entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark) | 237 entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark) |
250 entry[1].append(('D','prune',None, | 238 entry[1].append(('D','prune',None, |
251 _('delete the bookmark and prune the commits underneath'))) | 239 _('delete the bookmark and prune the commits underneath'))) |
252 | 240 |