##// END OF EJS Templates
merge: split out mostly-non-interactive working dir updates...
Bryan O'Sullivan -
r18630:9b9e2d9e default
parent child Browse files
Show More
@@ -342,6 +342,34 b' def manifestmerge(repo, wctx, p2, pa, br'
342 def actionkey(a):
342 def actionkey(a):
343 return a[1] == "r" and -1 or 0, a
343 return a[1] == "r" and -1 or 0, a
344
344
345 def getremove(repo, wctx, mctx, overwrite, args):
346 """apply usually-non-interactive updates to the working directory
347
348 wctx is the working copy context
349 mctx is the context to be merged into the working copy
350
351 yields tuples for progress updates
352 """
353 audit = repo.wopener.audit
354 for i, arg in enumerate(args):
355 f = arg[0]
356 if arg[1] == 'r':
357 repo.ui.note(_("removing %s\n") % f)
358 if f == '.hgsubstate': # subrepo states need updating
359 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
360 audit(f)
361 try:
362 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
363 except OSError, inst:
364 repo.ui.warn(_("update failed to remove %s: %s!\n") %
365 (f, inst.strerror))
366 else:
367 repo.ui.note(_("getting %s\n") % f)
368 repo.wwrite(f, mctx.filectx(f).data(), arg[2][0])
369 if f == '.hgsubstate': # subrepo states need updating
370 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
371 yield i, f
372
345 def applyupdates(repo, actions, wctx, mctx, actx, overwrite):
373 def applyupdates(repo, actions, wctx, mctx, actx, overwrite):
346 """apply the merge action list to the working directory
374 """apply the merge action list to the working directory
347
375
@@ -393,22 +421,22 b' def applyupdates(repo, actions, wctx, mc'
393 util.unlinkpath(repo.wjoin(f))
421 util.unlinkpath(repo.wjoin(f))
394
422
395 numupdates = len(actions)
423 numupdates = len(actions)
424 workeractions = [a for a in actions if a[1] in 'gr']
425 updated = len([a for a in workeractions if a[1] == 'g'])
426 removed = len([a for a in workeractions if a[1] == 'r'])
427 actions = [a for a in actions if a[1] not in 'gr']
428
429 for i, item in getremove(repo, wctx, mctx, overwrite, workeractions):
430 repo.ui.progress(_('updating'), i + 1, item=item, total=numupdates,
431 unit=_('files'))
432
433 z = len(workeractions)
434
396 for i, a in enumerate(actions):
435 for i, a in enumerate(actions):
397 f, m, args, msg = a
436 f, m, args, msg = a
398 repo.ui.progress(_('updating'), i + 1, item=f, total=numupdates,
437 repo.ui.progress(_('updating'), z + i + 1, item=f, total=numupdates,
399 unit=_('files'))
438 unit=_('files'))
400 if m == "r": # remove
439 if m == "m": # merge
401 repo.ui.note(_("removing %s\n") % f)
402 audit(f)
403 if f == '.hgsubstate': # subrepo states need updating
404 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
405 try:
406 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
407 except OSError, inst:
408 repo.ui.warn(_("update failed to remove %s: %s!\n") %
409 (f, inst.strerror))
410 removed += 1
411 elif m == "m": # merge
412 if fd == '.hgsubstate': # subrepo states need updating
440 if fd == '.hgsubstate': # subrepo states need updating
413 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
441 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
414 overwrite)
442 overwrite)
@@ -423,13 +451,6 b' def applyupdates(repo, actions, wctx, mc'
423 updated += 1
451 updated += 1
424 else:
452 else:
425 merged += 1
453 merged += 1
426 elif m == "g": # get
427 flags, = args
428 repo.ui.note(_("getting %s\n") % f)
429 repo.wwrite(f, mctx.filectx(f).data(), flags)
430 updated += 1
431 if f == '.hgsubstate': # subrepo states need updating
432 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
433 elif m == "d": # directory rename
454 elif m == "d": # directory rename
434 f2, fd, flags = args
455 f2, fd, flags = args
435 if f:
456 if f:
General Comments 0
You need to be logged in to leave comments. Login now