MCPcopy Index your code
hub / github.com/git/git / applyCommit

Method applyCommit

git-p4.py:2149–2451  ·  view source on GitHub ↗

Apply one commit, return True if it succeeded.

(self, id)

Source from the content-addressed store, hash-verified

2147 return (diff + newdiff).replace('\r\n', '\n')
2148
2149 def applyCommit(self, id):
2150 """Apply one commit, return True if it succeeded."""
2151
2152 print("Applying", read_pipe(["git", "show", "-s",
2153 "--format=format:%h %s", id]))
2154
2155 p4User, gitEmail = self.p4UserForCommit(id)
2156
2157 diff = read_pipe_lines(
2158 ["git", "diff-tree", "-r"] + self.diffOpts + ["{}^".format(id), id])
2159 filesToAdd = set()
2160 filesToChangeType = set()
2161 filesToDelete = set()
2162 editedFiles = set()
2163 pureRenameCopy = set()
2164 symlinks = set()
2165 filesToChangeExecBit = {}
2166 all_files = list()
2167
2168 for line in diff:
2169 diff = parseDiffTreeEntry(line)
2170 modifier = diff['status']
2171 path = diff['src']
2172 all_files.append(path)
2173
2174 if modifier == "M":
2175 p4_edit(path)
2176 if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
2177 filesToChangeExecBit[path] = diff['dst_mode']
2178 editedFiles.add(path)
2179 elif modifier == "A":
2180 filesToAdd.add(path)
2181 filesToChangeExecBit[path] = diff['dst_mode']
2182 if path in filesToDelete:
2183 filesToDelete.remove(path)
2184
2185 dst_mode = int(diff['dst_mode'], 8)
2186 if dst_mode == 0o120000:
2187 symlinks.add(path)
2188
2189 elif modifier == "D":
2190 filesToDelete.add(path)
2191 if path in filesToAdd:
2192 filesToAdd.remove(path)
2193 elif modifier == "C":
2194 src, dest = diff['src'], diff['dst']
2195 all_files.append(dest)
2196 p4_integrate(src, dest)
2197 pureRenameCopy.add(dest)
2198 if diff['src_sha1'] != diff['dst_sha1']:
2199 p4_edit(dest)
2200 pureRenameCopy.discard(dest)
2201 if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
2202 p4_edit(dest)
2203 pureRenameCopy.discard(dest)
2204 filesToChangeExecBit[dest] = diff['dst_mode']
2205 if self.isWindows:
2206 # turn off read-only attribute

Callers 1

runMethod · 0.95

Calls 15

p4UserForCommitMethod · 0.95
patchRCSKeywordsMethod · 0.95
prepareSubmitTemplateMethod · 0.95
prepareLogMessageMethod · 0.95
get_diff_descriptionMethod · 0.95
edit_templateMethod · 0.95
lastP4ChangelistMethod · 0.95
modifyChangelistUserMethod · 0.95
read_pipeFunction · 0.85
read_pipe_linesFunction · 0.85
parseDiffTreeEntryFunction · 0.85

Tested by

no test coverage detected