提交 161b951b 编写于 作者: K kohsuke

merged svnkit branch


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1771 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ff376457
......@@ -195,6 +195,11 @@
<artifactId>maven-embedder</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>com.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>net.sf.retrotranslator</groupId>
<artifactId>retrotranslator-runtime</artifactId>
......
......@@ -13,5 +13,8 @@ public class SCMS {
*/
@SuppressWarnings("unchecked") // generic array creation
public static final List<Descriptor<SCM>> SCMS =
Descriptor.toList(NullSCM.DESCRIPTOR,CVSSCM.DescriptorImpl.DESCRIPTOR,SubversionSCM.DESCRIPTOR);
Descriptor.toList(
NullSCM.DESCRIPTOR,
CVSSCM.DescriptorImpl.DESCRIPTOR,
SubversionSCM.DescriptorImpl.DESCRIPTOR);
}
......@@ -22,7 +22,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
/**
* @GuardedBy this
*/
private Map<String,Integer> revisionMap;
private Map<String,Long> revisionMap;
/*package*/ SubversionChangeLogSet(AbstractBuild build, List<LogEntry> logs) {
super(build);
......@@ -44,7 +44,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
return logs.iterator();
}
public synchronized Map<String,Integer> getRevisionMap() throws IOException {
public synchronized Map<String,Long> getRevisionMap() throws IOException {
if(revisionMap==null)
revisionMap = SubversionSCM.parseRevisionFile(build);
return revisionMap;
......
/*
* ====================================================================
* Copyright (c) 2004-2007 TMate Software Ltd. All rights reserved.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://svnkit.com/license.html
* If newer versions of this license are posted there, you may use a
* newer version instead, at your option.
* ====================================================================
*/
package hudson.scm;
import org.tmatesoft.svn.core.SVNCancelException;
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
import org.tmatesoft.svn.core.wc.SVNEvent;
import org.tmatesoft.svn.core.wc.SVNStatusType;
import org.tmatesoft.svn.core.wc.SVNEventAction;
import hudson.model.TaskListener;
import java.io.PrintStream;
/**
* Just prints out the progress of svn update/checkout operation in a way similar to
* the svn CLI.
*/
final class SubversionUpdateEventHandler implements ISVNEventHandler {
private final PrintStream out;
public SubversionUpdateEventHandler(TaskListener listener) {
this.out = listener.getLogger();
}
public void handleEvent(SVNEvent event, double progress) {
/*
* Gets the current action. An action is represented by SVNEventAction.
* In case of an update an action can be determined via comparing
* SVNEvent.getAction() and SVNEventAction.UPDATE_-like constants.
*/
SVNEventAction action = event.getAction();
String pathChangeType = " ";
if (action == SVNEventAction.UPDATE_ADD) {
/*
* the item was added
*/
pathChangeType = "A";
} else if (action == SVNEventAction.UPDATE_DELETE) {
/*
* the item was deleted
*/
pathChangeType = "D";
} else if (action == SVNEventAction.UPDATE_UPDATE) {
/*
* Find out in details what state the item is (after having been
* updated).
*
* Gets the status of file/directory item contents. It is
* SVNStatusType who contains information on the state of an item.
*/
SVNStatusType contentsStatus = event.getContentsStatus();
if (contentsStatus == SVNStatusType.CHANGED) {
/*
* the item was modified in the repository (got the changes
* from the repository
*/
pathChangeType = "U";
}else if (contentsStatus == SVNStatusType.CONFLICTED) {
/*
* The file item is in a state of Conflict. That is, changes
* received from the repository during an update, overlap with
* local changes the user has in his working copy.
*/
pathChangeType = "C";
} else if (contentsStatus == SVNStatusType.MERGED) {
/*
* The file item was merGed (those changes that came from the
* repository did not overlap local changes and were merged
* into the file).
*/
pathChangeType = "G";
}
} else if (action == SVNEventAction.UPDATE_EXTERNAL) {
/*for externals definitions*/
out.println("Fetching external item into '"
+ event.getFile().getAbsolutePath() + "'");
out.println("External at revision " + event.getRevision());
return;
} else if (action == SVNEventAction.UPDATE_COMPLETED) {
/*
* Updating the working copy is completed. Prints out the revision.
*/
out.println("At revision " + event.getRevision());
return;
} else if (action == SVNEventAction.ADD){
out.println("A " + event.getPath());
return;
} else if (action == SVNEventAction.DELETE){
out.println("D " + event.getPath());
return;
} else if (action == SVNEventAction.LOCKED){
out.println("L " + event.getPath());
return;
} else if (action == SVNEventAction.LOCK_FAILED){
out.println("failed to lock " + event.getPath());
return;
}
/*
* Now getting the status of properties of an item. SVNStatusType also
* contains information on the properties state.
*/
SVNStatusType propertiesStatus = event.getPropertiesStatus();
/*
* At first consider properties are normal (unchanged).
*/
String propertiesChangeType = " ";
if (propertiesStatus == SVNStatusType.CHANGED) {
/*
* Properties were updated.
*/
propertiesChangeType = "U";
} else if (propertiesStatus == SVNStatusType.CONFLICTED) {
/*
* Properties are in conflict with the repository.
*/
propertiesChangeType = "C";
} else if (propertiesStatus == SVNStatusType.MERGED) {
/*
* Properties that came from the repository were merged with the
* local ones.
*/
propertiesChangeType = "G";
}
/*
* Gets the status of the lock.
*/
String lockLabel = " ";
SVNStatusType lockType = event.getLockStatus();
if (lockType == SVNStatusType.LOCK_UNLOCKED) {
/*
* The lock is broken by someone.
*/
lockLabel = "B";
}
if(pathChangeType.equals(" ") && propertiesChangeType.equals(" ") && lockLabel.equals(" ") && event.getPath().equals(""))
// nothing to display here.
// SVNKit always seems to send one such line.
return;
out.println(pathChangeType
+ propertiesChangeType
+ lockLabel
+ " "
+ event.getPath());
}
public void checkCancelled() throws SVNCancelException {
if(Thread.currentThread().isInterrupted())
throw new SVNCancelException();
}
}
\ No newline at end of file
package hudson.tasks;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.Descriptor;
import static hudson.model.Hudson.isWindows;
import hudson.model.Project;
import org.kohsuke.stapler.StaplerRequest;
import java.io.IOException;
import java.util.Map;
/**
......@@ -24,7 +18,7 @@ public class Shell extends CommandInterpreter {
}
/**
* Fix CR/LF in the string according to the platform we are running on.
* Fix CR/LF and always make it Unix style.
*/
private static String fixCrLf(String s) {
// eliminate CR
......@@ -32,16 +26,16 @@ public class Shell extends CommandInterpreter {
while((idx=s.indexOf("\r\n"))!=-1)
s = s.substring(0,idx)+s.substring(idx+1);
// add CR back if this is for Windows
if(isWindows()) {
idx=0;
while(true) {
idx = s.indexOf('\n',idx);
if(idx==-1) break;
s = s.substring(0,idx)+'\r'+s.substring(idx);
idx+=2;
}
}
//// add CR back if this is for Windows
//if(isWindows()) {
// idx=0;
// while(true) {
// idx = s.indexOf('\n',idx);
// if(idx==-1) break;
// s = s.substring(0,idx)+'\r'+s.substring(idx);
// idx+=2;
// }
//}
return s;
}
......@@ -50,7 +44,7 @@ public class Shell extends CommandInterpreter {
}
protected String getContents() {
return command;
return fixCrLf(command);
}
protected String getFileExtension() {
......
package hudson.util;
import ch.ethz.ssh2.crypto.Base64;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
/**
* Used when storing passwords in configuration files.
*
* <p>
* This doesn't make passwords secure, but it prevents unwanted
* exposure to passwords, such as when one is grepping the file system
* or looking at config files for trouble-shooting.
*
* @author Kohsuke Kawaguchi
*/
public class Scrambler {
public static String scramble(String secret) {
try {
return new String(Base64.encode(secret.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new Error(e); // impossible
}
}
public static String descramble(String scrambled) {
try {
return new String(Base64.decode(scrambled.toCharArray()),"UTF-8");
} catch (IOException e) {
return ""; // corrupted data.
}
}
}
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout>
<l:header title="Subversion Authentication Successful" />
<l:side-panel />
<l:main-panel>
Authentication was successful. Information is stored in Hudson now.
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout>
<l:header title="Subversion Authentication" />
<l:side-panel />
<l:main-panel>
<h1>Subversion Authentication Check</h1>
<p>
Type in the Subversion repository URL below to see if the authentication
</p>
<f:form method="post" action="postCredential">
<f:entry title="Repository URL">
<f:textbox name="url" value="${request.queryString}" />
</f:entry>
<f:entry title="User name">
<f:textbox name="username" />
</f:entry>
<f:entry title="Password">
<input type="password" name="password" class="setting-input" />
</f:entry>
<f:block>
<input type="submit" name="Submit" value="OK" />
</f:block>
</f:form>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
......@@ -3,8 +3,8 @@
description="
URL of SVN module. Multiple URLs can be specified.
">
<input class="setting-input" name="svn_modules"
type="text" value="${scm.modules}"/>
<f:textbox name="svn_modules" value="${scm.modules}"
checkUrl="'${rootURL}/scm/SubversionSCM/authenticationCheck?value='+this.value" />
</f:entry>
<f:entry title="Use update"
description="
......@@ -12,22 +12,4 @@
But this causes the artifacts from the previous build to remain when a new build starts.">
<f:checkbox name="svn_use_update" checked="${scm.useUpdate}"/>
</f:entry>
<f:advanced>
<f:entry title="Username"
description="
If you need to specify a user name for accessing the repository.
To specify a password, &lt;a href='svn-password'>see this&lt;/a>.
">
<input class="setting-input" name="svn_username"
type="text" value="${scm.username}"/>
</f:entry>
<f:entry title="Other options"
description="
If you need to specify any other SVN option during checkout/update, specify them here
">
<input class="setting-input" name="svn_other_options"
type="text" value="${scm.otherOptions}"/>
</f:entry>
</f:advanced>
</j:jelly>
\ No newline at end of file
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:section title="Subversion">
<f:entry title="svn executable"
description="subversion executable"
help="/help/subversion/executable.html">
<input class="setting-input validated" name="svn_exe"
type="text" value="${descriptor.svnExe}"
checkUrl="'${rootURL}/scm/SubversionSCM/versionCheck?exe='+this.value" />
</f:entry>
</f:section>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册