mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
style: update hg create change method, fix DRY
This commit is contained in:
@@ -26,6 +26,8 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.CurrentContentRevision;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -322,6 +324,11 @@ public class HgHistoryUtil {
|
||||
|
||||
HgContentRevision beforeRevision =
|
||||
fileBefore == null ? null : new HgContentRevision(project, new HgFile(root, new File(root.getPath(), fileBefore)), revisionBefore);
|
||||
if (revisionAfter == null && fileBefore != null) {
|
||||
ContentRevision currentRevision =
|
||||
CurrentContentRevision.create(new HgFile(root, new File(root.getPath(), fileBefore)).toFilePath());
|
||||
return new Change(beforeRevision, currentRevision, aStatus);
|
||||
}
|
||||
HgContentRevision afterRevision =
|
||||
fileAfter == null ? null : new HgContentRevision(project, new HgFile(root, new File(root.getPath(), fileAfter)), revisionAfter);
|
||||
return new Change(beforeRevision, afterRevision, aStatus);
|
||||
|
||||
@@ -23,7 +23,10 @@ import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vcs.history.FileHistoryPanelImpl;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevisionEx;
|
||||
import com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile;
|
||||
@@ -45,6 +48,7 @@ import org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResult;
|
||||
import org.zmlx.hg4idea.execution.ShellCommand;
|
||||
import org.zmlx.hg4idea.execution.ShellCommandException;
|
||||
import org.zmlx.hg4idea.log.HgHistoryUtil;
|
||||
import org.zmlx.hg4idea.provider.HgChangeProvider;
|
||||
import org.zmlx.hg4idea.repo.HgRepository;
|
||||
import org.zmlx.hg4idea.repo.HgRepositoryManager;
|
||||
@@ -473,37 +477,15 @@ public abstract class HgUtil {
|
||||
//convert output changes to standart Change class
|
||||
for (HgChange hgChange : hgChanges) {
|
||||
FileStatus status = convertHgDiffStatus(hgChange.getStatus());
|
||||
if (status != FileStatus.UNKNOWN) {
|
||||
changes.add(createChange(project, root, hgChange.beforeFile().getRelativePath(), revNumber1,
|
||||
hgChange.afterFile().getRelativePath(),
|
||||
rev2 != null ? rev2.getRevisionNumber() : null, status));
|
||||
}
|
||||
if (status != FileStatus.UNKNOWN) {
|
||||
changes.add(HgHistoryUtil.createChange(project, root, hgChange.beforeFile().getRelativePath(), revNumber1,
|
||||
hgChange.afterFile().getRelativePath(),
|
||||
rev2 != null ? rev2.getRevisionNumber() : null, status));
|
||||
}
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Change createChange(@NotNull final Project project, VirtualFile root,
|
||||
@NotNull String fileBefore,
|
||||
@Nullable HgRevisionNumber revisionBefore,
|
||||
@NotNull String fileAfter,
|
||||
@Nullable HgRevisionNumber revisionAfter,
|
||||
@NotNull FileStatus aStatus) {
|
||||
HgContentRevision beforeRevision = revisionBefore == null
|
||||
? null
|
||||
: new HgContentRevision(project, new HgFile(root, new File(root.getPath(), fileBefore)),
|
||||
revisionBefore);
|
||||
if (revisionAfter == null) {
|
||||
ContentRevision currentRevision =
|
||||
CurrentContentRevision.create(new HgFile(root, new File(root.getPath(), fileBefore)).toFilePath());
|
||||
return new Change(beforeRevision, currentRevision, aStatus);
|
||||
}
|
||||
HgContentRevision afterRevision = new HgContentRevision(project,
|
||||
new HgFile(root, new File(root.getPath(), fileAfter)),
|
||||
revisionAfter);
|
||||
return new Change(beforeRevision, afterRevision, aStatus);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FileStatus convertHgDiffStatus(@NotNull HgFileStatusEnum hgstatus) {
|
||||
if (hgstatus.equals(HgFileStatusEnum.ADDED)) {
|
||||
|
||||
Reference in New Issue
Block a user