Avoid surfacing error when {hg, sl} status fails

Summary: `hg status` fails when a checkout is currently in progress. Instead of surfacing this error to the user, we should just silently log it and wait for the checkout to finish. After the checkout finishes, `hg status` is reran automatically and should succeed.

Reviewed By: evangrayk

Differential Revision: D42866406

fbshipit-source-id: fc0a61a20348ec29bfd88acf1853ec6c43e2ab47
This commit is contained in:
Michael Cuevas 2023-01-30 16:57:01 -08:00 committed by Facebook GitHub Bot
parent 2d27036226
commit 645f888a4a

View File

@ -514,6 +514,12 @@ export class Repository {
this.uncommittedChangesEmitter.emit('change', this.uncommittedChanges);
} catch (err) {
this.logger.error('Error fetching files: ', err);
if (isProcessError(err)) {
if (err.stderr.includes('checkout is currently in progress')) {
this.logger.info('Ignoring `hg status` error caused by in-progress checkout');
return;
}
}
this.uncommittedChangesEmitter.emit('error', err as Error);
}
});
@ -872,3 +878,7 @@ export function absolutePathForFileInRepo(
return null;
}
}
function isProcessError(s: any): s is {stderr: string} {
return s != null && typeof s === 'object' && 'stderr' in s;
}