##// END OF EJS Templates
largefiles: update in two steps, handle interrupted updates better...
Mads Kiilerich -
r20063:8a021cd3 stable
parent child Browse files
Show More
@@ -438,45 +438,27 b' def updatelfiles(ui, repo, filelist=None'
438 438 if filelist is not None:
439 439 lfiles = [f for f in lfiles if f in filelist]
440 440
441 if lfiles:
442 if printmessage:
443 ui.status(_('getting changed largefiles\n'))
444 cachelfiles(ui, repo, None, lfiles)
445
441 update = {}
446 442 updated, removed = 0, 0
447 443 for lfile in lfiles:
448 # updates a single largefile and copies the state of its standin from
449 # the repository's dirstate to its state in the lfdirstate.
450 444 abslfile = repo.wjoin(lfile)
451 445 absstandin = repo.wjoin(lfutil.standin(lfile))
452 446 if os.path.exists(absstandin):
453 447 if (os.path.exists(absstandin + '.orig') and
454 448 os.path.exists(abslfile)):
455 449 shutil.copyfile(abslfile, abslfile + '.orig')
456 update1 = 0
457 450 expecthash = lfutil.readstandin(repo, lfile)
458 451 if (expecthash != '' and
459 452 (not os.path.exists(abslfile) or
460 453 expecthash != lfutil.hashfile(abslfile))):
461 if not lfutil.copyfromcache(repo, expecthash, lfile):
462 # use normallookup() to allocate entry in largefiles
463 # dirstate, because lack of it misleads
464 # lfilesrepo.status() into recognition that such cache
465 # missing files are REMOVED.
466 if lfile not in repo[None]: # not switched to normal
467 util.unlinkpath(abslfile, ignoremissing=True)
468 lfdirstate.normallookup(lfile)
469 continue # don't try to set the mode
470 else:
471 # Synchronize largefile dirstate to the last modified
472 # time of the file
473 lfdirstate.normal(lfile)
474 update1 = 1
475 mode = os.stat(absstandin).st_mode
476 if mode != os.stat(abslfile).st_mode:
477 os.chmod(abslfile, mode)
478 update1 = 1
479 updated += update1
454 if lfile not in repo[None]: # not switched to normal file
455 util.unlinkpath(abslfile, ignoremissing=True)
456 # use normallookup() to allocate entry in largefiles
457 # dirstate, because lack of it misleads
458 # lfilesrepo.status() into recognition that such cache
459 # missing files are REMOVED.
460 lfdirstate.normallookup(lfile)
461 update[lfile] = expecthash
480 462 else:
481 463 # Remove lfiles for which the standin is deleted, unless the
482 464 # lfile is added to the repository again. This happens when a
@@ -486,6 +468,40 b' def updatelfiles(ui, repo, filelist=None'
486 468 repo.dirstate.normalize(lfile) not in repo[None]):
487 469 util.unlinkpath(abslfile)
488 470 removed += 1
471
472 # largefile processing might be slow and be interrupted - be prepared
473 lfdirstate.write()
474
475 if lfiles:
476 if printmessage:
477 ui.status(_('getting changed largefiles\n'))
478 cachelfiles(ui, repo, None, lfiles)
479
480 for lfile in lfiles:
481 update1 = 0
482
483 expecthash = update.get(lfile)
484 if expecthash:
485 if not lfutil.copyfromcache(repo, expecthash, lfile):
486 # failed ... but already removed and set to normallookup
487 continue
488 # Synchronize largefile dirstate to the last modified
489 # time of the file
490 lfdirstate.normal(lfile)
491 update1 = 1
492
493 # copy the state of largefile standin from the repository's
494 # dirstate to its state in the lfdirstate.
495 abslfile = repo.wjoin(lfile)
496 absstandin = repo.wjoin(lfutil.standin(lfile))
497 if os.path.exists(absstandin):
498 mode = os.stat(absstandin).st_mode
499 if mode != os.stat(abslfile).st_mode:
500 os.chmod(abslfile, mode)
501 update1 = 1
502
503 updated += update1
504
489 505 state = repo.dirstate[lfutil.standin(lfile)]
490 506 if state == 'n':
491 507 # When rebasing, we need to synchronize the standin and the
@@ -64,3 +64,4 b' makes copies instead of hardlinks:'
64 64 The largefile is not created in .hg/largefiles:
65 65
66 66 $ ls bob/.hg/largefiles
67 dirstate
General Comments 0
You need to be logged in to leave comments. Login now