mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
implement mercurial getChangeset
This commit is contained in:
@@ -321,6 +321,30 @@ public class AbstractHgHandler
|
|||||||
protected <T> T getResultFromScript(Class<T> resultType,
|
protected <T> T getResultFromScript(Class<T> resultType,
|
||||||
String scriptResource, Map<String, String> extraEnv)
|
String scriptResource, Map<String, String> extraEnv)
|
||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
|
{
|
||||||
|
return getResultFromScript(resultType, scriptResource, jaxbContext,
|
||||||
|
extraEnv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param resultType
|
||||||
|
* @param scriptResource
|
||||||
|
* @param jaxbContext
|
||||||
|
* @param extraEnv
|
||||||
|
* @param <T>
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
protected <T> T getResultFromScript(Class<T> resultType,
|
||||||
|
String scriptResource, JAXBContext jaxbContext,
|
||||||
|
Map<String, String> extraEnv)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Process p = createPythonProcess(extraEnv);
|
Process p = createPythonProcess(extraEnv);
|
||||||
T result = null;
|
T result = null;
|
||||||
|
|||||||
@@ -74,14 +74,17 @@ public class HgChangesetViewer extends AbstractHgHandler
|
|||||||
*
|
*
|
||||||
* @param handler
|
* @param handler
|
||||||
* @param changesetPagingResultContext
|
* @param changesetPagingResultContext
|
||||||
|
* @param changesetContext
|
||||||
* @param context
|
* @param context
|
||||||
* @param repositoryDirectory
|
* @param repositoryDirectory
|
||||||
*/
|
*/
|
||||||
public HgChangesetViewer(HgRepositoryHandler handler,
|
public HgChangesetViewer(HgRepositoryHandler handler,
|
||||||
JAXBContext changesetPagingResultContext,
|
JAXBContext changesetPagingResultContext,
|
||||||
HgContext context, File repositoryDirectory)
|
JAXBContext changesetContext, HgContext context,
|
||||||
|
File repositoryDirectory)
|
||||||
{
|
{
|
||||||
super(handler, changesetPagingResultContext, context, repositoryDirectory);
|
super(handler, changesetPagingResultContext, context, repositoryDirectory);
|
||||||
|
this.changesetContext = changesetContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,15 +93,18 @@ public class HgChangesetViewer extends AbstractHgHandler
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param handler
|
* @param handler
|
||||||
|
* @param changesetContext
|
||||||
* @param context
|
* @param context
|
||||||
* @param changesetPagingResultContext
|
* @param changesetPagingResultContext
|
||||||
* @param repository
|
* @param repository
|
||||||
*/
|
*/
|
||||||
public HgChangesetViewer(HgRepositoryHandler handler,
|
public HgChangesetViewer(HgRepositoryHandler handler,
|
||||||
JAXBContext changesetPagingResultContext,
|
JAXBContext changesetPagingResultContext,
|
||||||
HgContext context, Repository repository)
|
JAXBContext changesetContext, HgContext context,
|
||||||
|
Repository repository)
|
||||||
{
|
{
|
||||||
super(handler, changesetPagingResultContext, context, repository);
|
super(handler, changesetPagingResultContext, context, repository);
|
||||||
|
this.changesetContext = changesetContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
@@ -110,11 +116,25 @@ public class HgChangesetViewer extends AbstractHgHandler
|
|||||||
* @param revision
|
* @param revision
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Changeset getChangeset(String revision)
|
public Changeset getChangeset(String revision)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
Map<String, String> env = new HashMap<String, String>();
|
||||||
|
|
||||||
|
env.put(ENV_REVISION, HgUtil.getRevision(revision));
|
||||||
|
env.put(ENV_PATH, Util.EMPTY_STRING);
|
||||||
|
env.put(ENV_PAGE_START, Util.EMPTY_STRING);
|
||||||
|
env.put(ENV_PAGE_LIMIT, Util.EMPTY_STRING);
|
||||||
|
env.put(ENV_REVISION_START, Util.EMPTY_STRING);
|
||||||
|
env.put(ENV_REVISION_END, Util.EMPTY_STRING);
|
||||||
|
|
||||||
|
return getResultFromScript(Changeset.class, RESOURCE_LOG, changesetContext,
|
||||||
|
env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,4 +251,9 @@ public class HgChangesetViewer extends AbstractHgHandler
|
|||||||
|
|
||||||
return getChangesets(null, null, null, null, startNode, endNode);
|
return getChangesets(null, null, null, null, startNode, endNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private JAXBContext changesetContext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ public class HgRepositoryHandler
|
|||||||
{
|
{
|
||||||
this.browserResultContext = JAXBContext.newInstance(BrowserResult.class);
|
this.browserResultContext = JAXBContext.newInstance(BrowserResult.class);
|
||||||
this.blameResultContext = JAXBContext.newInstance(BlameResult.class);
|
this.blameResultContext = JAXBContext.newInstance(BlameResult.class);
|
||||||
|
this.changesetContext = JAXBContext.newInstance(Changeset.class);
|
||||||
this.changesetPagingResultContext =
|
this.changesetPagingResultContext =
|
||||||
JAXBContext.newInstance(ChangesetPagingResult.class);
|
JAXBContext.newInstance(ChangesetPagingResult.class);
|
||||||
}
|
}
|
||||||
@@ -248,8 +249,8 @@ public class HgRepositoryHandler
|
|||||||
if (TYPE_NAME.equals(type))
|
if (TYPE_NAME.equals(type))
|
||||||
{
|
{
|
||||||
changesetViewer = new HgChangesetViewer(this,
|
changesetViewer = new HgChangesetViewer(this,
|
||||||
changesetPagingResultContext, hgContextProvider.get(),
|
changesetPagingResultContext, changesetContext,
|
||||||
repository);
|
hgContextProvider.get(), repository);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -416,7 +417,8 @@ public class HgRepositoryHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new HgChangesetViewer(this, changesetPagingResultContext,
|
return new HgChangesetViewer(this, changesetPagingResultContext,
|
||||||
hgContextProvider.get(), repositoryDirectory);
|
changesetContext, hgContextProvider.get(),
|
||||||
|
repositoryDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- set methods ----------------------------------------------------------
|
//~--- set methods ----------------------------------------------------------
|
||||||
@@ -668,6 +670,9 @@ public class HgRepositoryHandler
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
private JAXBContext browserResultContext;
|
private JAXBContext browserResultContext;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private JAXBContext changesetContext;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private JAXBContext changesetPagingResultContext;
|
private JAXBContext changesetPagingResultContext;
|
||||||
|
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ def printFooter():
|
|||||||
print ' </changesets>'
|
print ' </changesets>'
|
||||||
print '</changeset-paging>'
|
print '</changeset-paging>'
|
||||||
|
|
||||||
def printChangesetsForPath(repo, path):
|
def printChangesetsForPath(repo, rev, path):
|
||||||
rev = os.environ['SCM_REVISION']
|
|
||||||
if len(rev) <= 0:
|
if len(rev) <= 0:
|
||||||
rev = "tip"
|
rev = "tip"
|
||||||
|
|
||||||
@@ -178,9 +177,14 @@ repo = hg.repository(ui.ui(), path = repositoryPath)
|
|||||||
path = os.environ['SCM_PATH']
|
path = os.environ['SCM_PATH']
|
||||||
startNode = os.environ['SCM_REVISION_START']
|
startNode = os.environ['SCM_REVISION_START']
|
||||||
endNode = os.environ['SCM_REVISION_END']
|
endNode = os.environ['SCM_REVISION_END']
|
||||||
|
rev = os.environ['SCM_REVISION']
|
||||||
|
|
||||||
if len(path) > 0:
|
if len(path) > 0:
|
||||||
printChangesetsForPath(repo, path)
|
printChangesetsForPath(repo, rev, path)
|
||||||
|
elif len(rev) > 0:
|
||||||
|
ctx = repo[rev]
|
||||||
|
print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
||||||
|
printChangeset(repo, ctx)
|
||||||
else:
|
else:
|
||||||
if len(startNode) > 0 and len(endNode) > 0:
|
if len(startNode) > 0 and len(endNode) > 0:
|
||||||
# start and end revision
|
# start and end revision
|
||||||
|
|||||||
Reference in New Issue
Block a user