##// END OF EJS Templates
narrow: mark the critical chunks of narrowing/widening as unsafe...
Augie Fackler -
r38547:a1d5951e default
parent child Browse files
Show More
@@ -203,50 +203,51 b' def _narrow(ui, repo, remote, commoninc,'
203 hint=_('use --force-delete-local-changes to '
203 hint=_('use --force-delete-local-changes to '
204 'ignore'))
204 'ignore'))
205
205
206 if revstostrip:
206 with ui.uninterruptable():
207 tostrip = [unfi.changelog.node(r) for r in revstostrip]
207 if revstostrip:
208 if repo['.'].node() in tostrip:
208 tostrip = [unfi.changelog.node(r) for r in revstostrip]
209 # stripping working copy, so move to a different commit first
209 if repo['.'].node() in tostrip:
210 urev = max(repo.revs('(::%n) - %ln + null',
210 # stripping working copy, so move to a different commit first
211 repo['.'].node(), visibletostrip))
211 urev = max(repo.revs('(::%n) - %ln + null',
212 hg.clean(repo, urev)
212 repo['.'].node(), visibletostrip))
213 repair.strip(ui, unfi, tostrip, topic='narrow')
213 hg.clean(repo, urev)
214 repair.strip(ui, unfi, tostrip, topic='narrow')
214
215
215 todelete = []
216 todelete = []
216 for f, f2, size in repo.store.datafiles():
217 for f, f2, size in repo.store.datafiles():
217 if f.startswith('data/'):
218 if f.startswith('data/'):
218 file = f[5:-2]
219 file = f[5:-2]
219 if not newmatch(file):
220 if not newmatch(file):
220 todelete.append(f)
221 todelete.append(f)
221 elif f.startswith('meta/'):
222 elif f.startswith('meta/'):
222 dir = f[5:-13]
223 dir = f[5:-13]
223 dirs = ['.'] + sorted(util.dirs({dir})) + [dir]
224 dirs = ['.'] + sorted(util.dirs({dir})) + [dir]
224 include = True
225 include = True
225 for d in dirs:
226 for d in dirs:
226 visit = newmatch.visitdir(d)
227 visit = newmatch.visitdir(d)
227 if not visit:
228 if not visit:
228 include = False
229 include = False
229 break
230 break
230 if visit == 'all':
231 if visit == 'all':
231 break
232 break
232 if not include:
233 if not include:
233 todelete.append(f)
234 todelete.append(f)
234
235
235 repo.destroying()
236 repo.destroying()
236
237
237 with repo.transaction("narrowing"):
238 with repo.transaction("narrowing"):
238 for f in todelete:
239 for f in todelete:
239 ui.status(_('deleting %s\n') % f)
240 ui.status(_('deleting %s\n') % f)
240 util.unlinkpath(repo.svfs.join(f))
241 util.unlinkpath(repo.svfs.join(f))
241 repo.store.markremoved(f)
242 repo.store.markremoved(f)
242
243
243 for f in repo.dirstate:
244 for f in repo.dirstate:
244 if not newmatch(f):
245 if not newmatch(f):
245 repo.dirstate.drop(f)
246 repo.dirstate.drop(f)
246 repo.wvfs.unlinkpath(f)
247 repo.wvfs.unlinkpath(f)
247 repo.setnarrowpats(newincludes, newexcludes)
248 repo.setnarrowpats(newincludes, newexcludes)
248
249
249 repo.destroyed()
250 repo.destroyed()
250
251
251 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
252 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
252 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
253 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
@@ -269,28 +270,29 b' def _widen(ui, repo, remote, commoninc, '
269 repo.setnarrowpats(newincludes, newexcludes)
270 repo.setnarrowpats(newincludes, newexcludes)
270 repo.setnewnarrowpats = setnewnarrowpats
271 repo.setnewnarrowpats = setnewnarrowpats
271
272
272 ds = repo.dirstate
273 with ui.uninterruptable():
273 p1, p2 = ds.p1(), ds.p2()
274 ds = repo.dirstate
274 with ds.parentchange():
275 p1, p2 = ds.p1(), ds.p2()
275 ds.setparents(node.nullid, node.nullid)
276 with ds.parentchange():
276 common = commoninc[0]
277 ds.setparents(node.nullid, node.nullid)
277 with wrappedextraprepare:
278 common = commoninc[0]
278 exchange.pull(repo, remote, heads=common)
279 with wrappedextraprepare:
279 with ds.parentchange():
280 exchange.pull(repo, remote, heads=common)
280 ds.setparents(p1, p2)
281 with ds.parentchange():
282 ds.setparents(p1, p2)
281
283
282 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
284 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
283 addgaction = actions['g'].append
285 addgaction = actions['g'].append
284
286
285 mf = repo['.'].manifest().matches(newmatch)
287 mf = repo['.'].manifest().matches(newmatch)
286 for f, fn in mf.iteritems():
288 for f, fn in mf.iteritems():
287 if f not in repo.dirstate:
289 if f not in repo.dirstate:
288 addgaction((f, (mf.flags(f), False),
290 addgaction((f, (mf.flags(f), False),
289 "add from widened narrow clone"))
291 "add from widened narrow clone"))
290
292
291 merge.applyupdates(repo, actions, wctx=repo[None],
293 merge.applyupdates(repo, actions, wctx=repo[None],
292 mctx=repo['.'], overwrite=False)
294 mctx=repo['.'], overwrite=False)
293 merge.recordupdates(repo, actions, branchmerge=False)
295 merge.recordupdates(repo, actions, branchmerge=False)
294
296
295 # TODO(rdamazio): Make new matcher format and update description
297 # TODO(rdamazio): Make new matcher format and update description
296 @command('tracked',
298 @command('tracked',
General Comments 0
You need to be logged in to leave comments. Login now