Skip to content

Commit

Permalink
Fixed problems with locking and changed other operations to be non-re…
Browse files Browse the repository at this point in the history
…cursive.
  • Loading branch information
sfred committed May 28, 2009
1 parent 84524a2 commit 17fdddc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 35 deletions.
39 changes: 39 additions & 0 deletions src/fitnesse/revisioncontrol/FileUtils.java
@@ -0,0 +1,39 @@
package fitnesse.revisioncontrol;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public final class FileUtils {
public static final String CONTENT_FILE_NAME = "content.txt";
private static final String PROPERTIES_FILE_NAME = "properties.xml";

public static File[] getPathsFromRoot(File file, boolean recursive) {
List<File> foundFiles = new ArrayList<File>();

if (file.isDirectory()) {
getPathsInDirectory(file, foundFiles, recursive);
}
else
foundFiles.add(file);

return foundFiles.toArray(new File[foundFiles.size()]);
}

private static void getPathsInDirectory(File root, List<File> paths, boolean recursive) {
for (File file : root.listFiles()) {
if (file.getName().equals(".svn")) {
continue;
}

if (file.isDirectory() && recursive)
getPathsInDirectory(file, paths, recursive);
else if (isContentOrPropertiesFile(file))
paths.add(file);
}
}

private static boolean isContentOrPropertiesFile(File file) {
return file.getName().endsWith(CONTENT_FILE_NAME) || file.getName().endsWith(PROPERTIES_FILE_NAME);
}
}
6 changes: 3 additions & 3 deletions src/fitnesse/revisioncontrol/RevisionControlOperation.java
Expand Up @@ -31,7 +31,7 @@ public NewRevisionResults execute(RevisionController revisionController, String
};

public static final RevisionControlOperation<Results> CHECKOUT =
new RevisionControlOperation<Results>("Checkout", "checkout", "c", "Get updates to this sub-wiki from version control.") {
new RevisionControlOperation<Results>("Checkout", "checkout", "c", "Get updates to this page from version control.") {

@Override
public Results execute(RevisionController revisionController, String pagePath) {
Expand All @@ -40,7 +40,7 @@ public Results execute(RevisionController revisionController, String pagePath) {
};

public static final RevisionControlOperation<NewRevisionResults> CHECKIN =
new RevisionControlOperation<NewRevisionResults>("Checkin", "checkin", "i", "Put changes to this sub-wiki into version control.") {
new RevisionControlOperation<NewRevisionResults>("Checkin", "checkin", "i", "Put changes to this page into version control.") {

@Override
public NewRevisionResults execute(RevisionController revisionController, String pagePath) {
Expand All @@ -49,7 +49,7 @@ public NewRevisionResults execute(RevisionController revisionController, String
};

public static final RevisionControlOperation<Results> REVERT =
new RevisionControlOperation<Results>("Revert", "revert", "", "Discard local changes to this sub-wiki.") {
new RevisionControlOperation<Results>("Revert", "revert", "", "Discard local changes to this page.") {

@Override
public Results execute(RevisionController revisionController, String pagePath) {
Expand Down
Expand Up @@ -77,7 +77,7 @@ private HtmlTag makeForm(String responderName, String buttonCaption) {
}

private HtmlTag makeCheckinContent() throws Exception {
TagGroup group = makeContent("Commit:", "Commit this sub-wiki to version control.");
TagGroup group = makeContent("Checkin:", "Put changes to this sub-wiki into version control.");
group.add(makeCheckinForm());
return group;
}
Expand Down
Expand Up @@ -154,7 +154,7 @@ private void debug(String operation, File file) {
}

private RevisionControlException revisionControlException(String operation, String pagePath, Exception e) {
return new RevisionControlException("Unable to " + operation + " page: " + pagePath, e);
return new RevisionControlException("Unable to " + operation + " page '" + pagePath + "':" + e.getMessage(), e);
}

private boolean isUnderVersionControl(final File file) {
Expand Down
35 changes: 5 additions & 30 deletions src/fitnesse/revisioncontrol/svn/client/SVNClient.java
Expand Up @@ -57,8 +57,8 @@ public void doCommit(File wcPath, String commitMessage, NewRevisionResults resul
SVNCommitClient client = clientManager.getCommitClient();
setEventHandler(results, client);

SVNCommitInfo svnInfo = client.doCommit(new File[]{wcPath}, false, commitMessage,
null, null, false, false, SVNDepth.INFINITY);
SVNCommitInfo svnInfo = client.doCommit(FileUtils.getPathsFromRoot(wcPath, false),
false, commitMessage, null, null, false, false, SVNDepth.INFINITY);

long newRevision = svnInfo.getNewRevision();
if (newRevision == -1)
Expand Down Expand Up @@ -124,21 +124,21 @@ public void doLock(File wcPath, Results results) throws SVNException {
SVNWCClient client = clientManager.getWCClient();
setEventHandler(results, client);

client.doLock(getPathsFromRoot(wcPath), false, null);
client.doLock(FileUtils.getPathsFromRoot(wcPath, false), false, null);

clearEventHandler(client);
}

public void doUnlock(File wcPath) throws SVNException {
SVNWCClient client = clientManager.getWCClient();
client.doUnlock(getPathsFromRoot(wcPath), true);
client.doUnlock(FileUtils.getPathsFromRoot(wcPath, false), true);
}

public void doUnlock(File wcPath, Results results) throws SVNException {
SVNWCClient client = clientManager.getWCClient();
setEventHandler(results, client);

client.doUnlock(getPathsFromRoot(wcPath), true);
client.doUnlock(FileUtils.getPathsFromRoot(wcPath, false), true);

clearEventHandler(client);
}
Expand All @@ -147,31 +147,6 @@ public void doMove(File src, File dest) throws SVNException {
clientManager.getMoveClient().doMove(src, dest);
}

private File[] getPathsFromRoot(File file) {
ArrayList<File> list = new ArrayList<File>();

if (file.isDirectory())
recurseDirectory(file, list);
else
list.add(file);

return list.toArray(new File[list.size()]);
}

private void recurseDirectory(File root, List<File> paths) {
File[] files = root.listFiles();
for (File file : files) {
if (file.getName().equals(".svn")) {
continue;
}

if (file.isDirectory())
recurseDirectory(file, paths);
else
paths.add(file);
}
}

private static class LogEntryHandler implements ISVNLogEntryHandler {
public List<SVNLogEntry> logEntries = new ArrayList<SVNLogEntry>();

Expand Down

0 comments on commit 17fdddc

Please sign in to comment.