hgext/largefiles/lfutil.py
changeset 17661 67deea9c1c42
parent 17425 e95ec38f86b0
parent 17659 ae57920ac188
child 17794 a03cca2cf6c2
equal deleted inserted replaced
17654:1dc37491e9fb 17661:67deea9c1c42
   139     def forget(self, f):
   139     def forget(self, f):
   140         return super(largefilesdirstate, self).forget(unixpath(f))
   140         return super(largefilesdirstate, self).forget(unixpath(f))
   141     def normallookup(self, f):
   141     def normallookup(self, f):
   142         return super(largefilesdirstate, self).normallookup(unixpath(f))
   142         return super(largefilesdirstate, self).normallookup(unixpath(f))
   143 
   143 
   144 def openlfdirstate(ui, repo):
   144 def openlfdirstate(ui, repo, create=True):
   145     '''
   145     '''
   146     Return a dirstate object that tracks largefiles: i.e. its root is
   146     Return a dirstate object that tracks largefiles: i.e. its root is
   147     the repo root, but it is saved in .hg/largefiles/dirstate.
   147     the repo root, but it is saved in .hg/largefiles/dirstate.
   148     '''
   148     '''
   149     admin = repo.join(longname)
   149     admin = repo.join(longname)
   152                                      repo.dirstate._validate)
   152                                      repo.dirstate._validate)
   153 
   153 
   154     # If the largefiles dirstate does not exist, populate and create
   154     # If the largefiles dirstate does not exist, populate and create
   155     # it. This ensures that we create it on the first meaningful
   155     # it. This ensures that we create it on the first meaningful
   156     # largefiles operation in a new clone.
   156     # largefiles operation in a new clone.
   157     if not os.path.exists(os.path.join(admin, 'dirstate')):
   157     if create and not os.path.exists(os.path.join(admin, 'dirstate')):
   158         util.makedirs(admin)
   158         util.makedirs(admin)
   159         matcher = getstandinmatcher(repo)
   159         matcher = getstandinmatcher(repo)
   160         for standin in dirstatewalk(repo.dirstate, matcher):
   160         for standin in dirstatewalk(repo.dirstate, matcher):
   161             lfile = splitstandin(standin)
   161             lfile = splitstandin(standin)
   162             hash = readstandin(repo, lfile)
   162             hash = readstandin(repo, lfile)
   433 def unixpath(path):
   433 def unixpath(path):
   434     '''Return a version of path normalized for use with the lfdirstate.'''
   434     '''Return a version of path normalized for use with the lfdirstate.'''
   435     return util.pconvert(os.path.normpath(path))
   435     return util.pconvert(os.path.normpath(path))
   436 
   436 
   437 def islfilesrepo(repo):
   437 def islfilesrepo(repo):
   438     return ('largefiles' in repo.requirements and
   438     if ('largefiles' in repo.requirements and
   439             util.any(shortname + '/' in f[0] for f in repo.store.datafiles()))
   439             util.any(shortname + '/' in f[0] for f in repo.store.datafiles())):
       
   440         return True
       
   441 
       
   442     return util.any(openlfdirstate(repo.ui, repo, False))
   440 
   443 
   441 class storeprotonotcapable(Exception):
   444 class storeprotonotcapable(Exception):
   442     def __init__(self, storetypes):
   445     def __init__(self, storetypes):
   443         self.storetypes = storetypes
   446         self.storetypes = storetypes
   444 
   447