diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java index ede2c660fd8b..27ec978229e8 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java @@ -99,7 +99,7 @@ public class HgVFSListener extends VcsVFSListener { pi.setText(repo.getPresentableUrl()); try { untrackedFiles - .addAll(new HgStatusCommand.Builder(false).includeUnknown(true).build(myProject) + .addAll(new HgStatusCommand.Builder(false).unknown(true).build(myProject) .getHgUntrackedFiles(repo, new ArrayList(files))); } catch (final VcsException ex) { @@ -148,7 +148,7 @@ public class HgVFSListener extends VcsVFSListener { LOG.assertTrue(myProject != null, "Project is null"); Collection unversionedAndIgnoredFiles = new ArrayList(); final Map> sortedSourceFilesByRepos = HgUtil.sortByHgRoots(myProject, copyFromMap.values()); - HgStatusCommand statusCommand = new HgStatusCommand.Builder(false).includeUnknown(true).includeIgnored(true).build(myProject); + HgStatusCommand statusCommand = new HgStatusCommand.Builder(false).unknown(true).ignored(true).build(myProject); for (VirtualFile repo : sortedSourceFilesByRepos.keySet()) { Set changes = statusCommand.execute(repo); for (HgChange change : changes) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java index 46957961c0cf..a3da92ad0e3d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java @@ -39,18 +39,18 @@ public class HgStatusCommand { private static final int ITEM_COUNT = 3; private static final int STATUS_INDEX = 0; - private final Project project; + private final Project myProject; - private final boolean includeAdded; - private final boolean includeModified; - private final boolean includeRemoved; - private final boolean includeDeleted; - private final boolean includeUnknown; - private final boolean includeIgnored; - private final boolean includeCopySource; + private final boolean myIncludeAdded; + private final boolean myIncludeModified; + private final boolean myIncludeRemoved; + private final boolean myIncludeDeleted; + private final boolean myIncludeUnknown; + private final boolean myIncludeIgnored; + private final boolean myIncludeCopySource; - @Nullable private HgRevisionNumber baseRevision; - @Nullable private HgRevisionNumber targetRevision; + @Nullable private final HgRevisionNumber myBaseRevision; + @Nullable private final HgRevisionNumber myTargetRevision; public static class Builder { @@ -62,6 +62,9 @@ public class HgStatusCommand { private boolean includeIgnored; private boolean includeCopySource; + private HgRevisionNumber baseRevision; + private HgRevisionNumber targetRevision; + public Builder(boolean initValue) { includeAdded = initValue; includeModified = initValue; @@ -70,23 +73,35 @@ public class HgStatusCommand { includeUnknown = initValue; includeIgnored = initValue; includeCopySource = initValue; + baseRevision = null; + targetRevision = null; } - public Builder includeUnknown(boolean val) { + public Builder unknown(boolean val) { includeUnknown = val; return this; } - public Builder includeIgnored(boolean val) { + public Builder ignored(boolean val) { includeIgnored = val; return this; } - public Builder includeCopySource(boolean val) { + public Builder copySource(boolean val) { includeCopySource = val; return this; } + public Builder baseRevision(HgRevisionNumber val) { + baseRevision = val; + return this; + } + + public Builder targetRevision(HgRevisionNumber val) { + targetRevision = val; + return this; + } + public HgStatusCommand build(Project project) { return new HgStatusCommand(project, this); } @@ -94,22 +109,16 @@ public class HgStatusCommand { } private HgStatusCommand(Project project, Builder builder) { - this.project = project; - includeAdded = builder.includeAdded; - includeModified = builder.includeModified; - includeRemoved = builder.includeRemoved; - includeDeleted = builder.includeDeleted; - includeUnknown = builder.includeUnknown; - includeIgnored = builder.includeIgnored; - includeCopySource = builder.includeCopySource; - } - - public void setBaseRevision(@Nullable HgRevisionNumber base) { - baseRevision = base; - } - - public void setTargetRevision(@Nullable HgRevisionNumber target) { - targetRevision = target; + this.myProject = project; + myIncludeAdded = builder.includeAdded; + myIncludeModified = builder.includeModified; + myIncludeRemoved = builder.includeRemoved; + myIncludeDeleted = builder.includeDeleted; + myIncludeUnknown = builder.includeUnknown; + myIncludeIgnored = builder.includeIgnored; + myIncludeCopySource = builder.includeCopySource; + myBaseRevision = builder.baseRevision; + myTargetRevision = builder.targetRevision; } public Set execute(VirtualFile repo) { @@ -121,37 +130,37 @@ public class HgStatusCommand { return Collections.emptySet(); } - HgCommandExecutor executor = new HgCommandExecutor(project, null); + HgCommandExecutor executor = new HgCommandExecutor(myProject, null); executor.setSilent(true); List options = new LinkedList(); - if (includeAdded) { + if (myIncludeAdded) { options.add("--added"); } - if (includeModified) { + if (myIncludeModified) { options.add("--modified"); } - if (includeRemoved) { + if (myIncludeRemoved) { options.add("--removed"); } - if (includeDeleted) { + if (myIncludeDeleted) { options.add("--deleted"); } - if (includeUnknown) { + if (myIncludeUnknown) { options.add("--unknown"); } - if (includeIgnored) { + if (myIncludeIgnored) { options.add("--ignored"); } - if (includeCopySource) { + if (myIncludeCopySource) { options.add("--copies"); } - if (baseRevision != null && !baseRevision.getRevision().isEmpty()) { + if (myBaseRevision != null && !myBaseRevision.getRevision().isEmpty()) { options.add("--rev"); - options.add(baseRevision.getChangeset().isEmpty() ? baseRevision.getRevision() : baseRevision.getChangeset()); - if (targetRevision != null) { + options.add(myBaseRevision.getChangeset().isEmpty() ? myBaseRevision.getRevision() : myBaseRevision.getChangeset()); + if (myTargetRevision != null) { options.add("--rev"); - options.add(targetRevision.getChangeset()); + options.add(myTargetRevision.getChangeset()); } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java index 9f04d14e89af..1a662917131d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java @@ -134,8 +134,7 @@ public class HgCheckinEnvironment implements CheckinEnvironment { private Set getChangedFilesNotInCommit(VirtualFile repo, Set selectedFiles) { List parents = new HgWorkingCopyRevisionsCommand(myProject).parents(repo); - HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).includeUnknown(false).includeIgnored(false).build(myProject); - statusCommand.setBaseRevision(parents.get(0)); + HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).unknown(false).ignored(false).baseRevision(parents.get(0)).build(myProject); Set allChangedFilesInRepo = statusCommand.execute(repo); Set filesNotIncluded = new HashSet(); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java index 2fdc47e4cadb..e44b38859763 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java @@ -216,7 +216,7 @@ public class HgRegularUpdater implements HgUpdater { } private Set getLocalChanges() { - HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).includeUnknown(false).includeIgnored(false).build(project); + HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).unknown(false).ignored(false).build(project); return statusCommand.execute(repository); } @@ -264,9 +264,8 @@ public class HgRegularUpdater implements HgUpdater { if (parentAfterUpdate.equals(parentBeforeUpdate)) { // nothing to update => returning not to capture local uncommitted changes return; } - HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).build(project); - statusCommand.setBaseRevision(parentBeforeUpdate); - statusCommand.setTargetRevision(parentAfterUpdate); + HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).baseRevision(parentBeforeUpdate).targetRevision( + parentAfterUpdate).build(project); Set changes = statusCommand.execute(repo); for (HgChange change : changes) { HgFileStatusEnum status = change.getStatus(); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java index 9747fb45904b..199c615e7c68 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java @@ -285,8 +285,7 @@ public abstract class HgUtil { public static HgFile getFileNameInTargetRevision(Project project, HgRevisionNumber vcsRevisionNumber, HgFile localHgFile) { - HgStatusCommand statCommand = new HgStatusCommand.Builder(true).includeUnknown(false).build(project); - statCommand.setBaseRevision(vcsRevisionNumber); + HgStatusCommand statCommand = new HgStatusCommand.Builder(true).unknown(false).baseRevision(vcsRevisionNumber).build(project); Set changes = statCommand.execute(localHgFile.getRepo()); @@ -400,16 +399,18 @@ public abstract class HgUtil { @NotNull final FilePath path, @Nullable final HgFileRevision rev1, @Nullable final HgFileRevision rev2) { - HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).includeCopySource(false).build(project); + HgStatusCommand statusCommand; HgRevisionNumber revNumber1 = null; if (rev1 != null) { revNumber1 = rev1.getRevisionNumber(); - statusCommand.setBaseRevision(revNumber1); - statusCommand.setTargetRevision(rev2 != null ? rev2.getRevisionNumber() : null); //rev2==null means "compare with local version" + //rev2==null means "compare with local version" + statusCommand = new HgStatusCommand.Builder(true).copySource(false).baseRevision(revNumber1) + .targetRevision(rev2 != null ? rev2.getRevisionNumber() : null).build(project); } else { LOG.assertTrue(rev2 != null, "revision1 and revision2 can't both be null. Path: " + path); //rev1 and rev2 can't be null both// - statusCommand.setBaseRevision(rev2.getRevisionNumber()); //get initial changes// + //get initial changes// + statusCommand = new HgStatusCommand.Builder(true).copySource(false).baseRevision(rev2.getRevisionNumber()).build(project); } Collection hgChanges = statusCommand.execute(root, Collections.singleton(path));