annotate hgext/inhibit.py @ 1711:7a2e0629bdee stable

inhibit: protect agains dropped 'bmstore.write' As planned per the deprecation policy, 'bmstore.write' have been dropped in Mercurial core (052c9318e464).
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 27 May 2016 17:33:53 +0200
parents ca5c8a827407
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
1 """reduce the changesets evolution feature scope for early and noob friendly ui
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
2
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
3 the full scale changeset evolution have some massive bleeding edge and it is
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
4 very easy for people not very intimate with the concept to end up in intricate
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
5 situation. in order to get some of the benefit sooner, this extension is
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
6 disabling some of the less polished aspect of evolution. it should gradually
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
7 get thinner and thinner as changeset evolution will get more polished. this
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
8 extension is only recommended for large scale organisations. individual user
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
9 should probably stick on using evolution in its current state, understand its
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
10 concept and provide feedback
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
11
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
12 This extension provides the ability to "inhibit" obsolescence markers. obsolete
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
13 revision can be cheaply brought back to life that way.
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
14 However as the inhibitor are not fitting in an append only model, this is
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
15 incompatible with sharing mutable history.
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
16 """
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
17 from mercurial import localrepo
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
18 from mercurial import obsolete
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
19 from mercurial import extensions
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
20 from mercurial import cmdutil
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
21 from mercurial import error
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
22 from mercurial import scmutil
1233
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
23 from mercurial import commands
1297
51ec3610968c inhibit: fix devel warning
Laurent Charignon <lcharignon@fb.com>
parents: 1293
diff changeset
24 from mercurial import lock as lockmod
1560
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
25 from mercurial import bookmarks
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
26 from mercurial import util
1241
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
27 from mercurial.i18n import _
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
28
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
29 cmdtable = {}
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
30 command = cmdutil.command(cmdtable)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
31
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
32 def _inhibitenabled(repo):
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
33 return util.safehasattr(repo, '_obsinhibit')
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
34
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
35 def reposetup(ui, repo):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
36
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
37 class obsinhibitedrepo(repo.__class__):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
38
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
39 @localrepo.storecache('obsinhibit')
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
40 def _obsinhibit(self):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
41 # XXX we should make sure it is invalidated by transaction failure
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
42 obsinhibit = set()
1465
777e5c369d99 compat: use svfs instead of sopener
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1366
diff changeset
43 raw = self.svfs.tryread('obsinhibit')
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
44 for i in xrange(0, len(raw), 20):
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
45 obsinhibit.add(raw[i:i + 20])
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
46 return obsinhibit
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
47
1292
62229e7451f7 inhibit: wrap repo.commit to inhibit nodes
Durham Goode <durham@fb.com>
parents: 1247
diff changeset
48 def commit(self, *args, **kwargs):
62229e7451f7 inhibit: wrap repo.commit to inhibit nodes
Durham Goode <durham@fb.com>
parents: 1247
diff changeset
49 newnode = super(obsinhibitedrepo, self).commit(*args, **kwargs)
1346
9a1415f8b21b inhbit: don't crash on commit with no changes
Laurent Charignon <lcharignon@fb.com>
parents: 1339
diff changeset
50 if newnode is not None:
9a1415f8b21b inhbit: don't crash on commit with no changes
Laurent Charignon <lcharignon@fb.com>
parents: 1339
diff changeset
51 _inhibitmarkers(repo, [newnode])
1292
62229e7451f7 inhibit: wrap repo.commit to inhibit nodes
Durham Goode <durham@fb.com>
parents: 1247
diff changeset
52 return newnode
62229e7451f7 inhibit: wrap repo.commit to inhibit nodes
Durham Goode <durham@fb.com>
parents: 1247
diff changeset
53
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
54 repo.__class__ = obsinhibitedrepo
1233
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
55
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
56 def _update(orig, ui, repo, *args, **kwargs):
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
57 """
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
58 When moving to a commit we want to inhibit any obsolete commit affecting
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
59 the changeset we are updating to. In other words we don't want any visible
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
60 commit to be obsolete.
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
61 """
1303
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
62 wlock = None
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
63 try:
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
64 # Evolve is running a hook on lock release to display a warning message
1303
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
65 # if the workind dir's parent is obsolete.
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
66 # We take the lock here to make sure that we inhibit the parent before
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
67 # that hook get a chance to run.
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
68 wlock = repo.wlock()
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
69 res = orig(ui, repo, *args, **kwargs)
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
70 newhead = repo['.'].node()
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
71 _inhibitmarkers(repo, [newhead])
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
72 return res
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
73 finally:
508f9911b042 inhibit: updating to a obsolete commit prints warning message
Laurent Charignon <lcharignon@fb.com>
parents: 1297
diff changeset
74 lockmod.release(wlock)
1233
63ee05dd557a inhibit: ensure no visible changesets are obsolete after an update
Laurent Charignon <lcharignon@fb.com>
parents: 1232
diff changeset
75
1560
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
76 def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
77 """ Add inhibition markers to every obsolete bookmarks """
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
78 repo = bkmstoreinst._repo
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
79 bkmstorenodes = [repo[v].node() for v in bkmstoreinst.values()]
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
80 _inhibitmarkers(repo, bkmstorenodes)
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
81 return orig(bkmstoreinst, *args, **kwargs)
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
82
1241
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
83 def _bookmark(orig, ui, repo, *bookmarks, **opts):
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
84 """ Add a -D option to the bookmark command, map it to prune -B """
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
85 haspruneopt = opts.get('prune', False)
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
86 if not haspruneopt:
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
87 return orig(ui, repo, *bookmarks, **opts)
1538
ef5da2310398 inhibit: improve handling of error cases for bookmark -D
Laurent Charignon <lcharignon@fb.com>
parents: 1535
diff changeset
88 elif opts.get('rename'):
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
89 raise error.Abort('Cannot use both -m and -D')
1538
ef5da2310398 inhibit: improve handling of error cases for bookmark -D
Laurent Charignon <lcharignon@fb.com>
parents: 1535
diff changeset
90 elif len(bookmarks) == 0:
ef5da2310398 inhibit: improve handling of error cases for bookmark -D
Laurent Charignon <lcharignon@fb.com>
parents: 1535
diff changeset
91 hint = _('make sure to put a space between -D and your bookmark name')
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
92 raise error.Abort(_('Error, please check your command'), hint=hint)
1293
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
93
1241
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
94 # Call prune -B
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
95 evolve = extensions.find('evolve')
1293
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
96 optsdict = {
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
97 'new': [],
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
98 'succ': [],
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
99 'rev': [],
1590
ca5c8a827407 inhibit: make bookmark -D work with a list of bookmarks
Jeroen Vaelen <jeroen@fb.com>
parents: 1588
diff changeset
100 'bookmark': bookmarks,
1293
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
101 'keep': None,
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
102 'biject': False,
dc5528e04c06 inhibit: remove book -D dependency on cmdprune
Durham Goode <durham@fb.com>
parents: 1292
diff changeset
103 }
1241
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
104 evolve.cmdprune(ui, repo, **optsdict)
3625d006e81b inhibit: Add -D option to the bookmark command
Laurent Charignon <lcharignon@fb.com>
parents: 1240
diff changeset
105
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
106 # obsolescence inhibitor
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
107 ########################
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
108
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
109 def _schedulewrite(tr, obsinhibit):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
110 """Make sure on disk content will be updated on transaction commit"""
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
111 def writer(fp):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
112 """Serialize the inhibited list to disk.
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
113 """
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
114 raw = ''.join(obsinhibit)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
115 fp.write(raw)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
116 tr.addfilegenerator('obsinhibit', ('obsinhibit',), writer)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
117 tr.hookargs['obs_inbihited'] = '1'
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
118
1225
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
119 def _filterpublic(repo, nodes):
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
120 """filter out inhibitor on public changeset
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
121
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
122 Public changesets are already immune to obsolescence"""
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
123 getrev = repo.changelog.nodemap.get
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
124 getphase = repo._phasecache.phase
1582
aa42a6ad9c5c inhibit: fix _filterpublic
Laurent Charignon <lcharignon@fb.com>
parents: 1564
diff changeset
125 return (n for n in nodes
1338
77cbf9121e8a inhibit: handle inhibit marker on stripped revision
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1334
diff changeset
126 if getrev(n) is not None and getphase(repo, getrev(n)))
1225
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
127
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
128 def _inhibitmarkers(repo, nodes):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
129 """add marker inhibitor for all obsolete revision under <nodes>
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
130
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
131 Content of <nodes> and all mutable ancestors are considered. Marker for
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
132 obsolete revision only are created.
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
133 """
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
134 if not _inhibitenabled(repo):
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
135 return
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
136
1535
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
137 # we add (non public()) as a lower boundary to
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
138 # - use the C code in 3.6 (no ancestors in C as this is written)
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
139 # - restrict the search space. Otherwise, the ancestors can spend a lot of
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
140 # time iterating if you have a check very low in the repo. We do not need
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
141 # to iterate over tens of thousand of public revisions with higher
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
142 # revision number
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
143 #
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
144 # In addition, the revset logic could be made significantly smarter here.
f6d10432499d inhibit: use dirty revset trick to speedup the inhibit search space.
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1534
diff changeset
145 newinhibit = repo.revs('(not public())::%ln and obsolete()', nodes)
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
146 if newinhibit:
1534
9a78ed4b9765 inhibit: use 'repo.revs' instead of 'repo.set'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1533
diff changeset
147 node = repo.changelog.node
1297
51ec3610968c inhibit: fix devel warning
Laurent Charignon <lcharignon@fb.com>
parents: 1293
diff changeset
148 lock = tr = None
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
149 try:
1297
51ec3610968c inhibit: fix devel warning
Laurent Charignon <lcharignon@fb.com>
parents: 1293
diff changeset
150 lock = repo.lock()
51ec3610968c inhibit: fix devel warning
Laurent Charignon <lcharignon@fb.com>
parents: 1293
diff changeset
151 tr = repo.transaction('obsinhibit')
1534
9a78ed4b9765 inhibit: use 'repo.revs' instead of 'repo.set'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1533
diff changeset
152 repo._obsinhibit.update(node(r) for r in newinhibit)
1225
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
153 _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit))
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
154 repo.invalidatevolatilesets()
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
155 tr.close()
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
156 finally:
1297
51ec3610968c inhibit: fix devel warning
Laurent Charignon <lcharignon@fb.com>
parents: 1293
diff changeset
157 lockmod.release(tr, lock)
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
158
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
159 def _deinhibitmarkers(repo, nodes):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
160 """lift obsolescence inhibition on a set of nodes
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
161
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
162 This will be triggered when inhibited nodes received new obsolescence
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
163 markers. Otherwise the new obsolescence markers would also be inhibited.
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
164 """
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
165 if not _inhibitenabled(repo):
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
166 return
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
167
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
168 deinhibited = repo._obsinhibit & set(nodes)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
169 if deinhibited:
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
170 tr = repo.transaction('obsinhibit')
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
171 try:
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
172 repo._obsinhibit -= deinhibited
1225
577f5340be6f inhibit: Add some inhibition clearing mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1224
diff changeset
173 _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit))
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
174 repo.invalidatevolatilesets()
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
175 tr.close()
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
176 finally:
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
177 tr.release()
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
178
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
179 def _createmarkers(orig, repo, relations, flag=0, date=None, metadata=None):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
180 """wrap markers create to make sure we de-inhibit target nodes"""
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
181 # wrapping transactio to unify the one in each function
1472
a8a4c8b8550d inhibit: add missing locking in wrapper for obsmarker creation
Laurent Charignon <lcharignon@fb.com>
parents: 1465
diff changeset
182 lock = tr = None
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
183 try:
1472
a8a4c8b8550d inhibit: add missing locking in wrapper for obsmarker creation
Laurent Charignon <lcharignon@fb.com>
parents: 1465
diff changeset
184 lock = repo.lock()
a8a4c8b8550d inhibit: add missing locking in wrapper for obsmarker creation
Laurent Charignon <lcharignon@fb.com>
parents: 1465
diff changeset
185 tr = repo.transaction('add-obsolescence-marker')
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
186 orig(repo, relations, flag, date, metadata)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
187 precs = (r[0].node() for r in relations)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
188 _deinhibitmarkers(repo, precs)
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
189 tr.close()
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
190 finally:
1472
a8a4c8b8550d inhibit: add missing locking in wrapper for obsmarker creation
Laurent Charignon <lcharignon@fb.com>
parents: 1465
diff changeset
191 lockmod.release(tr, lock)
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
192
1583
aaa65373a31b inhibit: fix compatibility with changes in rebase
Laurent Charignon <lcharignon@fb.com>
parents: 1582
diff changeset
193 def _filterobsoleterevswrap(orig, repo, rebasesetrevs, *args, **kwargs):
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
194 repo._notinhibited = rebasesetrevs
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
195 try:
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
196 repo.invalidatevolatilesets()
1583
aaa65373a31b inhibit: fix compatibility with changes in rebase
Laurent Charignon <lcharignon@fb.com>
parents: 1582
diff changeset
197 r = orig(repo, rebasesetrevs, *args, **kwargs)
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
198 finally:
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
199 del repo._notinhibited
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
200 repo.invalidatevolatilesets()
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
201 return r
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
202
1486
e8ebb2441e60 inhibit: do not search for visible obsolete changeset during stripping
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1472
diff changeset
203 def transactioncallback(orig, repo, desc, *args, **kwargs):
1240
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
204 """ Wrap localrepo.transaction to inhibit new obsolete changes """
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
205 def inhibitposttransaction(transaction):
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
206 # At the end of the transaction we catch all the new visible and
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
207 # obsolete commit to inhibit them
1362
73e5b5280c1c inhibit: improve performance of transaction wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1346
diff changeset
208 visibleobsolete = repo.revs('obsolete() - hidden()')
1321
8fa74845eb1f inhibit: don't inhibit pinned commits during rebase
Durham Goode <durham@fb.com>
parents: 1303
diff changeset
209 ignoreset = set(getattr(repo, '_rebaseset', []))
1588
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
210 ignoreset |= set(getattr(repo, '_obsoletenotrebased', []))
1321
8fa74845eb1f inhibit: don't inhibit pinned commits during rebase
Durham Goode <durham@fb.com>
parents: 1303
diff changeset
211 visibleobsolete = list(r for r in visibleobsolete if r not in ignoreset)
1240
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
212 if visibleobsolete:
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
213 _inhibitmarkers(repo, [repo[r].node() for r in visibleobsolete])
1486
e8ebb2441e60 inhibit: do not search for visible obsolete changeset during stripping
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1472
diff changeset
214 transaction = orig(repo, desc, *args, **kwargs)
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
215 if desc != 'strip' and _inhibitenabled(repo):
1551
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
216 transaction.addpostclose('inhibitposttransaction',
40e496bc7b54 check-code: make inhibit.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1542
diff changeset
217 inhibitposttransaction)
1240
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
218 return transaction
e1347ce2f954 inhibit: don't leave any obsolete commit visible after closing transaction
Laurent Charignon <lcharignon@fb.com>
parents: 1234
diff changeset
219
1588
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
220
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
221 # We wrap these two functions to address the following scenario:
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
222 # - Assuming that we have markers between commits in the rebase set and
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
223 # destination and that these markers are inhibited
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
224 # - At the end of the rebase the nodes are still visible because rebase operate
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
225 # without inhibition and skip these nodes
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
226 # We keep track in repo._obsoletenotrebased of the obsolete commits skipped by
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
227 # the rebase and lift the inhibition in the end of the rebase.
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
228
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
229 def _computeobsoletenotrebased(orig, repo, *args, **kwargs):
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
230 r = orig(repo, *args, **kwargs)
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
231 repo._obsoletenotrebased = r.keys()
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
232 return r
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
233
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
234 def _clearrebased(orig, ui, repo, *args, **kwargs):
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
235 r = orig(ui, repo, *args, **kwargs)
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
236 tonode = repo.changelog.node
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
237 if util.safehasattr(repo, '_obsoletenotrebased'):
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
238 _deinhibitmarkers(repo, [tonode(k) for k in repo._obsoletenotrebased])
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
239 return r
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
240
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
241
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
242 def extsetup(ui):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
243 # lets wrap the computation of the obsolete set
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
244 # We apply inhibition there
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
245 obsfunc = obsolete.cachefuncs['obsolete']
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
246 def _computeobsoleteset(repo):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
247 """remove any inhibited nodes from the obsolete set
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
248
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
249 This will trickle down to other part of mercurial (hidden, log, etc)"""
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
250 obs = obsfunc(repo)
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
251 if _inhibitenabled(repo):
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
252 getrev = repo.changelog.nodemap.get
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
253 blacklist = getattr(repo, '_notinhibited', set())
1490
bc7eec65dfcf inhibit: fix inhibit working with non-inhibit repos
Durham Goode <durham@fb.com>
parents: 1486
diff changeset
254 for n in repo._obsinhibit:
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
255 if getrev(n) not in blacklist:
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
256 obs.discard(getrev(n))
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
257 return obs
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
258 try:
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
259 extensions.find('directaccess')
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
260 except KeyError:
1474
8e6de39b724d inhibit: don't abort when directaccess is not enabled
Laurent Charignon <lcharignon@fb.com>
parents: 1472
diff changeset
261 errormsg = _('cannot use inhibit without the direct access extension\n')
8e6de39b724d inhibit: don't abort when directaccess is not enabled
Laurent Charignon <lcharignon@fb.com>
parents: 1472
diff changeset
262 hint = _("(please enable it or inhibit won\'t work)\n")
8e6de39b724d inhibit: don't abort when directaccess is not enabled
Laurent Charignon <lcharignon@fb.com>
parents: 1472
diff changeset
263 ui.warn(errormsg)
8e6de39b724d inhibit: don't abort when directaccess is not enabled
Laurent Charignon <lcharignon@fb.com>
parents: 1472
diff changeset
264 ui.warn(hint)
8e6de39b724d inhibit: don't abort when directaccess is not enabled
Laurent Charignon <lcharignon@fb.com>
parents: 1472
diff changeset
265 return
1366
9c3ba42c582a inhibit: move transaction wrapping outside of repo setup
Laurent Charignon <lcharignon@fb.com>
parents: 1362
diff changeset
266
9c3ba42c582a inhibit: move transaction wrapping outside of repo setup
Laurent Charignon <lcharignon@fb.com>
parents: 1362
diff changeset
267 # Wrapping this to inhibit obsolete revs resulting from a transaction
9c3ba42c582a inhibit: move transaction wrapping outside of repo setup
Laurent Charignon <lcharignon@fb.com>
parents: 1362
diff changeset
268 extensions.wrapfunction(localrepo.localrepository,
9c3ba42c582a inhibit: move transaction wrapping outside of repo setup
Laurent Charignon <lcharignon@fb.com>
parents: 1362
diff changeset
269 'transaction', transactioncallback)
9c3ba42c582a inhibit: move transaction wrapping outside of repo setup
Laurent Charignon <lcharignon@fb.com>
parents: 1362
diff changeset
270
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
271 obsolete.cachefuncs['obsolete'] = _computeobsoleteset
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
272 # wrap create marker to make it able to lift the inhibition
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
273 extensions.wrapfunction(obsolete, 'createmarkers', _createmarkers)
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
274 # drop divergence computation since it is incompatible with "light revive"
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
275 obsolete.cachefuncs['divergent'] = lambda repo: set()
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
276 # drop bumped computation since it is incompatible with "light revive"
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
277 obsolete.cachefuncs['bumped'] = lambda repo: set()
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
278 # wrap update to make sure that no obsolete commit is visible after an
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
279 # update
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
280 extensions.wrapcommand(commands.table, 'update', _update)
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
281 try:
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
282 rebase = extensions.find('rebase')
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
283 if rebase:
1583
aaa65373a31b inhibit: fix compatibility with changes in rebase
Laurent Charignon <lcharignon@fb.com>
parents: 1582
diff changeset
284 if util.safehasattr(rebase, '_filterobsoleterevs'):
aaa65373a31b inhibit: fix compatibility with changes in rebase
Laurent Charignon <lcharignon@fb.com>
parents: 1582
diff changeset
285 extensions.wrapfunction(rebase,
aaa65373a31b inhibit: fix compatibility with changes in rebase
Laurent Charignon <lcharignon@fb.com>
parents: 1582
diff changeset
286 '_filterobsoleterevs',
aaa65373a31b inhibit: fix compatibility with changes in rebase
Laurent Charignon <lcharignon@fb.com>
parents: 1582
diff changeset
287 _filterobsoleterevswrap)
1588
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
288 extensions.wrapfunction(rebase, 'clearrebased', _clearrebased)
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
289 if util.safehasattr(rebase, '_computeobsoletenotrebased'):
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
290 extensions.wrapfunction(rebase,
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
291 '_computeobsoletenotrebased',
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
292 _computeobsoletenotrebased)
983f2e4dbe5d inhibit: fix compat with rebaseskipobsolete
Laurent Charignon <lcharignon@fb.com>
parents: 1583
diff changeset
293
1542
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
294 except KeyError:
333e056b3034 inhibit: make rebase see obsolescence even for visible nodes
Laurent Charignon <lcharignon@fb.com>
parents: 1541
diff changeset
295 pass
1560
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
296 # There are two ways to save bookmark changes during a transation, we
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
297 # wrap both to add inhibition markers.
59d47a9f633d inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping
Laurent Charignon <lcharignon@fb.com>
parents: 1551
diff changeset
298 extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged)
1711
7a2e0629bdee inhibit: protect agains dropped 'bmstore.write'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1590
diff changeset
299 if getattr(bookmarks.bmstore, 'write', None) is not None:# mercurial < 3.9
7a2e0629bdee inhibit: protect agains dropped 'bmstore.write'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1590
diff changeset
300 extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
1339
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
301 # Add bookmark -D option
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
302 entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark)
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
303 entry[1].append(('D','prune',None,
0e2eb196923a inhibit: create direct access extension
Laurent Charignon <lcharignon@fb.com>
parents: 1338
diff changeset
304 _('delete the bookmark and prune the commits underneath')))
1224
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
305
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
306 @command('debugobsinhibit', [], '')
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
307 def cmddebugobsinhibit(ui, repo, *revs):
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
308 """inhibit obsolescence markers effect on a set of revs"""
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
309 nodes = (repo[r].node() for r in scmutil.revrange(repo, revs))
859a854cedc3 add a 'inhibit' extension
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
310 _inhibitmarkers(repo, nodes)