Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

File tree

212 files changed

+78475
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+78475
-0
lines changed

extension.xml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project basedir="." default="all" name="svn">
3+
4+
<property file="../local.build.properties"/>
5+
<property file="../build.properties"/>
6+
7+
<property name="extension.name" value="${ant.project.name}"/>
8+
<property name="existhome.dir" location="../.."/>
9+
10+
<property name="extension.include" value="${include.feature.svn}"/>
11+
12+
<!-- import common.xml here -->
13+
<import file="${existhome.dir}/build/scripts/extensions-common.xml"/>
14+
15+
16+
<target name="download-3rd-party" description="Download thirdparty jar files">
17+
<echo>Retrieving 3rd party jar files '${extension.name}'</echo>
18+
<taskdef name="fetch" classname="nl.ow.dilemma.ant.fetch.FetchTask" classpathref="classpath.core"/>
19+
<fetch classpathref="classpath.core" dest="${existhome.dir}/${lib.user}"
20+
url="http://www.svnkit.com/org.tmatesoft.svn_1.8.8.standalone.zip" classname="org.tmatesoft.svn.cli.SVN">
21+
<patternset>
22+
<include name="**/svnkit-1.8.8.jar"/>
23+
<include name="**/svnkit-cli-1.8.8.jar"/>
24+
<include name="**/sequence-library-*.jar"/>
25+
</patternset>
26+
</fetch>
27+
</target>
28+
29+
<!-- do not clean up this jars because of conflict on windows with ant -->
30+
<!--
31+
<target name="clean-3rd-party" description="Remove thirdparty jar files" >
32+
<echo>Removing 3rd party jar files '${extension.name}'</echo>
33+
<delete includeemptydirs="true">
34+
<fileset dir="${existhome.dir}/${lib.user}" includes="svnkit*.jar"/>
35+
</delete>
36+
</target>
37+
-->
38+
39+
</project>

