MCPcopy
hub / github.com/Aider-AI/aider / do_replace

Function do_replace

aider/coders/udiff_coder.py:121–144  ·  view source on GitHub ↗
(fname, content, hunk)

Source from the content-addressed store, hash-verified

119
120
121def do_replace(fname, content, hunk):
122 fname = Path(fname)
123
124 before_text, after_text = hunk_to_before_after(hunk)
125
126 # does it want to make a new file?
127 if not fname.exists() and not before_text.strip():
128 fname.touch()
129 content = ""
130
131 if content is None:
132 return
133
134 # TODO: handle inserting into new file
135 if not before_text.strip():
136 # append to existing file, or start a new file
137 new_content = content + after_text
138 return new_content
139
140 new_content = None
141
142 new_content = apply_hunk(content, hunk)
143 if new_content:
144 return new_content
145
146
147def collapse_repeats(s):

Callers 2

apply_editsMethod · 0.70
_update_filesMethod · 0.70

Calls 2

hunk_to_before_afterFunction · 0.85
apply_hunkFunction · 0.85

Tested by

no test coverage detected