undo-files: use the cleanup function in narrow
Lets use the same code, so that we can fix things only once.
--- a/hgext/narrow/narrowbundle2.py Mon Mar 06 12:57:46 2023 +0100
+++ b/hgext/narrow/narrowbundle2.py Mon Mar 06 13:02:16 2023 +0100
@@ -6,7 +6,6 @@
# GNU General Public License version 2 or any later version.
-import errno
import struct
from mercurial.i18n import _
@@ -23,7 +22,6 @@
util,
wireprototypes,
)
-from mercurial.utils import stringutil
_NARROWACL_SECTION = b'narrowacl'
_CHANGESPECPART = b'narrow:changespec'
@@ -295,16 +293,7 @@
finally:
f.close()
- # remove undo files
- for undovfs, undofile in repo.undofiles():
- try:
- undovfs.unlink(undofile)
- except OSError as e:
- if e.errno != errno.ENOENT:
- ui.warn(
- _(b'error removing %s: %s\n')
- % (undovfs.join(undofile), stringutil.forcebytestr(e))
- )
+ repair.cleanup_undo_files(repo)
# Remove partial backup only if there were no exceptions
op._widen_uninterr.__exit__(None, None, None)