comparison 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
comparison
equal deleted inserted replaced
51434:dd519ea71416 51435:ad1066534237
192 else: 192 else:
193 pull_revs = [rev] 193 pull_revs = [rev]
194 overrides = {(b'ui', b'quiet'): True} 194 overrides = {(b'ui', b'quiet'): True}
195 with repo.ui.configoverride(overrides, b'chainsaw-update'): 195 with repo.ui.configoverride(overrides, b'chainsaw-update'):
196 pull = cmdutil.findcmd(b'pull', commands.table)[1][0] 196 pull = cmdutil.findcmd(b'pull', commands.table)[1][0]
197 pull(repo.ui, repo, source, rev=pull_revs, remote_hidden=False) 197 ret = pull(
198 repo.ui,
199 repo,
200 source,
201 rev=pull_revs,
202 remote_hidden=False,
203 )
204 if ret:
205 return ret
198 206
199 purge = cmdutil.findcmd(b'purge', commands.table)[1][0] 207 purge = cmdutil.findcmd(b'purge', commands.table)[1][0]
200 purge( 208 ret = purge(
201 ui, 209 ui,
202 repo, 210 repo,
203 dirs=True, 211 dirs=True,
204 all=opts.get('purge_ignored'), 212 all=opts.get('purge_ignored'),
205 files=opts.get('purge_unknown'), 213 files=opts.get('purge_unknown'),
206 confirm=False, 214 confirm=False,
207 ) 215 )
216 if ret:
217 return ret
208 218
209 ui.status(_(b'updating to revision \'%s\'\n') % rev) 219 ui.status(_(b'updating to revision \'%s\'\n') % rev)
210 update = cmdutil.findcmd(b'update', commands.table)[1][0] 220 update = cmdutil.findcmd(b'update', commands.table)[1][0]
211 update(ui, repo, rev=rev, clean=True) 221 ret = update(ui, repo, rev=rev, clean=True)
222 if ret:
223 return ret
212 224
213 ui.status( 225 ui.status(
214 _( 226 _(
215 b'chainsaw-update to revision \'%s\' ' 227 b'chainsaw-update to revision \'%s\' '
216 b'for repository at \'%s\' done\n' 228 b'for repository at \'%s\' done\n'