use of org.zmlx.hg4idea.command.HgRevertCommand in project intellij-community by JetBrains.
the class HgRevertUncommittedMergeTest method testRevertAfterMerge.
public void testRevertAfterMerge() throws VcsException {
cd(myRepository);
hg("branch branchA");
String aFile = "A.txt";
touch(aFile, "a");
hg("add " + aFile);
hg("commit -m 'create file in branchA' ");
hg("up default");
touch(aFile, "default");
hg("add " + aFile);
hg("commit -m 'create file in default branch'");
hgMergeWith("branchA");
HgCommandResult revertResult = new HgRevertCommand(myProject).execute(myRepository, Collections.singleton(new File(myRepository.getPath(), aFile).getAbsolutePath()), null, false);
assertTrue(HgErrorUtil.hasUncommittedChangesConflict(revertResult));
}
use of org.zmlx.hg4idea.command.HgRevertCommand in project intellij-community by JetBrains.
the class HgRevertTest method testRevertToCurrentRevision.
@Test
public void testRevertToCurrentRevision() throws Exception {
fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
runHgOnProjectRepo("add", ".");
runHgOnProjectRepo("commit", "-m", "initial contents");
fillFile(myProjectDir, new String[] { "file.txt" }, "new contents");
HgRevertCommand revertCommand = new HgRevertCommand(myProject);
revertCommand.execute(myRepo.getDir(), Collections.singleton(new File(myProjectDir, "file.txt").getPath()), null, false);
HgCatCommand catCommand = new HgCatCommand(myProject);
HgCommandResult result = catCommand.execute(getHgFile("file.txt"), null, Charset.defaultCharset());
assertNotNull(result);
assertEquals(result.getRawOutput(), "initial contents");
}
use of org.zmlx.hg4idea.command.HgRevertCommand in project intellij-community by JetBrains.
the class HgRevertTest method testRevertToGivenRevision.
@Test
public void testRevertToGivenRevision() throws Exception {
fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
runHgOnProjectRepo("add", ".");
runHgOnProjectRepo("commit", "-m", "initial contents");
fillFile(myProjectDir, new String[] { "file.txt" }, "new contents");
runHgOnProjectRepo("commit", "-m", "new contents");
HgRevertCommand revertCommand = new HgRevertCommand(myProject);
revertCommand.execute(myRepo.getDir(), Collections.singleton(new File(myProjectDir, "file.txt").getPath()), HgRevisionNumber.getLocalInstance("0"), false);
HgCatCommand catCommand = new HgCatCommand(myProject);
HgCommandResult result = catCommand.execute(getHgFile("file.txt"), HgRevisionNumber.getLocalInstance("0"), Charset.defaultCharset());
assertNotNull(result);
assertEquals(result.getRawOutput(), "initial contents");
}
use of org.zmlx.hg4idea.command.HgRevertCommand in project intellij-community by JetBrains.
the class HgRollbackEnvironment method revert.
private void revert(@NotNull List<FilePath> filePaths) {
for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(project, filePaths).entrySet()) {
final VirtualFile repo = entry.getKey();
final Collection<FilePath> files = entry.getValue();
HgRevisionNumber revisionNumber = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
for (List<String> chunk : VcsFileUtil.chunkPaths(repo, files)) {
HgCommandResult revertResult = new HgRevertCommand(project).execute(repo, chunk, revisionNumber, false);
if (HgErrorUtil.hasUncommittedChangesConflict(revertResult)) {
String message = String.format("<html>Revert failed due to uncommitted merge.<br>" + "Would you like to discard all changes for repository <it><b>%s</b></it>?</html>", repo.getPresentableName());
int exitCode = HgUpdateCommand.showDiscardChangesConfirmation(project, message);
if (exitCode == Messages.OK) {
//discard all changes for this repository//
HgUpdateCommand updateCommand = new HgUpdateCommand(project, repo);
updateCommand.setClean(true);
updateCommand.setRevision(".");
updateCommand.execute();
}
break;
}
new HgResolveCommand(project).markResolved(repo, files);
}
}
}
Aggregations