comparison hgext/narrow/narrowcommands.py @ 41028:095a0a63ad88

narrow: when narrowing, write new narrowspec before removing revlogs If revlogs were removed and then the process crashed before the narrowspec was written, the repo would be corrupt. Differential Revision: https://phab.mercurial-scm.org/D5467
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 05 Dec 2018 15:30:56 -0800
parents 74e023f5a922
children 54c3b4bd01f2
comparison
equal deleted inserted replaced
41027:74e023f5a922 41028:095a0a63ad88
240 todelete.append(f) 240 todelete.append(f)
241 241
242 repo.destroying() 242 repo.destroying()
243 243
244 with repo.transaction("narrowing"): 244 with repo.transaction("narrowing"):
245 # Update narrowspec before removing revlogs, so repo won't be
246 # corrupt in case of crash
247 repo.setnarrowpats(newincludes, newexcludes)
248
245 for f in todelete: 249 for f in todelete:
246 ui.status(_('deleting %s\n') % f) 250 ui.status(_('deleting %s\n') % f)
247 util.unlinkpath(repo.svfs.join(f)) 251 util.unlinkpath(repo.svfs.join(f))
248 repo.store.markremoved(f) 252 repo.store.markremoved(f)
249 253
250 _narrowcleanupwdir(repo, oldincludes, oldexcludes, newincludes, 254 _narrowcleanupwdir(repo, oldincludes, oldexcludes, newincludes,
251 newexcludes, oldmatch, newmatch) 255 newexcludes, oldmatch, newmatch)
252 repo.setnarrowpats(newincludes, newexcludes)
253 256
254 repo.destroyed() 257 repo.destroyed()
255 258
256 def _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes, 259 def _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes,
257 newincludes, newexcludes): 260 newincludes, newexcludes):