D3717: repair: mark the critical section of strip() as unsafe

2018-07-03 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6e0c66ef8cd0: repair: mark the critical section of strip() 
as unsafe (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3717?vs=9327=9412

REVISION DETAIL
  https://phab.mercurial-scm.org/D3717

AFFECTED FILES
  mercurial/repair.py

CHANGE DETAILS

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -186,76 +186,77 @@
 tmpbundlefile = backupbundle(repo, savebases, saveheads, node, 'temp',
  compress=False, obsolescence=False)
 
-try:
-with repo.transaction("strip") as tr:
-offset = len(tr.entries)
+with ui.uninterruptable():
+try:
+with repo.transaction("strip") as tr:
+offset = len(tr.entries)
 
-tr.startgroup()
-cl.strip(striprev, tr)
-stripmanifest(repo, striprev, tr, files)
-
-for fn in files:
-repo.file(fn).strip(striprev, tr)
-tr.endgroup()
+tr.startgroup()
+cl.strip(striprev, tr)
+stripmanifest(repo, striprev, tr, files)
 
-for i in xrange(offset, len(tr.entries)):
-file, troffset, ignore = tr.entries[i]
-with repo.svfs(file, 'a', checkambig=True) as fp:
-fp.truncate(troffset)
-if troffset == 0:
-repo.store.markremoved(file)
+for fn in files:
+repo.file(fn).strip(striprev, tr)
+tr.endgroup()
 
-deleteobsmarkers(repo.obsstore, stripobsidx)
-del repo.obsstore
-repo.invalidatevolatilesets()
-repo._phasecache.filterunknown(repo)
+for i in xrange(offset, len(tr.entries)):
+file, troffset, ignore = tr.entries[i]
+with repo.svfs(file, 'a', checkambig=True) as fp:
+fp.truncate(troffset)
+if troffset == 0:
+repo.store.markremoved(file)
+
+deleteobsmarkers(repo.obsstore, stripobsidx)
+del repo.obsstore
+repo.invalidatevolatilesets()
+repo._phasecache.filterunknown(repo)
 
-if tmpbundlefile:
-ui.note(_("adding branch\n"))
-f = vfs.open(tmpbundlefile, "rb")
-gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
-if not repo.ui.verbose:
-# silence internal shuffling chatter
-repo.ui.pushbuffer()
-tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
-txnname = 'strip'
-if not isinstance(gen, bundle2.unbundle20):
-txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
-with repo.transaction(txnname) as tr:
-bundle2.applybundle(repo, gen, tr, source='strip',
-url=tmpbundleurl)
-if not repo.ui.verbose:
-repo.ui.popbuffer()
-f.close()
+if tmpbundlefile:
+ui.note(_("adding branch\n"))
+f = vfs.open(tmpbundlefile, "rb")
+gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
+if not repo.ui.verbose:
+# silence internal shuffling chatter
+repo.ui.pushbuffer()
+tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
+txnname = 'strip'
+if not isinstance(gen, bundle2.unbundle20):
+txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
+with repo.transaction(txnname) as tr:
+bundle2.applybundle(repo, gen, tr, source='strip',
+url=tmpbundleurl)
+if not repo.ui.verbose:
+repo.ui.popbuffer()
+f.close()
 
-with repo.transaction('repair') as tr:
-bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
-bm.applychanges(repo, tr, bmchanges)
+with repo.transaction('repair') as tr:
+bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
+bm.applychanges(repo, tr, bmchanges)
 
-# remove undo files
-for undovfs, undofile in repo.undofiles():
-try:
-undovfs.unlink(undofile)
-except OSError as e:
-if e.errno != errno.ENOENT:
-ui.warn(_('error removing %s: %s\n') %
-(undovfs.join(undofile),
- stringutil.forcebytestr(e)))
+# remove undo files
+for undovfs, undofile in repo.undofiles():
+try:
+   

D3717: repair: mark the critical section of strip() as unsafe

2018-06-27 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 9327.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3717?vs=9024=9327

REVISION DETAIL
  https://phab.mercurial-scm.org/D3717

AFFECTED FILES
  mercurial/repair.py

CHANGE DETAILS

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -186,76 +186,77 @@
 tmpbundlefile = backupbundle(repo, savebases, saveheads, node, 'temp',
  compress=False, obsolescence=False)
 
-try:
-with repo.transaction("strip") as tr:
-offset = len(tr.entries)
+with ui.uninterruptable():
+try:
+with repo.transaction("strip") as tr:
+offset = len(tr.entries)
 
-tr.startgroup()
-cl.strip(striprev, tr)
-stripmanifest(repo, striprev, tr, files)
-
-for fn in files:
-repo.file(fn).strip(striprev, tr)
-tr.endgroup()
+tr.startgroup()
+cl.strip(striprev, tr)
+stripmanifest(repo, striprev, tr, files)
 
-for i in xrange(offset, len(tr.entries)):
-file, troffset, ignore = tr.entries[i]
-with repo.svfs(file, 'a', checkambig=True) as fp:
-fp.truncate(troffset)
-if troffset == 0:
-repo.store.markremoved(file)
+for fn in files:
+repo.file(fn).strip(striprev, tr)
+tr.endgroup()
 
-deleteobsmarkers(repo.obsstore, stripobsidx)
-del repo.obsstore
-repo.invalidatevolatilesets()
-repo._phasecache.filterunknown(repo)
+for i in xrange(offset, len(tr.entries)):
+file, troffset, ignore = tr.entries[i]
+with repo.svfs(file, 'a', checkambig=True) as fp:
+fp.truncate(troffset)
+if troffset == 0:
+repo.store.markremoved(file)
+
+deleteobsmarkers(repo.obsstore, stripobsidx)
+del repo.obsstore
+repo.invalidatevolatilesets()
+repo._phasecache.filterunknown(repo)
 
-if tmpbundlefile:
-ui.note(_("adding branch\n"))
-f = vfs.open(tmpbundlefile, "rb")
-gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
-if not repo.ui.verbose:
-# silence internal shuffling chatter
-repo.ui.pushbuffer()
-tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
-txnname = 'strip'
-if not isinstance(gen, bundle2.unbundle20):
-txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
-with repo.transaction(txnname) as tr:
-bundle2.applybundle(repo, gen, tr, source='strip',
-url=tmpbundleurl)
-if not repo.ui.verbose:
-repo.ui.popbuffer()
-f.close()
+if tmpbundlefile:
+ui.note(_("adding branch\n"))
+f = vfs.open(tmpbundlefile, "rb")
+gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
+if not repo.ui.verbose:
+# silence internal shuffling chatter
+repo.ui.pushbuffer()
+tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
+txnname = 'strip'
+if not isinstance(gen, bundle2.unbundle20):
+txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
+with repo.transaction(txnname) as tr:
+bundle2.applybundle(repo, gen, tr, source='strip',
+url=tmpbundleurl)
+if not repo.ui.verbose:
+repo.ui.popbuffer()
+f.close()
 
-with repo.transaction('repair') as tr:
-bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
-bm.applychanges(repo, tr, bmchanges)
+with repo.transaction('repair') as tr:
+bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
+bm.applychanges(repo, tr, bmchanges)
 
-# remove undo files
-for undovfs, undofile in repo.undofiles():
-try:
-undovfs.unlink(undofile)
-except OSError as e:
-if e.errno != errno.ENOENT:
-ui.warn(_('error removing %s: %s\n') %
-(undovfs.join(undofile),
- stringutil.forcebytestr(e)))
+# remove undo files
+for undovfs, undofile in repo.undofiles():
+try:
+undovfs.unlink(undofile)
+except OSError as e:
+if e.errno != errno.ENOENT:
+

D3717: repair: mark the critical section of strip() as unsafe

2018-06-12 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When our experimental nointerrupt feature is enabled, this will
  help prevent users from corrupting their repo during a strip.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3717

AFFECTED FILES
  mercurial/repair.py

CHANGE DETAILS

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -186,76 +186,77 @@
 tmpbundlefile = backupbundle(repo, savebases, saveheads, node, 'temp',
  compress=False, obsolescence=False)
 
-try:
-with repo.transaction("strip") as tr:
-offset = len(tr.entries)
+with ui.unsafeoperation():
+try:
+with repo.transaction("strip") as tr:
+offset = len(tr.entries)
 
-tr.startgroup()
-cl.strip(striprev, tr)
-stripmanifest(repo, striprev, tr, files)
-
-for fn in files:
-repo.file(fn).strip(striprev, tr)
-tr.endgroup()
+tr.startgroup()
+cl.strip(striprev, tr)
+stripmanifest(repo, striprev, tr, files)
 
-for i in xrange(offset, len(tr.entries)):
-file, troffset, ignore = tr.entries[i]
-with repo.svfs(file, 'a', checkambig=True) as fp:
-fp.truncate(troffset)
-if troffset == 0:
-repo.store.markremoved(file)
+for fn in files:
+repo.file(fn).strip(striprev, tr)
+tr.endgroup()
 
-deleteobsmarkers(repo.obsstore, stripobsidx)
-del repo.obsstore
-repo.invalidatevolatilesets()
-repo._phasecache.filterunknown(repo)
+for i in xrange(offset, len(tr.entries)):
+file, troffset, ignore = tr.entries[i]
+with repo.svfs(file, 'a', checkambig=True) as fp:
+fp.truncate(troffset)
+if troffset == 0:
+repo.store.markremoved(file)
+
+deleteobsmarkers(repo.obsstore, stripobsidx)
+del repo.obsstore
+repo.invalidatevolatilesets()
+repo._phasecache.filterunknown(repo)
 
-if tmpbundlefile:
-ui.note(_("adding branch\n"))
-f = vfs.open(tmpbundlefile, "rb")
-gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
-if not repo.ui.verbose:
-# silence internal shuffling chatter
-repo.ui.pushbuffer()
-tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
-txnname = 'strip'
-if not isinstance(gen, bundle2.unbundle20):
-txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
-with repo.transaction(txnname) as tr:
-bundle2.applybundle(repo, gen, tr, source='strip',
-url=tmpbundleurl)
-if not repo.ui.verbose:
-repo.ui.popbuffer()
-f.close()
+if tmpbundlefile:
+ui.note(_("adding branch\n"))
+f = vfs.open(tmpbundlefile, "rb")
+gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
+if not repo.ui.verbose:
+# silence internal shuffling chatter
+repo.ui.pushbuffer()
+tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
+txnname = 'strip'
+if not isinstance(gen, bundle2.unbundle20):
+txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
+with repo.transaction(txnname) as tr:
+bundle2.applybundle(repo, gen, tr, source='strip',
+url=tmpbundleurl)
+if not repo.ui.verbose:
+repo.ui.popbuffer()
+f.close()
 
-with repo.transaction('repair') as tr:
-bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
-bm.applychanges(repo, tr, bmchanges)
+with repo.transaction('repair') as tr:
+bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
+bm.applychanges(repo, tr, bmchanges)
 
-# remove undo files
-for undovfs, undofile in repo.undofiles():
-try:
-undovfs.unlink(undofile)
-except OSError as e:
-if e.errno != errno.ENOENT:
-ui.warn(_('error removing %s: %s\n') %
-(undovfs.join(undofile),
- stringutil.forcebytestr(e)))
+# remove undo files
+for undovfs, undofile in repo.undofiles():
+try:
+