##// END OF EJS Templates
merge: separate worker functions for batch remove and batch get...
Mads Kiilerich -
r21392:b1ce47da default
parent child Browse files
Show More
@@ -577,23 +577,19 actionpriority = dict((m, p) for p, m in
577 def actionkey(a):
577 def actionkey(a):
578 return actionpriority[a[1]], a
578 return actionpriority[a[1]], a
579
579
580 def getremove(repo, mctx, overwrite, args):
580 def batchremove(repo, actions):
581 """apply usually-non-interactive updates to the working directory
581 """apply removes to the working directory
582
583 mctx is the context to be merged into the working copy
584
582
585 yields tuples for progress updates
583 yields tuples for progress updates
586 """
584 """
587 verbose = repo.ui.verbose
585 verbose = repo.ui.verbose
588 unlink = util.unlinkpath
586 unlink = util.unlinkpath
589 wjoin = repo.wjoin
587 wjoin = repo.wjoin
590 fctx = mctx.filectx
591 wwrite = repo.wwrite
592 audit = repo.wopener.audit
588 audit = repo.wopener.audit
593 i = 0
589 i = 0
594 for f, m, args, msg in args:
590 for f, m, args, msg in actions:
595 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m))
591 repo.ui.debug(" %s: %s -> r\n" % (f, msg))
596 if m == 'r':
592 if True:
597 if verbose:
593 if verbose:
598 repo.ui.note(_("removing %s\n") % f)
594 repo.ui.note(_("removing %s\n") % f)
599 audit(f)
595 audit(f)
@@ -602,7 +598,27 def getremove(repo, mctx, overwrite, arg
602 except OSError, inst:
598 except OSError, inst:
603 repo.ui.warn(_("update failed to remove %s: %s!\n") %
599 repo.ui.warn(_("update failed to remove %s: %s!\n") %
604 (f, inst.strerror))
600 (f, inst.strerror))
605 else:
601 if i == 100:
602 yield i, f
603 i = 0
604 i += 1
605 if i > 0:
606 yield i, f
607
608 def batchget(repo, mctx, actions):
609 """apply gets to the working directory
610
611 mctx is the context to get from
612
613 yields tuples for progress updates
614 """
615 verbose = repo.ui.verbose
616 fctx = mctx.filectx
617 wwrite = repo.wwrite
618 i = 0
619 for f, m, args, msg in actions:
620 repo.ui.debug(" %s: %s -> g\n" % (f, msg))
621 if True:
606 if verbose:
622 if verbose:
607 repo.ui.note(_("getting %s\n") % f)
623 repo.ui.note(_("getting %s\n") % f)
608 wwrite(f, fctx(f).data(), args[0])
624 wwrite(f, fctx(f).data(), args[0])
@@ -674,15 +690,13 def applyupdates(repo, actions, wctx, mc
674
690
675 # remove in parallel (must come first)
691 # remove in parallel (must come first)
676 z = 0
692 z = 0
677 prog = worker.worker(repo.ui, 0.001, getremove, (repo, mctx, overwrite),
693 prog = worker.worker(repo.ui, 0.001, batchremove, (repo,), removeactions)
678 removeactions)
679 for i, item in prog:
694 for i, item in prog:
680 z += i
695 z += i
681 progress(_updating, z, item=item, total=numupdates, unit=_files)
696 progress(_updating, z, item=item, total=numupdates, unit=_files)
682
697
683 # get in parallel
698 # get in parallel
684 prog = worker.worker(repo.ui, 0.001, getremove, (repo, mctx, overwrite),
699 prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx), updateactions)
685 updateactions)
686 for i, item in prog:
700 for i, item in prog:
687 z += i
701 z += i
688 progress(_updating, z, item=item, total=numupdates, unit=_files)
702 progress(_updating, z, item=item, total=numupdates, unit=_files)
General Comments 0
You need to be logged in to leave comments. Login now