comparison mercurial/commit.py @ 45443:037e88d453fa

commit: pass mergestate into _filecommit() instead of re-reading it mergestate reading although cheap is not free. Let's read mergestate once on top and pass it into `_filecommit()`. In upcoming patches, we will be reading mergestate more in `_filecommit()`. Differential Revision: https://phab.mercurial-scm.org/D8984
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 03 Sep 2020 14:14:04 +0530
parents f52b0297acc8
children 479cce8c9882
comparison
equal deleted inserted replaced
45442:c6e332a451d0 45443:037e88d453fa
155 mctx = m1ctx.copy() 155 mctx = m1ctx.copy()
156 156
157 m = mctx.read() 157 m = mctx.read()
158 m1 = m1ctx.read() 158 m1 = m1ctx.read()
159 m2 = m2ctx.read() 159 m2 = m2ctx.read()
160 ms = mergestate.mergestate.read(repo)
160 161
161 files = metadata.ChangingFiles() 162 files = metadata.ChangingFiles()
162 163
163 # check in files 164 # check in files
164 added = [] 165 added = []
173 if fctx is None: 174 if fctx is None:
174 removed.append(f) 175 removed.append(f)
175 else: 176 else:
176 added.append(f) 177 added.append(f)
177 m[f], is_touched = _filecommit( 178 m[f], is_touched = _filecommit(
178 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta, 179 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta, ms
179 ) 180 )
180 if is_touched: 181 if is_touched:
181 if is_touched == 'added': 182 if is_touched == 'added':
182 files.mark_added(f) 183 files.mark_added(f)
183 else: 184 else:
209 210
210 return mn, files 211 return mn, files
211 212
212 213
213 def _filecommit( 214 def _filecommit(
214 repo, fctx, manifest1, manifest2, linkrev, tr, includecopymeta, 215 repo, fctx, manifest1, manifest2, linkrev, tr, includecopymeta, ms,
215 ): 216 ):
216 """ 217 """
217 commit an individual file as part of a larger transaction 218 commit an individual file as part of a larger transaction
218 219
219 input: 220 input:
224 linkrev: revision number of the changeset being created 225 linkrev: revision number of the changeset being created
225 tr: current transation 226 tr: current transation
226 includecopymeta: boolean, set to False to skip storing the copy data 227 includecopymeta: boolean, set to False to skip storing the copy data
227 (only used by the Google specific feature of using 228 (only used by the Google specific feature of using
228 changeset extra as copy source of truth). 229 changeset extra as copy source of truth).
230 ms: mergestate object
229 231
230 output: (filenode, touched) 232 output: (filenode, touched)
231 233
232 filenode: the filenode that should be used by this changeset 234 filenode: the filenode that should be used by this changeset
233 touched: one of: None (mean untouched), 'added' or 'modified' 235 touched: one of: None (mean untouched), 'added' or 'modified'
322 fparent1, fparent2 = fparent2, nullid 324 fparent1, fparent2 = fparent2, nullid
323 elif fparent2 in fparentancestors: 325 elif fparent2 in fparentancestors:
324 fparent2 = nullid 326 fparent2 = nullid
325 elif not fparentancestors: 327 elif not fparentancestors:
326 # TODO: this whole if-else might be simplified much more 328 # TODO: this whole if-else might be simplified much more
327 ms = mergestate.mergestate.read(repo) 329 if (
328 if ms.extras(fname).get(b'filenode-source') == b'other': 330 ms.active()
331 and ms.extras(fname).get(b'filenode-source') == b'other'
332 ):
329 fparent1, fparent2 = fparent2, nullid 333 fparent1, fparent2 = fparent2, nullid
330 334
331 # is the file changed? 335 # is the file changed?
332 text = fctx.data() 336 text = fctx.data()
333 if fparent2 != nullid or meta or flog.cmp(fparent1, text): 337 if fparent2 != nullid or meta or flog.cmp(fparent1, text):