Mercurial > evolve
diff hgext/inhibit.py @ 1234:c15d4677f2ba
inhibit: ensure that no obsolete changesets are visible after a bookmark change
When creating a bookmark, we could reveal obsolete changesets. We are
inhibiting the obsolete changesets resulting from a bookmark change.
There are two ways to record bookmark changes to disk and we wrap both.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Mon, 30 Mar 2015 13:31:09 -0700 |
parents | 63ee05dd557a |
children | e1347ce2f954 |
line wrap: on
line diff
--- a/hgext/inhibit.py Mon Mar 30 11:45:17 2015 -0700 +++ b/hgext/inhibit.py Mon Mar 30 13:31:09 2015 -0700 @@ -29,6 +29,7 @@ from mercurial import revset from mercurial import error from mercurial import commands +from mercurial import bookmarks cmdtable = {} command = cmdutil.command(cmdtable) @@ -61,6 +62,12 @@ _inhibitmarkers(repo, [newhead]) return res +def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs): + """ Add inhibition markers to every obsolete bookmarks """ + repo = bkmstoreinst._repo + bkmstorenodes = [repo[v].node() for v in bkmstoreinst.values()] + _inhibitmarkers(repo, bkmstorenodes) + return orig(bkmstoreinst, *args, **kwargs) # obsolescence inhibitor ######################## @@ -154,6 +161,11 @@ # wrap update to make sure that no obsolete commit is visible after an # update extensions.wrapcommand(commands.table, 'update', _update) + # There are two ways to save bookmark changes during a transation, we + # wrap both to add inhibition markers. + extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged) + extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged) + def gethashsymbols(tree): # Returns the list of symbols of the tree that look like hashes