comparison mercurial/commit.py @ 45235:b65b4b09859c

commitctx: treat `filesadded` more like `filesremoved` Accumulating the filename in a list will have a negligible cost and deal with the list of added files like the other ones will make is code cleaning simpler. The two variable with very close name is not great, but my plan is to split most of the code in a separated function which will make the "problem" go away by itself.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Jul 2020 23:08:00 +0200
parents 595307e14140
children 0c468fef09b3
comparison
equal deleted inserted replaced
45234:595307e14140 45235:b65b4b09859c
92 m1 = m1ctx.read() 92 m1 = m1ctx.read()
93 m2 = m2ctx.read() 93 m2 = m2ctx.read()
94 94
95 # check in files 95 # check in files
96 added = [] 96 added = []
97 filesadded = [] 97 files_added = []
98 removed = list(ctx.removed()) 98 removed = list(ctx.removed())
99 touched = [] 99 touched = []
100 linkrev = len(repo) 100 linkrev = len(repo)
101 repo.ui.note(_(b"committing files:\n")) 101 repo.ui.note(_(b"committing files:\n"))
102 uipathfn = scmutil.getuipathfn(repo) 102 uipathfn = scmutil.getuipathfn(repo)
111 m[f], is_touched = _filecommit( 111 m[f], is_touched = _filecommit(
112 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta, 112 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta,
113 ) 113 )
114 if is_touched: 114 if is_touched:
115 touched.append(f) 115 touched.append(f)
116 if writechangesetcopy and is_touched == 'added': 116 if is_touched == 'added':
117 filesadded.append(f) 117 files_added.append(f)
118 m.setflag(f, fctx.flags()) 118 m.setflag(f, fctx.flags())
119 except OSError: 119 except OSError:
120 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f)) 120 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
121 raise 121 raise
122 except IOError as inst: 122 except IOError as inst:
141 files = touched 141 files = touched
142 mn = _commit_manifest(tr, linkrev, ctx, mctx, files, added, drop) 142 mn = _commit_manifest(tr, linkrev, ctx, mctx, files, added, drop)
143 143
144 if writechangesetcopy: 144 if writechangesetcopy:
145 filesremoved = removed 145 filesremoved = removed
146 filesadded = files_added
146 147
147 if not writefilecopymeta: 148 if not writefilecopymeta:
148 # If writing only to changeset extras, use None to indicate that 149 # If writing only to changeset extras, use None to indicate that
149 # no entry should be written. If writing to both, write an empty 150 # no entry should be written. If writing to both, write an empty
150 # entry to prevent the reader from falling back to reading 151 # entry to prevent the reader from falling back to reading