mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
implement mercurial getChangeset
This commit is contained in:
@@ -321,6 +321,30 @@ public class AbstractHgHandler
|
||||
protected <T> T getResultFromScript(Class<T> resultType,
|
||||
String scriptResource, Map<String, String> extraEnv)
|
||||
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);
|
||||
T result = null;
|
||||
|
||||
@@ -74,14 +74,17 @@ public class HgChangesetViewer extends AbstractHgHandler
|
||||
*
|
||||
* @param handler
|
||||
* @param changesetPagingResultContext
|
||||
* @param changesetContext
|
||||
* @param context
|
||||
* @param repositoryDirectory
|
||||
*/
|
||||
public HgChangesetViewer(HgRepositoryHandler handler,
|
||||
JAXBContext changesetPagingResultContext,
|
||||
HgContext context, File repositoryDirectory)
|
||||
JAXBContext changesetContext, HgContext context,
|
||||
File repositoryDirectory)
|
||||
{
|
||||
super(handler, changesetPagingResultContext, context, repositoryDirectory);
|
||||
this.changesetContext = changesetContext;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,15 +93,18 @@ public class HgChangesetViewer extends AbstractHgHandler
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param changesetContext
|
||||
* @param context
|
||||
* @param changesetPagingResultContext
|
||||
* @param repository
|
||||
*/
|
||||
public HgChangesetViewer(HgRepositoryHandler handler,
|
||||
JAXBContext changesetPagingResultContext,
|
||||
HgContext context, Repository repository)
|
||||
JAXBContext changesetContext, HgContext context,
|
||||
Repository repository)
|
||||
{
|
||||
super(handler, changesetPagingResultContext, context, repository);
|
||||
this.changesetContext = changesetContext;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -110,11 +116,25 @@ public class HgChangesetViewer extends AbstractHgHandler
|
||||
* @param revision
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private JAXBContext changesetContext;
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public class HgRepositoryHandler
|
||||
{
|
||||
this.browserResultContext = JAXBContext.newInstance(BrowserResult.class);
|
||||
this.blameResultContext = JAXBContext.newInstance(BlameResult.class);
|
||||
this.changesetContext = JAXBContext.newInstance(Changeset.class);
|
||||
this.changesetPagingResultContext =
|
||||
JAXBContext.newInstance(ChangesetPagingResult.class);
|
||||
}
|
||||
@@ -248,8 +249,8 @@ public class HgRepositoryHandler
|
||||
if (TYPE_NAME.equals(type))
|
||||
{
|
||||
changesetViewer = new HgChangesetViewer(this,
|
||||
changesetPagingResultContext, hgContextProvider.get(),
|
||||
repository);
|
||||
changesetPagingResultContext, changesetContext,
|
||||
hgContextProvider.get(), repository);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -416,7 +417,8 @@ public class HgRepositoryHandler
|
||||
}
|
||||
|
||||
return new HgChangesetViewer(this, changesetPagingResultContext,
|
||||
hgContextProvider.get(), repositoryDirectory);
|
||||
changesetContext, hgContextProvider.get(),
|
||||
repositoryDirectory);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
@@ -668,6 +670,9 @@ public class HgRepositoryHandler
|
||||
/** Field description */
|
||||
private JAXBContext browserResultContext;
|
||||
|
||||
/** Field description */
|
||||
private JAXBContext changesetContext;
|
||||
|
||||
/** Field description */
|
||||
private JAXBContext changesetPagingResultContext;
|
||||
|
||||
|
||||
@@ -131,8 +131,7 @@ def printFooter():
|
||||
print ' </changesets>'
|
||||
print '</changeset-paging>'
|
||||
|
||||
def printChangesetsForPath(repo, path):
|
||||
rev = os.environ['SCM_REVISION']
|
||||
def printChangesetsForPath(repo, rev, path):
|
||||
if len(rev) <= 0:
|
||||
rev = "tip"
|
||||
|
||||
@@ -178,9 +177,14 @@ repo = hg.repository(ui.ui(), path = repositoryPath)
|
||||
path = os.environ['SCM_PATH']
|
||||
startNode = os.environ['SCM_REVISION_START']
|
||||
endNode = os.environ['SCM_REVISION_END']
|
||||
rev = os.environ['SCM_REVISION']
|
||||
|
||||
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:
|
||||
if len(startNode) > 0 and len(endNode) > 0:
|
||||
# start and end revision
|
||||
|
||||
Reference in New Issue
Block a user