Mercurial > hg
comparison hgext/largefiles/lfcommands.py @ 50018:ef1540c57730
largefiles: remove the first `changing_parents` in `updatelfiles`
Now that the `update_file` call have been migrated, we can drop the
semantically-wrong `changing_parents` context.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Feb 2023 00:55:44 +0100 |
parents | 1a2360f7bb35 |
children | eed104af7401 |
comparison
equal
deleted
inserted
replaced
50017:1a2360f7bb35 | 50018:ef1540c57730 |
---|---|
515 | 515 |
516 if filelist is not None: | 516 if filelist is not None: |
517 filelist = set(filelist) | 517 filelist = set(filelist) |
518 lfiles = [f for f in lfiles if f in filelist] | 518 lfiles = [f for f in lfiles if f in filelist] |
519 | 519 |
520 with lfdirstate.changing_parents(repo): | 520 update = {} |
521 update = {} | 521 dropped = set() |
522 dropped = set() | 522 updated, removed = 0, 0 |
523 updated, removed = 0, 0 | 523 wvfs = repo.wvfs |
524 wvfs = repo.wvfs | 524 wctx = repo[None] |
525 wctx = repo[None] | 525 for lfile in lfiles: |
526 for lfile in lfiles: | 526 lfileorig = os.path.relpath( |
527 lfileorig = os.path.relpath( | 527 scmutil.backuppath(ui, repo, lfile), start=repo.root |
528 scmutil.backuppath(ui, repo, lfile), start=repo.root | 528 ) |
529 ) | 529 standin = lfutil.standin(lfile) |
530 standin = lfutil.standin(lfile) | 530 standinorig = os.path.relpath( |
531 standinorig = os.path.relpath( | 531 scmutil.backuppath(ui, repo, standin), start=repo.root |
532 scmutil.backuppath(ui, repo, standin), start=repo.root | 532 ) |
533 ) | 533 if wvfs.exists(standin): |
534 if wvfs.exists(standin): | 534 if wvfs.exists(standinorig) and wvfs.exists(lfile): |
535 if wvfs.exists(standinorig) and wvfs.exists(lfile): | 535 shutil.copyfile(wvfs.join(lfile), wvfs.join(lfileorig)) |
536 shutil.copyfile(wvfs.join(lfile), wvfs.join(lfileorig)) | 536 wvfs.unlinkpath(standinorig) |
537 wvfs.unlinkpath(standinorig) | 537 expecthash = lfutil.readasstandin(wctx[standin]) |
538 expecthash = lfutil.readasstandin(wctx[standin]) | 538 if expecthash != b'': |
539 if expecthash != b'': | 539 if lfile not in wctx: # not switched to normal file |
540 if lfile not in wctx: # not switched to normal file | 540 if repo.dirstate.get_entry(standin).any_tracked: |
541 if repo.dirstate.get_entry(standin).any_tracked: | 541 wvfs.unlinkpath(lfile, ignoremissing=True) |
542 wvfs.unlinkpath(lfile, ignoremissing=True) | 542 else: |
543 else: | 543 dropped.add(lfile) |
544 dropped.add(lfile) | 544 |
545 | 545 # allocate an entry in largefiles dirstate to prevent |
546 # allocate an entry in largefiles dirstate to prevent | 546 # lfilesrepo.status() from reporting missing files as |
547 # lfilesrepo.status() from reporting missing files as | 547 # removed. |
548 # removed. | 548 lfdirstate.hacky_extension_update_file( |
549 lfdirstate.hacky_extension_update_file( | 549 lfile, |
550 lfile, | 550 p1_tracked=True, |
551 p1_tracked=True, | 551 wc_tracked=True, |
552 wc_tracked=True, | 552 possibly_dirty=True, |
553 possibly_dirty=True, | 553 ) |
554 ) | 554 update[lfile] = expecthash |
555 update[lfile] = expecthash | 555 else: |
556 else: | 556 # Remove lfiles for which the standin is deleted, unless the |
557 # Remove lfiles for which the standin is deleted, unless the | 557 # lfile is added to the repository again. This happens when a |
558 # lfile is added to the repository again. This happens when a | 558 # largefile is converted back to a normal file: the standin |
559 # largefile is converted back to a normal file: the standin | 559 # disappears, but a new (normal) file appears as the lfile. |
560 # disappears, but a new (normal) file appears as the lfile. | 560 if ( |
561 if ( | 561 wvfs.exists(lfile) |
562 wvfs.exists(lfile) | 562 and repo.dirstate.normalize(lfile) not in wctx |
563 and repo.dirstate.normalize(lfile) not in wctx | 563 ): |
564 ): | 564 wvfs.unlinkpath(lfile) |
565 wvfs.unlinkpath(lfile) | 565 removed += 1 |
566 removed += 1 | |
567 | 566 |
568 # largefile processing might be slow and be interrupted - be prepared | 567 # largefile processing might be slow and be interrupted - be prepared |
569 lfdirstate.write(repo.currenttransaction()) | 568 lfdirstate.write(repo.currenttransaction()) |
570 | 569 |
571 if lfiles: | 570 if lfiles: |