# HG changeset patch # User Raphaël Gomès # Date 1694600751 -7200 # Node ID cf47b83d8ad05195b259d6db8f6f4f2aeeded6e5 # Parent 727428c7e1fc15b7986759cd81c59c15bcde75dc transaction: abstract away the detection of an abandoned transaction We're about to add another place where this is used, let's not spill this implementation detail. diff -r 727428c7e1fc -r cf47b83d8ad0 mercurial/transaction.py --- a/mercurial/transaction.py Wed Jan 25 15:33:39 2023 +0100 +++ b/mercurial/transaction.py Wed Sep 13 12:25:51 2023 +0200 @@ -59,6 +59,11 @@ ] +def has_abandoned_transaction(repo): + """Return True if the repo has an abandoned transaction""" + return os.path.exists(repo.sjoin(b"journal")) + + def cleanup_undo_files(report, vfsmap, undo_prefix=b'undo'): """remove "undo" files used by the rollback logic diff -r 727428c7e1fc -r cf47b83d8ad0 mercurial/verify.py --- a/mercurial/verify.py Wed Jan 25 15:33:39 2023 +0100 +++ b/mercurial/verify.py Wed Sep 13 12:25:51 2023 +0200 @@ -17,6 +17,7 @@ pycompat, requirements, revlog, + transaction, util, ) @@ -195,7 +196,7 @@ if not repo.url().startswith(b'file:'): raise error.Abort(_(b"cannot verify bundle or remote repos")) - if os.path.exists(repo.sjoin(b"journal")): + if transaction.has_abandoned_transaction(repo): ui.warn(_(b"abandoned transaction found - run hg recover\n")) if ui.verbose or not self.revlogv1: