mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 11:05:56 +01:00
added revision for mercurial sub repositories
This commit is contained in:
@@ -39,6 +39,9 @@ import sonia.scm.LastModifiedAware;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
@@ -47,6 +50,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
* @since 1.5
|
||||
*/
|
||||
@XmlRootElement(name = "file")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class FileObject implements LastModifiedAware
|
||||
{
|
||||
|
||||
@@ -112,9 +116,9 @@ public class FileObject implements LastModifiedAware
|
||||
* @since 1.10
|
||||
* @return
|
||||
*/
|
||||
public String getSubRepositoryUrl()
|
||||
public SubRepository getSubRepository()
|
||||
{
|
||||
return subRepositoryUrl;
|
||||
return subRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,12 +204,13 @@ public class FileObject implements LastModifiedAware
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param subRepositoryUrl
|
||||
* @since 1.10
|
||||
*
|
||||
* @param subRepository
|
||||
*/
|
||||
public void setSubRepositoryUrl(String subRepositoryUrl)
|
||||
public void setSubRepository(SubRepository subRepository)
|
||||
{
|
||||
this.subRepositoryUrl = subRepositoryUrl;
|
||||
this.subRepository = subRepository;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
@@ -229,5 +234,6 @@ public class FileObject implements LastModifiedAware
|
||||
private String path;
|
||||
|
||||
/** Field description */
|
||||
private String subRepositoryUrl;
|
||||
@XmlElement(name = "subrepository")
|
||||
private SubRepository subRepository;
|
||||
}
|
||||
|
||||
179
scm-core/src/main/java/sonia/scm/repository/SubRepository.java
Normal file
179
scm-core/src/main/java/sonia/scm/repository/SubRepository.java
Normal file
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* @since 1.10
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement(name = "subrepository")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class SubRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public SubRepository() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param repositoryUrl
|
||||
*/
|
||||
public SubRepository(String repositoryUrl)
|
||||
{
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
* @param repositoryUrl
|
||||
*/
|
||||
public SubRepository(String repositoryUrl, String revision)
|
||||
{
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
* @param repositoryUrl
|
||||
* @param browserUrl
|
||||
*/
|
||||
public SubRepository(String repositoryUrl, String browserUrl, String revision)
|
||||
{
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
this.browserUrl = browserUrl;
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getBrowserUrl()
|
||||
{
|
||||
return browserUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRepositoryUrl()
|
||||
{
|
||||
return repositoryUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRevision()
|
||||
{
|
||||
return revision;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param browserUrl
|
||||
*/
|
||||
public void setBrowserUrl(String browserUrl)
|
||||
{
|
||||
this.browserUrl = browserUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repositoryUrl
|
||||
*/
|
||||
public void setRepositoryUrl(String repositoryUrl)
|
||||
{
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
*/
|
||||
public void setRevision(String revision)
|
||||
{
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "browser-url")
|
||||
private String browserUrl;
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "repository-url")
|
||||
private String repositoryUrl;
|
||||
|
||||
/** Field description */
|
||||
private String revision;
|
||||
}
|
||||
@@ -29,6 +29,10 @@
|
||||
#
|
||||
#
|
||||
|
||||
class SubRepository:
|
||||
url = None
|
||||
revision = None
|
||||
|
||||
import sys, os
|
||||
|
||||
pythonPath = os.environ['SCM_PYTHON_PATH']
|
||||
@@ -65,11 +69,25 @@ try:
|
||||
for line in hgsub:
|
||||
parts = line.split('=')
|
||||
if len(parts) > 1:
|
||||
subrepos[parts[0].strip()] = parts[1].strip()
|
||||
subrepo = SubRepository()
|
||||
subrepo.url = parts[1].strip()
|
||||
subrepos[parts[0].strip()] = subrepo
|
||||
print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
||||
except Exception:
|
||||
# howto drop execptions
|
||||
# howto drop execptions in python?
|
||||
print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
||||
|
||||
try:
|
||||
hgsubstate = revCtx.filectx('.hgsubstate').data().split('\n')
|
||||
for line in hgsubstate:
|
||||
parts = line.split(' ')
|
||||
if len(parts) > 1:
|
||||
subrev = parts[0].strip()
|
||||
subrepo = subrepos[parts[1].strip()]
|
||||
subrepo.revision = subrev
|
||||
except Exception:
|
||||
# howto drop execptions in python?
|
||||
print ''
|
||||
|
||||
if path is "":
|
||||
length = 1
|
||||
@@ -112,7 +130,11 @@ for dir in directories:
|
||||
print ' <directory>true</directory>'
|
||||
if dir in subrepos:
|
||||
subrepo = subrepos[dir]
|
||||
print ' <subRepositoryUrl>' + subrepo + '</subRepositoryUrl>'
|
||||
print ' <subrepository>'
|
||||
if subrepo.revision != None:
|
||||
print ' <revision>' + subrepo.revision + '</revision>'
|
||||
print ' <repository-url>' + subrepo.url + '</repository-url>'
|
||||
print ' </subrepository>'
|
||||
print ' </file>'
|
||||
|
||||
for file in files:
|
||||
|
||||
@@ -267,7 +267,9 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
|
||||
|
||||
if (Util.isNotEmpty(externals))
|
||||
{
|
||||
fileObject.setSubRepositoryUrl(externals);
|
||||
SubRepository subRepository = new SubRepository(externals);
|
||||
|
||||
fileObject.setSubRepository(subRepository);
|
||||
}
|
||||
}
|
||||
catch (SVNException ex)
|
||||
|
||||
@@ -362,7 +362,7 @@
|
||||
<aether.version>1.13</aether.version>
|
||||
<wagon.version>1.0</wagon.version>
|
||||
<maven.version>3.0.3</maven.version>
|
||||
<netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
|
||||
<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
|
||||
@@ -56,7 +56,7 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
url: restUrl + 'repositories/' + this.repository.id + '/browse.json',
|
||||
method: 'GET'
|
||||
}),
|
||||
fields: ['path', 'name', 'length', 'lastModified', 'directory', 'description', 'subRepositoryUrl'],
|
||||
fields: ['path', 'name', 'length', 'lastModified', 'directory', 'description', 'subrepository'],
|
||||
root: 'files',
|
||||
idProperty: 'path',
|
||||
autoLoad: true,
|
||||
@@ -111,8 +111,8 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
dataIndex: 'description',
|
||||
header: 'Description'
|
||||
},{
|
||||
id: 'subRepositoryUrl',
|
||||
dataIndex: 'subRepositoryUrl',
|
||||
id: 'subrepository',
|
||||
dataIndex: 'subrepository',
|
||||
hidden: true
|
||||
}]
|
||||
});
|
||||
@@ -336,17 +336,21 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
},
|
||||
|
||||
renderName: function(name, p, record){
|
||||
var subRepository = record.get('subRepositoryUrl');
|
||||
var subRepository = record.get('subrepository');
|
||||
var folder = record.get('directory');
|
||||
var path = null;
|
||||
var template = null;
|
||||
if ( subRepository ){
|
||||
// get real revision (.hgsubstate)?
|
||||
path = this.transformLink(subRepository);
|
||||
var subRepositoryUrl = subRepository['browser-url'];
|
||||
if (!subRepositoryUrl){
|
||||
subRepositoryUrl = subRepository['repository-url'];
|
||||
}
|
||||
path = this.transformLink(subRepositoryUrl);
|
||||
if ( path ){
|
||||
template = this.templateInternalLink;
|
||||
} else {
|
||||
path = subRepository;
|
||||
path = subRepositoryUrl;
|
||||
template = this.templateExternalLink;
|
||||
}
|
||||
} else {
|
||||
@@ -364,7 +368,8 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
renderIcon: function(directory, p, record){
|
||||
var icon = null;
|
||||
var subRepository = record.get('subRepositoryUrl');
|
||||
var subRepository = record.get('subrepository');
|
||||
|
||||
var name = record.get('name');
|
||||
if ( subRepository ){
|
||||
icon = this.iconSubRepository;
|
||||
|
||||
Reference in New Issue
Block a user