comparison mercurial/sparse.py @ 47759:d7515d29761d stable 5.9rc0

branching: merge default into stable This mark the start of the 5.9 freeze.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 21 Jul 2021 22:52:09 +0200
parents 000ea893aad3
children b74ee41addee
comparison
equal deleted inserted replaced
47054:29ea3b4c4f62 47759:d7515d29761d
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import os 10 import os
11 11
12 from .i18n import _ 12 from .i18n import _
13 from .node import ( 13 from .node import hex
14 hex,
15 nullid,
16 )
17 from . import ( 14 from . import (
18 error, 15 error,
19 match as matchmod, 16 match as matchmod,
20 merge as mergemod, 17 merge as mergemod,
21 mergestate as mergestatemod, 18 mergestate as mergestatemod,
175 referenced profiles from parents of the working directory. 172 referenced profiles from parents of the working directory.
176 """ 173 """
177 revs = [ 174 revs = [
178 repo.changelog.rev(node) 175 repo.changelog.rev(node)
179 for node in repo.dirstate.parents() 176 for node in repo.dirstate.parents()
180 if node != nullid 177 if node != repo.nullid
181 ] 178 ]
182 179
183 allincludes = set() 180 allincludes = set()
184 allexcludes = set() 181 allexcludes = set()
185 allprofiles = set() 182 allprofiles = set()
284 repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False 281 repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False
285 ) 282 )
286 283
287 # Fix dirstate 284 # Fix dirstate
288 for file in dropped: 285 for file in dropped:
289 dirstate.drop(file) 286 dirstate.update_file(file, p1_tracked=False, wc_tracked=False)
290 287
291 repo.vfs.unlink(b'tempsparse') 288 repo.vfs.unlink(b'tempsparse')
292 repo._sparsesignaturecache.clear() 289 repo._sparsesignaturecache.clear()
293 msg = _( 290 msg = _(
294 b'cleaned up %d temporarily added file(s) from the ' 291 b'cleaned up %d temporarily added file(s) from the '
319 316
320 if not revs or revs == [None]: 317 if not revs or revs == [None]:
321 revs = [ 318 revs = [
322 repo.changelog.rev(node) 319 repo.changelog.rev(node)
323 for node in repo.dirstate.parents() 320 for node in repo.dirstate.parents()
324 if node != nullid 321 if node != repo.nullid
325 ] 322 ]
326 323
327 signature = configsignature(repo, includetemp=includetemp) 324 signature = configsignature(repo, includetemp=includetemp)
328 325
329 key = b'%s %s' % (signature, b' '.join(map(pycompat.bytestr, revs))) 326 key = b'%s %s' % (signature, b' '.join(map(pycompat.bytestr, revs)))
440 mergestatemod.ACTION_GET, 437 mergestatemod.ACTION_GET,
441 (fctx.flags(), False), 438 (fctx.flags(), False),
442 message, 439 message,
443 ) 440 )
444 441
445 mergemod.applyupdates( 442 with repo.dirstate.parentchange():
446 repo, tmresult, repo[None], repo[b'.'], False, wantfiledata=False 443 mergemod.applyupdates(
447 ) 444 repo,
448 445 tmresult,
449 dirstate = repo.dirstate 446 repo[None],
450 for file, flags, msg in tmresult.getactions([mergestatemod.ACTION_GET]): 447 repo[b'.'],
451 dirstate.normal(file) 448 False,
449 wantfiledata=False,
450 )
451
452 dirstate = repo.dirstate
453 for file, flags, msg in tmresult.getactions(
454 [mergestatemod.ACTION_GET]
455 ):
456 dirstate.update_file(file, p1_tracked=True, wc_tracked=True)
452 457
453 profiles = activeconfig(repo)[2] 458 profiles = activeconfig(repo)[2]
454 changedprofiles = profiles & files 459 changedprofiles = profiles & files
455 # If an active profile changed during the update, refresh the checkout. 460 # If an active profile changed during the update, refresh the checkout.
456 # Don't do this during a branch merge, since all incoming changes should 461 # Don't do this during a branch merge, since all incoming changes should
558 repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False 563 repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False
559 ) 564 )
560 565
561 # Fix dirstate 566 # Fix dirstate
562 for file in added: 567 for file in added:
563 dirstate.normal(file) 568 dirstate.update_file(file, p1_tracked=True, wc_tracked=True)
564 569
565 for file in dropped: 570 for file in dropped:
566 dirstate.drop(file) 571 dirstate.update_file(file, p1_tracked=False, wc_tracked=False)
567 572
568 for file in lookup: 573 for file in lookup:
569 # File exists on disk, and we're bringing it back in an unknown state. 574 # File exists on disk, and we're bringing it back in an unknown state.
570 dirstate.normallookup(file) 575 dirstate.update_file(
576 file, p1_tracked=True, wc_tracked=True, possibly_dirty=True
577 )
571 578
572 return added, dropped, lookup 579 return added, dropped, lookup
573 580
574 581
575 def aftercommit(repo, node): 582 def aftercommit(repo, node):
631 """Clears include/exclude rules from the sparse config. 638 """Clears include/exclude rules from the sparse config.
632 639
633 The remaining sparse config only has profiles, if defined. The working 640 The remaining sparse config only has profiles, if defined. The working
634 directory is refreshed, as needed. 641 directory is refreshed, as needed.
635 """ 642 """
636 with repo.wlock(): 643 with repo.wlock(), repo.dirstate.parentchange():
637 raw = repo.vfs.tryread(b'sparse') 644 raw = repo.vfs.tryread(b'sparse')
638 includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') 645 includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse')
639 646
640 if not includes and not excludes: 647 if not includes and not excludes:
641 return 648 return
647 """Import sparse config rules from files. 654 """Import sparse config rules from files.
648 655
649 The updated sparse config is written out and the working directory 656 The updated sparse config is written out and the working directory
650 is refreshed, as needed. 657 is refreshed, as needed.
651 """ 658 """
652 with repo.wlock(): 659 with repo.wlock(), repo.dirstate.parentchange():
653 # read current configuration 660 # read current configuration
654 raw = repo.vfs.tryread(b'sparse') 661 raw = repo.vfs.tryread(b'sparse')
655 includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') 662 includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse')
656 aincludes, aexcludes, aprofiles = activeconfig(repo) 663 aincludes, aexcludes, aprofiles = activeconfig(repo)
657 664
709 716
710 Only one of the actions may be performed. 717 Only one of the actions may be performed.
711 718
712 The new config is written out and a working directory refresh is performed. 719 The new config is written out and a working directory refresh is performed.
713 """ 720 """
714 with repo.wlock(): 721 with repo.wlock(), repo.dirstate.parentchange():
715 raw = repo.vfs.tryread(b'sparse') 722 raw = repo.vfs.tryread(b'sparse')
716 oldinclude, oldexclude, oldprofiles = parseconfig( 723 oldinclude, oldexclude, oldprofiles = parseconfig(
717 repo.ui, raw, b'sparse' 724 repo.ui, raw, b'sparse'
718 ) 725 )
719 726