diff hgext/chainsaw.py @ 51435:ad1066534237

chainsaw-update: exit early if one of the intermediate command fails That will prevent the user to be presented with a start that pretend to be consistent with the request, but is not.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 23 Feb 2024 06:25:09 +0100
parents dd519ea71416
children
line wrap: on
line diff
--- a/hgext/chainsaw.py	Fri Feb 23 03:32:35 2024 +0100
+++ b/hgext/chainsaw.py	Fri Feb 23 06:25:09 2024 +0100
@@ -194,10 +194,18 @@
         overrides = {(b'ui', b'quiet'): True}
         with repo.ui.configoverride(overrides, b'chainsaw-update'):
             pull = cmdutil.findcmd(b'pull', commands.table)[1][0]
-            pull(repo.ui, repo, source, rev=pull_revs, remote_hidden=False)
+            ret = pull(
+                repo.ui,
+                repo,
+                source,
+                rev=pull_revs,
+                remote_hidden=False,
+            )
+            if ret:
+                return ret
 
         purge = cmdutil.findcmd(b'purge', commands.table)[1][0]
-        purge(
+        ret = purge(
             ui,
             repo,
             dirs=True,
@@ -205,10 +213,14 @@
             files=opts.get('purge_unknown'),
             confirm=False,
         )
+        if ret:
+            return ret
 
         ui.status(_(b'updating to revision \'%s\'\n') % rev)
         update = cmdutil.findcmd(b'update', commands.table)[1][0]
-        update(ui, repo, rev=rev, clean=True)
+        ret = update(ui, repo, rev=rev, clean=True)
+        if ret:
+            return ret
 
         ui.status(
             _(