Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commit.py @ 45353:54eeb1a0e325
commitctx: directly update the touched and added set of files
Instead of going through intermediate variable, we can simply use the
ChangingFiles object. The object will take care of the consistency.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 28 Jul 2020 20:21:06 +0200 |
parents | 027f3dd76302 |
children | 0652a533fe3c |
comparison
equal
deleted
inserted
replaced
45352:027f3dd76302 | 45353:54eeb1a0e325 |
---|---|
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 | 160 |
161 files = metadata.ChangingFiles() | |
162 | |
161 # check in files | 163 # check in files |
162 added = [] | 164 added = [] |
163 filesadded = [] | |
164 removed = list(ctx.removed()) | 165 removed = list(ctx.removed()) |
165 touched = [] | |
166 linkrev = len(repo) | 166 linkrev = len(repo) |
167 repo.ui.note(_(b"committing files:\n")) | 167 repo.ui.note(_(b"committing files:\n")) |
168 uipathfn = scmutil.getuipathfn(repo) | 168 uipathfn = scmutil.getuipathfn(repo) |
169 for f in sorted(ctx.modified() + ctx.added()): | 169 for f in sorted(ctx.modified() + ctx.added()): |
170 repo.ui.note(uipathfn(f) + b"\n") | 170 repo.ui.note(uipathfn(f) + b"\n") |
176 added.append(f) | 176 added.append(f) |
177 m[f], is_touched = _filecommit( | 177 m[f], is_touched = _filecommit( |
178 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta, | 178 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta, |
179 ) | 179 ) |
180 if is_touched: | 180 if is_touched: |
181 touched.append(f) | |
182 if is_touched == 'added': | 181 if is_touched == 'added': |
183 filesadded.append(f) | 182 files.mark_added(f) |
183 else: | |
184 files.mark_touched(f) | |
184 m.setflag(f, fctx.flags()) | 185 m.setflag(f, fctx.flags()) |
185 except OSError: | 186 except OSError: |
186 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f)) | 187 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f)) |
187 raise | 188 raise |
188 except IOError as inst: | 189 except IOError as inst: |
189 errcode = getattr(inst, 'errno', errno.ENOENT) | 190 errcode = getattr(inst, 'errno', errno.ENOENT) |
190 if error or errcode and errcode != errno.ENOENT: | 191 if error or errcode and errcode != errno.ENOENT: |
191 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f)) | 192 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f)) |
192 raise | 193 raise |
193 | 194 |
194 files = metadata.ChangingFiles(touched=touched, added=filesadded) | |
195 # update manifest | 195 # update manifest |
196 removed = [f for f in removed if f in m1 or f in m2] | 196 removed = [f for f in removed if f in m1 or f in m2] |
197 drop = sorted([f for f in removed if f in m]) | 197 drop = sorted([f for f in removed if f in m]) |
198 for f in drop: | 198 for f in drop: |
199 del m[f] | 199 del m[f] |