protected void performCycle() throws IOException {
String newFile = randomString(1);
String fileContent = randomString(20);
writeFile(repo, newFile, fileContent);
AddCommand.on(repo).execute();
CommitCommand commitCmd = CommitCommand.on(repo).user("thread: " + this.threadId).message(
"msg: " + this.threadId);
Changeset x = commitCmd.execute();
if (x != null) {
Changeset y = repo.changeset(x.getNode());
Assert.assertSame(x, y);
stats.incChanges();
} else {
// Change committed by other thread
stats.incNoChanges();
}
File file = new File(repo.getDirectory(), randomString(1));
try {
RemoveCommand.on(repo).execute(file.getPath());
} catch (ExecutionException e) {
// The file did not exist. Maybe it never existed, or
// maybe it was deleted by another Mercurial process.
// Note that even if we check for existence before
// calling 'hg remove', then another thread might
// delete it before Mercurial and thus cause an error.
}
commitCmd.execute();
if (commitCmd.getReturnCode() == 1) {
// Change committed by other thread
stats.incNoChanges();
} else {
stats.incChanges();
}