comparison hgext/largefiles/lfutil.py @ 39390:a65ad9b22a00

largefiles: use a context manager to control the progress bar lifetime
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 25 Aug 2018 13:09:24 -0400
parents 164306d3f4b4
children 0bd56c291359
comparison
equal deleted inserted replaced
39389:b26350d9d7b5 39390:a65ad9b22a00
499 if f[0] not in filelist: 499 if f[0] not in filelist:
500 filelist.append(f[0]) 500 filelist.append(f[0])
501 return filelist 501 return filelist
502 502
503 def getlfilestoupload(repo, missing, addfunc): 503 def getlfilestoupload(repo, missing, addfunc):
504 progress = repo.ui.makeprogress(_('finding outgoing largefiles'), 504 makeprogress = repo.ui.makeprogress
505 unit=_('revisions'), total=len(missing)) 505 with makeprogress(_('finding outgoing largefiles'),
506 for i, n in enumerate(missing): 506 unit=_('revisions'), total=len(missing)) as progress:
507 progress.update(i) 507 for i, n in enumerate(missing):
508 parents = [p for p in repo[n].parents() if p != node.nullid] 508 progress.update(i)
509 509 parents = [p for p in repo[n].parents() if p != node.nullid]
510 oldlfstatus = repo.lfstatus 510
511 repo.lfstatus = False 511 oldlfstatus = repo.lfstatus
512 try: 512 repo.lfstatus = False
513 ctx = repo[n] 513 try:
514 finally: 514 ctx = repo[n]
515 repo.lfstatus = oldlfstatus 515 finally:
516 516 repo.lfstatus = oldlfstatus
517 files = set(ctx.files()) 517
518 if len(parents) == 2: 518 files = set(ctx.files())
519 mc = ctx.manifest() 519 if len(parents) == 2:
520 mp1 = ctx.parents()[0].manifest() 520 mc = ctx.manifest()
521 mp2 = ctx.parents()[1].manifest() 521 mp1 = ctx.parents()[0].manifest()
522 for f in mp1: 522 mp2 = ctx.parents()[1].manifest()
523 if f not in mc: 523 for f in mp1:
524 files.add(f) 524 if f not in mc:
525 for f in mp2: 525 files.add(f)
526 if f not in mc: 526 for f in mp2:
527 files.add(f) 527 if f not in mc:
528 for f in mc: 528 files.add(f)
529 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None): 529 for f in mc:
530 files.add(f) 530 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):
531 for fn in files: 531 files.add(f)
532 if isstandin(fn) and fn in ctx: 532 for fn in files:
533 addfunc(fn, readasstandin(ctx[fn])) 533 if isstandin(fn) and fn in ctx:
534 progress.complete() 534 addfunc(fn, readasstandin(ctx[fn]))
535 535
536 def updatestandinsbymatch(repo, match): 536 def updatestandinsbymatch(repo, match):
537 '''Update standins in the working directory according to specified match 537 '''Update standins in the working directory according to specified match
538 538
539 This returns (possibly modified) ``match`` object to be used for 539 This returns (possibly modified) ``match`` object to be used for