Skip to content

Commit

Permalink
fix svn log path list
Browse files Browse the repository at this point in the history
  • Loading branch information
bozaro committed Aug 15, 2014
1 parent cb5815f commit 5497955
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/main/java/svnserver/repository/VcsRevision.java
Expand Up @@ -31,5 +31,5 @@ public interface VcsRevision {
VcsFile getFile(@NotNull String fullPath) throws IOException;

@NotNull
Map<String, VcsLogEntry> getChanges(@NotNull Set<String> targetPaths);
Map<String, VcsLogEntry> getChanges();
}
18 changes: 3 additions & 15 deletions src/main/java/svnserver/repository/git/GitRevision.java
Expand Up @@ -12,10 +12,7 @@
import svnserver.repository.VcsRevision;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
Expand Down Expand Up @@ -52,17 +49,8 @@ public RevCommit getCommit() {

@NotNull
@Override
public Map<String, VcsLogEntry> getChanges(@NotNull Set<String> targetPaths) {
final Map<String, VcsLogEntry> result = new TreeMap<>();
for (String targetPath : targetPaths) {
for (Map.Entry<String, GitLogEntry> entry : changes.tailMap(targetPath, true).entrySet()) {
if (!StringHelper.isParentPath(targetPath, entry.getKey())) {
break;
}
result.put(entry.getKey(), entry.getValue());
}
}
return result;
public Map<String, VcsLogEntry> getChanges() {
return new TreeMap<>(changes);
}

@NotNull
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/svnserver/server/command/LogCmd.java
Expand Up @@ -43,7 +43,6 @@
* @author a.navrotskiy
*/
public class LogCmd extends BaseCmd<LogCmd.Params> {
@SuppressWarnings("UnusedDeclaration")
public static class Params {
@NotNull
private final String[] targetPath;
Expand Down Expand Up @@ -105,10 +104,8 @@ protected void processCommand(@NotNull SessionContext context, @NotNull Params a
break;
}
final VcsRevision revisionInfo = context.getRepository().getRevisionInfo(rev);
Map<String, VcsLogEntry> changes = revisionInfo.getChanges(targetPaths);
if (changes.isEmpty()) {
continue;
}
final Map<String, VcsLogEntry> changes = revisionInfo.getChanges();
if (!hasTargets(changes, targetPaths)) continue;
writer
.listBegin()
.listBegin();
Expand Down Expand Up @@ -155,4 +152,11 @@ protected void processCommand(@NotNull SessionContext context, @NotNull Params a
.listEnd()
.listEnd();
}

private static boolean hasTargets(Map<String, VcsLogEntry> changes, Set<String> targetPaths) {
for (String targetPath : targetPaths) {
if (changes.containsKey(targetPath)) return true;
}
return false;
}
}

0 comments on commit 5497955

Please sign in to comment.