mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
improve perf of repomap and other file intensive actions
This commit is contained in:
parent
55fcbc958d
commit
793035b2e0
2 changed files with 29 additions and 11 deletions
|
@ -1330,7 +1330,9 @@ class Coder:
|
||||||
else:
|
else:
|
||||||
files = self.get_inchat_relative_files()
|
files = self.get_inchat_relative_files()
|
||||||
|
|
||||||
files = [fname for fname in files if self.is_file_safe(fname)]
|
# This is quite slow in large repos
|
||||||
|
# files = [fname for fname in files if self.is_file_safe(fname)]
|
||||||
|
|
||||||
return sorted(set(files))
|
return sorted(set(files))
|
||||||
|
|
||||||
def get_all_abs_files(self):
|
def get_all_abs_files(self):
|
||||||
|
|
|
@ -229,6 +229,8 @@ class GitRepo:
|
||||||
|
|
||||||
return diffs
|
return diffs
|
||||||
|
|
||||||
|
tree_files = {}
|
||||||
|
|
||||||
def get_tracked_files(self):
|
def get_tracked_files(self):
|
||||||
if not self.repo:
|
if not self.repo:
|
||||||
return []
|
return []
|
||||||
|
@ -240,25 +242,39 @@ class GitRepo:
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
if commit:
|
if commit:
|
||||||
for blob in commit.tree.traverse():
|
if commit in self.tree_files:
|
||||||
if blob.type == "blob": # blob is a file
|
files = self.tree_files[commit]
|
||||||
files.append(blob.path)
|
else:
|
||||||
|
for blob in commit.tree.traverse():
|
||||||
|
if blob.type == "blob": # blob is a file
|
||||||
|
files.append(blob.path)
|
||||||
|
files = set(self.normalize_path(path) for path in files)
|
||||||
|
self.tree_files[commit] = set(files)
|
||||||
|
|
||||||
# Add staged files
|
# Add staged files
|
||||||
index = self.repo.index
|
index = self.repo.index
|
||||||
staged_files = [path for path, _ in index.entries.keys()]
|
staged_files = [path for path, _ in index.entries.keys()]
|
||||||
|
files.update(self.normalize_path(path) for path in staged_files)
|
||||||
|
|
||||||
files.extend(staged_files)
|
res = [fname for fname in files if not self.ignored_file(fname)]
|
||||||
|
|
||||||
# convert to appropriate os.sep, since git always normalizes to /
|
|
||||||
res = set(self.normalize_path(path) for path in files)
|
|
||||||
|
|
||||||
res = [fname for fname in res if not self.ignored_file(fname)]
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
normalized_path = {}
|
||||||
|
|
||||||
def normalize_path(self, path):
|
def normalize_path(self, path):
|
||||||
return str(Path(PurePosixPath((Path(self.root) / path).relative_to(self.root))))
|
orig_path = path
|
||||||
|
res = self.normalized_path.get(orig_path)
|
||||||
|
if res:
|
||||||
|
return res
|
||||||
|
|
||||||
|
path = Path(self.root) / path
|
||||||
|
path = PurePosixPath(path)
|
||||||
|
path = path.relative_to(self.root)
|
||||||
|
|
||||||
|
path = str(path)
|
||||||
|
self.normalized_path[orig_path] = path
|
||||||
|
return path
|
||||||
|
|
||||||
def refresh_aider_ignore(self):
|
def refresh_aider_ignore(self):
|
||||||
if not self.aider_ignore_file:
|
if not self.aider_ignore_file:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue