mercurial/sparse.py
changeset 48665 a62ba3345534
parent 48494 b74ee41addee
child 48713 5dfaca4464d1
equal deleted inserted replaced
48664:497c2655c71e 48665:a62ba3345534
   598 
   598 
   599 def _updateconfigandrefreshwdir(
   599 def _updateconfigandrefreshwdir(
   600     repo, includes, excludes, profiles, force=False, removing=False
   600     repo, includes, excludes, profiles, force=False, removing=False
   601 ):
   601 ):
   602     """Update the sparse config and working directory state."""
   602     """Update the sparse config and working directory state."""
   603     raw = repo.vfs.tryread(b'sparse')
   603     with repo.lock():
   604     oldincludes, oldexcludes, oldprofiles = parseconfig(repo.ui, raw, b'sparse')
   604         raw = repo.vfs.tryread(b'sparse')
   605 
   605         oldincludes, oldexcludes, oldprofiles = parseconfig(
   606     oldstatus = repo.status()
   606             repo.ui, raw, b'sparse'
   607     oldmatch = matcher(repo)
   607         )
   608     oldrequires = set(repo.requirements)
   608 
   609 
   609         oldstatus = repo.status()
   610     # TODO remove this try..except once the matcher integrates better
   610         oldmatch = matcher(repo)
   611     # with dirstate. We currently have to write the updated config
   611         oldrequires = set(repo.requirements)
   612     # because that will invalidate the matcher cache and force a
   612 
   613     # re-read. We ideally want to update the cached matcher on the
   613         # TODO remove this try..except once the matcher integrates better
   614     # repo instance then flush the new config to disk once wdir is
   614         # with dirstate. We currently have to write the updated config
   615     # updated. But this requires massive rework to matcher() and its
   615         # because that will invalidate the matcher cache and force a
   616     # consumers.
   616         # re-read. We ideally want to update the cached matcher on the
   617 
   617         # repo instance then flush the new config to disk once wdir is
   618     if requirements.SPARSE_REQUIREMENT in oldrequires and removing:
   618         # updated. But this requires massive rework to matcher() and its
   619         repo.requirements.discard(requirements.SPARSE_REQUIREMENT)
   619         # consumers.
   620         scmutil.writereporequirements(repo)
   620 
   621     elif requirements.SPARSE_REQUIREMENT not in oldrequires:
   621         if requirements.SPARSE_REQUIREMENT in oldrequires and removing:
   622         repo.requirements.add(requirements.SPARSE_REQUIREMENT)
   622             repo.requirements.discard(requirements.SPARSE_REQUIREMENT)
   623         scmutil.writereporequirements(repo)
       
   624 
       
   625     try:
       
   626         writeconfig(repo, includes, excludes, profiles)
       
   627         return refreshwdir(repo, oldstatus, oldmatch, force=force)
       
   628     except Exception:
       
   629         if repo.requirements != oldrequires:
       
   630             repo.requirements.clear()
       
   631             repo.requirements |= oldrequires
       
   632             scmutil.writereporequirements(repo)
   623             scmutil.writereporequirements(repo)
   633         writeconfig(repo, oldincludes, oldexcludes, oldprofiles)
   624         elif requirements.SPARSE_REQUIREMENT not in oldrequires:
   634         raise
   625             repo.requirements.add(requirements.SPARSE_REQUIREMENT)
       
   626             scmutil.writereporequirements(repo)
       
   627 
       
   628         try:
       
   629             writeconfig(repo, includes, excludes, profiles)
       
   630             return refreshwdir(repo, oldstatus, oldmatch, force=force)
       
   631         except Exception:
       
   632             if repo.requirements != oldrequires:
       
   633                 repo.requirements.clear()
       
   634                 repo.requirements |= oldrequires
       
   635                 scmutil.writereporequirements(repo)
       
   636             writeconfig(repo, oldincludes, oldexcludes, oldprofiles)
       
   637             raise
   635 
   638 
   636 
   639 
   637 def clearrules(repo, force=False):
   640 def clearrules(repo, force=False):
   638     """Clears include/exclude rules from the sparse config.
   641     """Clears include/exclude rules from the sparse config.
   639 
   642