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