Mercurial > evolve
comparison hgext/inhibit.py @ 1491:8f469f81129c
merge with stable
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 12 Aug 2015 20:38:39 -0700 |
parents | 3dec62fc266e bc7eec65dfcf |
children | 74cf5a69f201 |
comparison
equal
deleted
inserted
replaced
1488:3dec62fc266e | 1491:8f469f81129c |
---|---|
21 from mercurial import error | 21 from mercurial import error |
22 from mercurial import scmutil | 22 from mercurial import scmutil |
23 from mercurial import commands | 23 from mercurial import commands |
24 from mercurial import lock as lockmod | 24 from mercurial import lock as lockmod |
25 from mercurial import bookmarks | 25 from mercurial import bookmarks |
26 from mercurial import util | |
26 from mercurial.i18n import _ | 27 from mercurial.i18n import _ |
27 | 28 |
28 cmdtable = {} | 29 cmdtable = {} |
29 command = cmdutil.command(cmdtable) | 30 command = cmdutil.command(cmdtable) |
31 | |
32 def _inhibitenabled(repo): | |
33 return util.safehasattr(repo, '_obsinhibit') | |
30 | 34 |
31 def reposetup(ui, repo): | 35 def reposetup(ui, repo): |
32 | 36 |
33 class obsinhibitedrepo(repo.__class__): | 37 class obsinhibitedrepo(repo.__class__): |
34 | 38 |
120 """add marker inhibitor for all obsolete revision under <nodes> | 124 """add marker inhibitor for all obsolete revision under <nodes> |
121 | 125 |
122 Content of <nodes> and all mutable ancestors are considered. Marker for | 126 Content of <nodes> and all mutable ancestors are considered. Marker for |
123 obsolete revision only are created. | 127 obsolete revision only are created. |
124 """ | 128 """ |
129 if not _inhibitenabled(repo): | |
130 return | |
131 | |
125 newinhibit = repo.set('::%ln and obsolete()', nodes) | 132 newinhibit = repo.set('::%ln and obsolete()', nodes) |
126 if newinhibit: | 133 if newinhibit: |
127 lock = tr = None | 134 lock = tr = None |
128 try: | 135 try: |
129 lock = repo.lock() | 136 lock = repo.lock() |
139 """lift obsolescence inhibition on a set of nodes | 146 """lift obsolescence inhibition on a set of nodes |
140 | 147 |
141 This will be triggered when inhibited nodes received new obsolescence | 148 This will be triggered when inhibited nodes received new obsolescence |
142 markers. Otherwise the new obsolescence markers would also be inhibited. | 149 markers. Otherwise the new obsolescence markers would also be inhibited. |
143 """ | 150 """ |
151 if not _inhibitenabled(repo): | |
152 return | |
153 | |
144 deinhibited = repo._obsinhibit & set(nodes) | 154 deinhibited = repo._obsinhibit & set(nodes) |
145 if deinhibited: | 155 if deinhibited: |
146 tr = repo.transaction('obsinhibit') | 156 tr = repo.transaction('obsinhibit') |
147 try: | 157 try: |
148 repo._obsinhibit -= deinhibited | 158 repo._obsinhibit -= deinhibited |
175 ignoreset = set(getattr(repo, '_rebaseset', [])) | 185 ignoreset = set(getattr(repo, '_rebaseset', [])) |
176 visibleobsolete = list(r for r in visibleobsolete if r not in ignoreset) | 186 visibleobsolete = list(r for r in visibleobsolete if r not in ignoreset) |
177 if visibleobsolete: | 187 if visibleobsolete: |
178 _inhibitmarkers(repo, [repo[r].node() for r in visibleobsolete]) | 188 _inhibitmarkers(repo, [repo[r].node() for r in visibleobsolete]) |
179 transaction = orig(repo, desc, *args, **kwargs) | 189 transaction = orig(repo, desc, *args, **kwargs) |
180 if desc != 'strip': | 190 if desc != 'strip' and _inhibitenabled(repo): |
181 transaction.addpostclose('inhibitposttransaction', inhibitposttransaction) | 191 transaction.addpostclose('inhibitposttransaction', inhibitposttransaction) |
182 return transaction | 192 return transaction |
183 | 193 |
184 def extsetup(ui): | 194 def extsetup(ui): |
185 # lets wrap the computation of the obsolete set | 195 # lets wrap the computation of the obsolete set |
188 def _computeobsoleteset(repo): | 198 def _computeobsoleteset(repo): |
189 """remove any inhibited nodes from the obsolete set | 199 """remove any inhibited nodes from the obsolete set |
190 | 200 |
191 This will trickle down to other part of mercurial (hidden, log, etc)""" | 201 This will trickle down to other part of mercurial (hidden, log, etc)""" |
192 obs = obsfunc(repo) | 202 obs = obsfunc(repo) |
193 getrev = repo.changelog.nodemap.get | 203 if _inhibitenabled(repo): |
194 for n in repo._obsinhibit: | 204 getrev = repo.changelog.nodemap.get |
195 obs.discard(getrev(n)) | 205 for n in repo._obsinhibit: |
206 obs.discard(getrev(n)) | |
196 return obs | 207 return obs |
197 try: | 208 try: |
198 extensions.find('directaccess') | 209 extensions.find('directaccess') |
199 except KeyError: | 210 except KeyError: |
200 errormsg = _('cannot use inhibit without the direct access extension\n') | 211 errormsg = _('cannot use inhibit without the direct access extension\n') |