Handle dir lock while executing mercurial command on windows
Fix error message
Fixed a bug when cancelling builds if the build load was high

- This was due to adding a require function call around the code