##// END OF EJS Templates
largefile: consider `updatelfiles` as a `parentchange`...
marmoute -
r48451:40811cc7 default
parent child Browse files
Show More
@@ -519,96 +519,98 b' def updatelfiles('
519 519 filelist = set(filelist)
520 520 lfiles = [f for f in lfiles if f in filelist]
521 521
522 update = {}
523 dropped = set()
524 updated, removed = 0, 0
525 wvfs = repo.wvfs
526 wctx = repo[None]
527 for lfile in lfiles:
528 lfileorig = os.path.relpath(
529 scmutil.backuppath(ui, repo, lfile), start=repo.root
530 )
531 standin = lfutil.standin(lfile)
532 standinorig = os.path.relpath(
533 scmutil.backuppath(ui, repo, standin), start=repo.root
534 )
535 if wvfs.exists(standin):
536 if wvfs.exists(standinorig) and wvfs.exists(lfile):
537 shutil.copyfile(wvfs.join(lfile), wvfs.join(lfileorig))
538 wvfs.unlinkpath(standinorig)
539 expecthash = lfutil.readasstandin(wctx[standin])
540 if expecthash != b'':
541 if lfile not in wctx: # not switched to normal file
542 if repo.dirstate[standin] != b'?':
543 wvfs.unlinkpath(lfile, ignoremissing=True)
544 else:
545 dropped.add(lfile)
522 with lfdirstate.parentchange():
523 update = {}
524 dropped = set()
525 updated, removed = 0, 0
526 wvfs = repo.wvfs
527 wctx = repo[None]
528 for lfile in lfiles:
529 lfileorig = os.path.relpath(
530 scmutil.backuppath(ui, repo, lfile), start=repo.root
531 )
532 standin = lfutil.standin(lfile)
533 standinorig = os.path.relpath(
534 scmutil.backuppath(ui, repo, standin), start=repo.root
535 )
536 if wvfs.exists(standin):
537 if wvfs.exists(standinorig) and wvfs.exists(lfile):
538 shutil.copyfile(wvfs.join(lfile), wvfs.join(lfileorig))
539 wvfs.unlinkpath(standinorig)
540 expecthash = lfutil.readasstandin(wctx[standin])
541 if expecthash != b'':
542 if lfile not in wctx: # not switched to normal file
543 if repo.dirstate[standin] != b'?':
544 wvfs.unlinkpath(lfile, ignoremissing=True)
545 else:
546 dropped.add(lfile)
546 547
547 # use normallookup() to allocate an entry in largefiles
548 # dirstate to prevent lfilesrepo.status() from reporting
549 # missing files as removed.
550 lfdirstate.normallookup(lfile)
551 update[lfile] = expecthash
552 else:
553 # Remove lfiles for which the standin is deleted, unless the
554 # lfile is added to the repository again. This happens when a
555 # largefile is converted back to a normal file: the standin
556 # disappears, but a new (normal) file appears as the lfile.
557 if (
558 wvfs.exists(lfile)
559 and repo.dirstate.normalize(lfile) not in wctx
560 ):
561 wvfs.unlinkpath(lfile)
562 removed += 1
548 # use normallookup() to allocate an entry in largefiles
549 # dirstate to prevent lfilesrepo.status() from reporting
550 # missing files as removed.
551 lfdirstate.normallookup(lfile)
552 update[lfile] = expecthash
553 else:
554 # Remove lfiles for which the standin is deleted, unless the
555 # lfile is added to the repository again. This happens when a
556 # largefile is converted back to a normal file: the standin
557 # disappears, but a new (normal) file appears as the lfile.
558 if (
559 wvfs.exists(lfile)
560 and repo.dirstate.normalize(lfile) not in wctx
561 ):
562 wvfs.unlinkpath(lfile)
563 removed += 1
563 564
564 565 # largefile processing might be slow and be interrupted - be prepared
565 566 lfdirstate.write()
566 567
567 if lfiles:
568 lfiles = [f for f in lfiles if f not in dropped]
569
570 for f in dropped:
571 repo.wvfs.unlinkpath(lfutil.standin(f))
568 with lfdirstate.parentchange():
569 if lfiles:
570 lfiles = [f for f in lfiles if f not in dropped]
572 571
573 # This needs to happen for dropped files, otherwise they stay in
574 # the M state.
575 lfutil.synclfdirstate(repo, lfdirstate, f, normallookup)
572 for f in dropped:
573 repo.wvfs.unlinkpath(lfutil.standin(f))
576 574
577 statuswriter(_(b'getting changed largefiles\n'))
578 cachelfiles(ui, repo, None, lfiles)
579
580 for lfile in lfiles:
581 update1 = 0
575 # This needs to happen for dropped files, otherwise they stay in
576 # the M state.
577 lfutil.synclfdirstate(repo, lfdirstate, f, normallookup)
582 578
583 expecthash = update.get(lfile)
584 if expecthash:
585 if not lfutil.copyfromcache(repo, expecthash, lfile):
586 # failed ... but already removed and set to normallookup
587 continue
588 # Synchronize largefile dirstate to the last modified
589 # time of the file
590 lfdirstate.normal(lfile)
591 update1 = 1
579 statuswriter(_(b'getting changed largefiles\n'))
580 cachelfiles(ui, repo, None, lfiles)
581
582 for lfile in lfiles:
583 update1 = 0
592 584
593 # copy the exec mode of largefile standin from the repository's
594 # dirstate to its state in the lfdirstate.
595 standin = lfutil.standin(lfile)
596 if wvfs.exists(standin):
597 # exec is decided by the users permissions using mask 0o100
598 standinexec = wvfs.stat(standin).st_mode & 0o100
599 st = wvfs.stat(lfile)
600 mode = st.st_mode
601 if standinexec != mode & 0o100:
602 # first remove all X bits, then shift all R bits to X
603 mode &= ~0o111
604 if standinexec:
605 mode |= (mode >> 2) & 0o111 & ~util.umask
606 wvfs.chmod(lfile, mode)
585 expecthash = update.get(lfile)
586 if expecthash:
587 if not lfutil.copyfromcache(repo, expecthash, lfile):
588 # failed ... but already removed and set to normallookup
589 continue
590 # Synchronize largefile dirstate to the last modified
591 # time of the file
592 lfdirstate.normal(lfile)
607 593 update1 = 1
608 594
609 updated += update1
595 # copy the exec mode of largefile standin from the repository's
596 # dirstate to its state in the lfdirstate.
597 standin = lfutil.standin(lfile)
598 if wvfs.exists(standin):
599 # exec is decided by the users permissions using mask 0o100
600 standinexec = wvfs.stat(standin).st_mode & 0o100
601 st = wvfs.stat(lfile)
602 mode = st.st_mode
603 if standinexec != mode & 0o100:
604 # first remove all X bits, then shift all R bits to X
605 mode &= ~0o111
606 if standinexec:
607 mode |= (mode >> 2) & 0o111 & ~util.umask
608 wvfs.chmod(lfile, mode)
609 update1 = 1
610 610
611 lfutil.synclfdirstate(repo, lfdirstate, lfile, normallookup)
611 updated += update1
612
613 lfutil.synclfdirstate(repo, lfdirstate, lfile, normallookup)
612 614
613 615 lfdirstate.write()
614 616 if lfiles:
General Comments 0
You need to be logged in to leave comments. Login now