src/org/exist/commands/svn/Add.java

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* eXist Open Source Native XML Database
3+
* Copyright (C) 2010 The eXist Project
4+
* http://exist-db.org
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*
20+
* $Id$
21+
*/
22+
package org.exist.commands.svn;
23+
24+
import org.exist.plugin.command.*;
25+
import org.exist.util.io.Resource;
26+
import org.exist.versioning.svn.WorkingCopy;
27+
import org.exist.xmldb.XmldbURI;
28+
import org.tmatesoft.svn.core.SVNException;
29+
30+
/**
31+
* Puts directories and files under version control scheduling them for addition to a repository.
32+
*
33+
* @author <a href="mailto:[email protected]">Dmitriy Shabanov</a>
34+
*
35+
*/
36+
public class Add extends AbstractCommand {
37+
38+
public Add() {
39+
names = new String[] {"add"};
40+
}
41+
42+
public void process(XmldbURI collection, String[] params) throws CommandException {
43+
44+
WorkingCopy wc = new WorkingCopy("", "");
45+
46+
String destPath = params[0];
47+
48+
Resource wcDir = new Resource(collection.append(destPath));
49+
50+
try {
51+
wc.addEntry(wcDir);
52+
} catch (SVNException e) {
53+
throw new CommandException(e);
54+
}
55+
}
56+
}
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* eXist Open Source Native XML Database
3+
* Copyright (C) 2010 The eXist Project
4+
* http://exist-db.org
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*
20+
* $Id$
21+
*/
22+
package org.exist.commands.svn;
23+
24+
import org.exist.plugin.command.*;
25+
import org.exist.util.io.Resource;
26+
import org.exist.versioning.svn.WorkingCopy;
27+
import org.exist.xmldb.XmldbURI;
28+
import org.tmatesoft.svn.core.SVNException;
29+
import org.tmatesoft.svn.core.SVNURL;
30+
import org.tmatesoft.svn.core.wc.SVNRevision;
31+
32+
/**
33+
* @author <a href="mailto:[email protected]">Dmitriy Shabanov</a>
34+
*
35+
*/
36+
public class CheckOut extends AbstractCommand {
37+
38+
public CheckOut() {
39+
names = new String[] {"checkout", "co"};
40+
}
41+
42+
public void process(XmldbURI collection, String[] params) throws CommandException {
43+
//TODO: check params
44+
String uri = params[0];
45+
String destPath = params[1];
46+
47+
WorkingCopy wc = new WorkingCopy("", "");
48+
49+
Resource wcDir = new Resource(collection.append(destPath));
50+
if (wcDir.exists()) {
51+
throw new CommandException(
52+
"the destination directory '" + wcDir.getAbsolutePath() + "' already exists!");
53+
}
54+
wcDir.mkdirs();
55+
56+
try {
57+
out().println( wc.checkout(SVNURL.parseURIEncoded(uri), SVNRevision.HEAD, wcDir, true) );
58+
} catch (SVNException svne) {
59+
throw new CommandException(
60+
"error while checking out a working copy for the location '" + uri + "'", svne);
61+
}
62+
}
63+
64+
}
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* eXist Open Source Native XML Database
3+
* Copyright (C) 2010 The eXist Project
4+
* http://exist-db.org
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*
20+
* $Id$
21+
*/
22+
package org.exist.commands.svn;
23+
24+
import org.exist.plugin.command.*;
25+
import org.exist.util.io.Resource;
26+
import org.exist.versioning.svn.WorkingCopy;
27+
import org.exist.xmldb.XmldbURI;
28+
import org.tmatesoft.svn.core.SVNException;
29+
30+
/**
31+
* @author <a href="mailto:[email protected]">Dmitriy Shabanov</a>
32+
*
33+
*/
34+
public class Commit extends AbstractCommand {
35+
36+
public Commit() {
37+
names = new String[] {"commit", "ci"};
38+
}
39+
40+
public void process(XmldbURI collection, String[] params) throws CommandException {
41+
String user = params[0];
42+
String password = params[1];
43+
String comment = params[2];
44+
45+
Resource wcDir = new Resource(collection);
46+
47+
try {
48+
WorkingCopy wc = new WorkingCopy(user, password);
49+
50+
out().println( wc.commit(wcDir, false, comment) );
51+
} catch (SVNException svne) {
52+
svne.printStackTrace();
53+
throw new CommandException(
54+
"error while commiting a working copy to the repository '"
55+
+ wcDir + "'", svne);
56+
}
57+
}
58+
59+
}
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* eXist Open Source Native XML Database
3+
* Copyright (C) 2010 The eXist Project
4+
* http://exist-db.org
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*
20+
* $Id$
21+
*/
22+
package org.exist.commands.svn;
23+
24+
import org.exist.plugin.command.*;
25+
import org.exist.util.io.Resource;
26+
import org.exist.versioning.svn.WorkingCopy;
27+
import org.exist.versioning.svn.wc.ISVNStatusHandler;
28+
import org.exist.versioning.svn.wc.SVNClientManager;
29+
import org.exist.versioning.svn.wc.SVNStatusClient;
30+
import org.exist.versioning.svn.wc.SVNWCUtil;
31+
import org.exist.xmldb.XmldbURI;
32+
import org.tmatesoft.svn.core.SVNDepth;
33+
import org.tmatesoft.svn.core.SVNException;
34+
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
35+
import org.tmatesoft.svn.core.wc.SVNRevision;
36+
37+
/**
38+
* @author <a href="mailto:[email protected]">Dmitriy Shabanov</a>
39+
*
40+
*/
41+
public class Status extends AbstractCommand {
42+
43+
public Status() {
44+
names = new String[] {"status", "st"};
45+
}
46+
47+
public void process(XmldbURI collection, String[] params) throws CommandException {
48+
49+
String userName = "";
50+
String password = "";
51+
if (params.length == 2) {
52+
userName = params[0];
53+
password = params[1];
54+
}
55+
new WorkingCopy(userName, password);
56+
57+
SVNRepositoryFactoryImpl.setup();
58+
SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(false), userName, password);
59+
SVNStatusClient statusClient = manager.getStatusClient();
60+
// SVNWCClient wcClient = manager.getWCClient();
61+
try {
62+
statusClient.doStatus(new Resource(collection), SVNRevision.HEAD, SVNDepth.getInfinityOrFilesDepth(true), true, true, false, false, new AddStatusHandler(), null);
63+
} catch (SVNException e) {
64+
e.printStackTrace();
65+
throw new CommandException(e);
66+
}
67+
}
68+
69+
private class AddStatusHandler implements ISVNStatusHandler {
70+
71+
@Override
72+
public void handleStatus(org.exist.versioning.svn.wc.SVNStatus status) throws SVNException {
73+
out().println(status.getContentsStatus().getCode()+" "+status.getFile());
74+
}
75+
}
76+
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* eXist Open Source Native XML Database
3+
* Copyright (C) 2010 The eXist Project
4+
* http://exist-db.org
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*
20+
* $Id$
21+
*/
22+
package org.exist.commands.svn;
23+
24+
import org.exist.plugin.command.AbstractCommandResolver;
25+
26+
/**
27+
* @author <a href="mailto:[email protected]">Dmitriy Shabanov</a>
28+
*
29+
*/
30+
public class SvnCommandResolver extends AbstractCommandResolver {
31+
32+
static {
33+
SvnCommandResolver resolver = new SvnCommandResolver();
34+
35+
resolver.plug(Add.class);
36+
resolver.plug(CheckOut.class);
37+
resolver.plug(Commit.class);
38+
resolver.plug(Status.class);
39+
resolver.plug(Update.class);
40+
41+
org.exist.plugin.command.Commands.plug("svn", resolver);
42+
}
43+
44+
}

0 commit comments

Comments
 (0)