comparison hgext/fix.py @ 38950:35bc4b6e132d

fix: correctly set wdirwritten given that the dict item is deleted Differential Revision: https://phab.mercurial-scm.org/D4146
author Danny Hooper <hooper@google.com>
date Mon, 06 Aug 2018 16:00:00 -0700
parents b0c591950e51
children a009589cd32a
comparison
equal deleted inserted replaced
38949:b0c591950e51 38950:35bc4b6e132d
160 # leaves a little bit of memory efficiency on the table, but also makes 160 # leaves a little bit of memory efficiency on the table, but also makes
161 # the tests deterministic. It might also be considered a feature since 161 # the tests deterministic. It might also be considered a feature since
162 # it makes the results more easily reproducible. 162 # it makes the results more easily reproducible.
163 filedata = collections.defaultdict(dict) 163 filedata = collections.defaultdict(dict)
164 replacements = {} 164 replacements = {}
165 wdirwritten = False
165 commitorder = sorted(revstofix, reverse=True) 166 commitorder = sorted(revstofix, reverse=True)
166 with ui.makeprogress(topic=_('fixing'), unit=_('files'), 167 with ui.makeprogress(topic=_('fixing'), unit=_('files'),
167 total=sum(numitems.values())) as progress: 168 total=sum(numitems.values())) as progress:
168 for rev, path, newdata in results: 169 for rev, path, newdata in results:
169 progress.increment(item=path) 170 progress.increment(item=path)
177 while commitorder and not numitems[commitorder[-1]]: 178 while commitorder and not numitems[commitorder[-1]]:
178 rev = commitorder.pop() 179 rev = commitorder.pop()
179 ctx = repo[rev] 180 ctx = repo[rev]
180 if rev == wdirrev: 181 if rev == wdirrev:
181 writeworkingdir(repo, ctx, filedata[rev], replacements) 182 writeworkingdir(repo, ctx, filedata[rev], replacements)
183 wdirwritten = bool(filedata[rev])
182 else: 184 else:
183 replacerev(ui, repo, ctx, filedata[rev], replacements) 185 replacerev(ui, repo, ctx, filedata[rev], replacements)
184 del filedata[rev] 186 del filedata[rev]
185 187
186 cleanup(repo, replacements, bool(filedata[wdirrev])) 188 cleanup(repo, replacements, wdirwritten)
187 189
188 def cleanup(repo, replacements, wdirwritten): 190 def cleanup(repo, replacements, wdirwritten):
189 """Calls scmutil.cleanupnodes() with the given replacements. 191 """Calls scmutil.cleanupnodes() with the given replacements.
190 192
191 "replacements" is a dict from nodeid to nodeid, with one key and one value 193 "replacements" is a dict from nodeid to nodeid, with one key and one value