mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
dirstate: optimize copied
for treestate
Summary: For treestate, `copies` is more expensive as it's not a cache but calculates from the source of truth. So avoid using `copies` but read the copy information directly from the tree. Reviewed By: DurhamG Differential Revision: D8595357 fbshipit-source-id: bcea254358d66c9fa9f933d73221bbeb0bd8d5b2
This commit is contained in:
parent
0630c7d183
commit
0191b7396f
@ -422,7 +422,10 @@ class dirstate(object):
|
||||
self._updatedfiles.add(dest)
|
||||
|
||||
def copied(self, file):
|
||||
return self._map.copymap.get(file, None)
|
||||
if self._istreestate:
|
||||
return self._map.copysource(file)
|
||||
else:
|
||||
return self._map.copymap.get(file, None)
|
||||
|
||||
def copies(self):
|
||||
return self._map.copymap
|
||||
|
@ -460,3 +460,14 @@ class treestatemap(object):
|
||||
state |= treestate.NEED_CHECK
|
||||
self._tree.insert(path, state, mode, size, mtime, copied)
|
||||
return True
|
||||
|
||||
def copysource(self, path):
|
||||
"""Return the copysource for path. Return None if it's not copied, or
|
||||
path does not exist.
|
||||
"""
|
||||
existing = self._tree.get(path, None)
|
||||
if existing:
|
||||
_state, _mode, _size, _mtime, copied = existing
|
||||
return copied
|
||||
else:
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user