mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
added option to display revisions as part of the node id
This commit is contained in:
@@ -101,6 +101,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
return pythonPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isShowRevisionInId()
|
||||
{
|
||||
return showRevisionInId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -171,6 +182,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
this.pythonPath = pythonPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param showRevisionInId
|
||||
*/
|
||||
public void setShowRevisionInId(boolean showRevisionInId)
|
||||
{
|
||||
this.showRevisionInId = showRevisionInId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -198,4 +220,7 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
|
||||
/** Field description */
|
||||
private boolean useOptimizedBytecode = false;
|
||||
|
||||
/** Field description */
|
||||
private boolean showRevisionInId = false;
|
||||
}
|
||||
|
||||
@@ -148,6 +148,19 @@ public class HgCommandContext implements Closeable
|
||||
return repository;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HgConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -87,7 +87,7 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
com.aragost.javahg.Repository repository = open();
|
||||
HgLogChangesetCommand cmd = HgLogChangesetCommand.on(repository);
|
||||
HgLogChangesetCommand cmd = on(repository);
|
||||
|
||||
return cmd.rev(id).single();
|
||||
}
|
||||
@@ -127,19 +127,16 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
||||
|
||||
if (!Strings.isNullOrEmpty(startChangeset))
|
||||
{
|
||||
start = HgLogChangesetCommand.on(repository).rev(
|
||||
startChangeset).singleRevision();
|
||||
start = on(repository).rev(startChangeset).singleRevision();
|
||||
}
|
||||
else if (!Strings.isNullOrEmpty(endChangeset))
|
||||
{
|
||||
end = HgLogChangesetCommand.on(repository).rev(
|
||||
endChangeset).singleRevision();
|
||||
end = on(repository).rev(endChangeset).singleRevision();
|
||||
}
|
||||
|
||||
if (start < 0)
|
||||
{
|
||||
start =
|
||||
HgLogChangesetCommand.on(repository).rev("tip").singleRevision();
|
||||
start = on(repository).rev("tip").singleRevision();
|
||||
}
|
||||
|
||||
if (start >= 0)
|
||||
@@ -162,8 +159,8 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
||||
end = 0;
|
||||
}
|
||||
|
||||
List<Changeset> changesets =
|
||||
HgLogChangesetCommand.on(repository).rev(start + ":" + end).execute();
|
||||
List<Changeset> changesets = on(repository).rev(start + ":"
|
||||
+ end).execute();
|
||||
|
||||
result = new ChangesetPagingResult(total, changesets);
|
||||
}
|
||||
@@ -192,7 +189,7 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
||||
private ChangesetPagingResult collectSafely(
|
||||
com.aragost.javahg.Repository repository, LogCommandRequest request)
|
||||
{
|
||||
HgLogChangesetCommand cmd = HgLogChangesetCommand.on(repository);
|
||||
HgLogChangesetCommand cmd = on(repository);
|
||||
String startChangeset = request.getStartChangeset();
|
||||
String endChangeset = request.getEndChangeset();
|
||||
|
||||
@@ -265,9 +262,22 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
||||
revs[i] = sublist.get(i).toString();
|
||||
}
|
||||
|
||||
changesets = HgLogChangesetCommand.on(repository).rev(revs).execute();
|
||||
changesets = on(repository).rev(revs).execute();
|
||||
}
|
||||
|
||||
return new ChangesetPagingResult(total, changesets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private HgLogChangesetCommand on(com.aragost.javahg.Repository repository)
|
||||
{
|
||||
return HgLogChangesetCommand.on(repository, getContext().getConfig());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.Person;
|
||||
|
||||
@@ -94,10 +95,12 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param config
|
||||
*/
|
||||
public HgLogChangesetCommand(Repository repository)
|
||||
public HgLogChangesetCommand(Repository repository, HgConfig config)
|
||||
{
|
||||
super(repository);
|
||||
this.config = config;
|
||||
withDebugFlag();
|
||||
}
|
||||
|
||||
@@ -108,12 +111,13 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param config
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static HgLogChangesetCommand on(Repository repository)
|
||||
public static HgLogChangesetCommand on(Repository repository, HgConfig config)
|
||||
{
|
||||
return new HgLogChangesetCommand(repository);
|
||||
return new HgLogChangesetCommand(repository, config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,9 +223,12 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
public int singleRevision(String... files)
|
||||
{
|
||||
Integer rev = Utils.single(loadRevisions(files));
|
||||
if ( rev == null ){
|
||||
|
||||
if (rev == null)
|
||||
{
|
||||
rev = -1;
|
||||
}
|
||||
|
||||
return rev;
|
||||
}
|
||||
|
||||
@@ -254,10 +261,8 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
private Changeset createFromInputStream(HgInputStream in) throws IOException
|
||||
{
|
||||
Changeset changeset = new Changeset();
|
||||
byte[] node = in.next(40);
|
||||
String nodeString = new String(node);
|
||||
|
||||
changeset.setId(nodeString);
|
||||
changeset.setId(readId(in));
|
||||
|
||||
String user = in.textUpTo('\n');
|
||||
|
||||
@@ -274,20 +279,16 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
changeset.getBranches().add(branch);
|
||||
}
|
||||
|
||||
in.upTo(':');
|
||||
String p1 = readId(in);
|
||||
|
||||
String p1 = in.nextAsText(40);
|
||||
|
||||
if (!NULL_ID.equals(p1))
|
||||
if (!isNullId(p1))
|
||||
{
|
||||
changeset.getParents().add(p1);
|
||||
}
|
||||
|
||||
in.upTo(':');
|
||||
String p2 = readId(in);
|
||||
|
||||
String p2 = in.nextAsText(40);
|
||||
|
||||
if (!NULL_ID.equals(p2))
|
||||
if (!isNullId(p2))
|
||||
{
|
||||
changeset.getParents().add(p2);
|
||||
}
|
||||
@@ -361,6 +362,45 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
return revisions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private String readId(HgInputStream in) throws IOException
|
||||
{
|
||||
String nodeString = null;
|
||||
|
||||
if (config.isShowRevisionInId())
|
||||
{
|
||||
Integer rev = in.readDecimal();
|
||||
|
||||
if (rev != null)
|
||||
{
|
||||
nodeString = String.valueOf(rev);
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeString = "-1";
|
||||
}
|
||||
|
||||
in.upTo(':');
|
||||
nodeString = nodeString.concat(":").concat(in.nextAsText(40));
|
||||
}
|
||||
else
|
||||
{
|
||||
in.upTo(':');
|
||||
nodeString = in.nextAsText(40);
|
||||
}
|
||||
|
||||
return nodeString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -402,4 +442,25 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
|
||||
return changesets;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isNullId(String id)
|
||||
{
|
||||
return ((id != null) && id.equals("-1:".concat(NULL_ID)))
|
||||
|| id.equals(NULL_ID);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private HgConfig config;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user