mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +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;
|
return pythonPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isShowRevisionInId()
|
||||||
|
{
|
||||||
|
return showRevisionInId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -171,6 +182,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
|||||||
this.pythonPath = pythonPath;
|
this.pythonPath = pythonPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param showRevisionInId
|
||||||
|
*/
|
||||||
|
public void setShowRevisionInId(boolean showRevisionInId)
|
||||||
|
{
|
||||||
|
this.showRevisionInId = showRevisionInId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -198,4 +220,7 @@ public class HgConfig extends SimpleRepositoryConfig
|
|||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private boolean useOptimizedBytecode = false;
|
private boolean useOptimizedBytecode = false;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private boolean showRevisionInId = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,19 @@ public class HgCommandContext implements Closeable
|
|||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public HgConfig getConfig()
|
||||||
|
{
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
|||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
com.aragost.javahg.Repository repository = open();
|
com.aragost.javahg.Repository repository = open();
|
||||||
HgLogChangesetCommand cmd = HgLogChangesetCommand.on(repository);
|
HgLogChangesetCommand cmd = on(repository);
|
||||||
|
|
||||||
return cmd.rev(id).single();
|
return cmd.rev(id).single();
|
||||||
}
|
}
|
||||||
@@ -127,19 +127,16 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
|||||||
|
|
||||||
if (!Strings.isNullOrEmpty(startChangeset))
|
if (!Strings.isNullOrEmpty(startChangeset))
|
||||||
{
|
{
|
||||||
start = HgLogChangesetCommand.on(repository).rev(
|
start = on(repository).rev(startChangeset).singleRevision();
|
||||||
startChangeset).singleRevision();
|
|
||||||
}
|
}
|
||||||
else if (!Strings.isNullOrEmpty(endChangeset))
|
else if (!Strings.isNullOrEmpty(endChangeset))
|
||||||
{
|
{
|
||||||
end = HgLogChangesetCommand.on(repository).rev(
|
end = on(repository).rev(endChangeset).singleRevision();
|
||||||
endChangeset).singleRevision();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
start =
|
start = on(repository).rev("tip").singleRevision();
|
||||||
HgLogChangesetCommand.on(repository).rev("tip").singleRevision();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start >= 0)
|
if (start >= 0)
|
||||||
@@ -162,8 +159,8 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
|||||||
end = 0;
|
end = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Changeset> changesets =
|
List<Changeset> changesets = on(repository).rev(start + ":"
|
||||||
HgLogChangesetCommand.on(repository).rev(start + ":" + end).execute();
|
+ end).execute();
|
||||||
|
|
||||||
result = new ChangesetPagingResult(total, changesets);
|
result = new ChangesetPagingResult(total, changesets);
|
||||||
}
|
}
|
||||||
@@ -192,7 +189,7 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
|||||||
private ChangesetPagingResult collectSafely(
|
private ChangesetPagingResult collectSafely(
|
||||||
com.aragost.javahg.Repository repository, LogCommandRequest request)
|
com.aragost.javahg.Repository repository, LogCommandRequest request)
|
||||||
{
|
{
|
||||||
HgLogChangesetCommand cmd = HgLogChangesetCommand.on(repository);
|
HgLogChangesetCommand cmd = on(repository);
|
||||||
String startChangeset = request.getStartChangeset();
|
String startChangeset = request.getStartChangeset();
|
||||||
String endChangeset = request.getEndChangeset();
|
String endChangeset = request.getEndChangeset();
|
||||||
|
|
||||||
@@ -265,9 +262,22 @@ public class HgLogCommand extends AbstractCommand implements LogCommand
|
|||||||
revs[i] = sublist.get(i).toString();
|
revs[i] = sublist.get(i).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
changesets = HgLogChangesetCommand.on(repository).rev(revs).execute();
|
changesets = on(repository).rev(revs).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ChangesetPagingResult(total, changesets);
|
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 com.google.common.collect.Lists;
|
||||||
|
|
||||||
import sonia.scm.repository.Changeset;
|
import sonia.scm.repository.Changeset;
|
||||||
|
import sonia.scm.repository.HgConfig;
|
||||||
import sonia.scm.repository.Modifications;
|
import sonia.scm.repository.Modifications;
|
||||||
import sonia.scm.repository.Person;
|
import sonia.scm.repository.Person;
|
||||||
|
|
||||||
@@ -94,10 +95,12 @@ public class HgLogChangesetCommand extends AbstractCommand
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param repository
|
* @param repository
|
||||||
|
* @param config
|
||||||
*/
|
*/
|
||||||
public HgLogChangesetCommand(Repository repository)
|
public HgLogChangesetCommand(Repository repository, HgConfig config)
|
||||||
{
|
{
|
||||||
super(repository);
|
super(repository);
|
||||||
|
this.config = config;
|
||||||
withDebugFlag();
|
withDebugFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,12 +111,13 @@ public class HgLogChangesetCommand extends AbstractCommand
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param repository
|
* @param repository
|
||||||
|
* @param config
|
||||||
*
|
*
|
||||||
* @return
|
* @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)
|
public int singleRevision(String... files)
|
||||||
{
|
{
|
||||||
Integer rev = Utils.single(loadRevisions(files));
|
Integer rev = Utils.single(loadRevisions(files));
|
||||||
if ( rev == null ){
|
|
||||||
|
if (rev == null)
|
||||||
|
{
|
||||||
rev = -1;
|
rev = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rev;
|
return rev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,10 +261,8 @@ public class HgLogChangesetCommand extends AbstractCommand
|
|||||||
private Changeset createFromInputStream(HgInputStream in) throws IOException
|
private Changeset createFromInputStream(HgInputStream in) throws IOException
|
||||||
{
|
{
|
||||||
Changeset changeset = new Changeset();
|
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');
|
String user = in.textUpTo('\n');
|
||||||
|
|
||||||
@@ -274,20 +279,16 @@ public class HgLogChangesetCommand extends AbstractCommand
|
|||||||
changeset.getBranches().add(branch);
|
changeset.getBranches().add(branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
in.upTo(':');
|
String p1 = readId(in);
|
||||||
|
|
||||||
String p1 = in.nextAsText(40);
|
if (!isNullId(p1))
|
||||||
|
|
||||||
if (!NULL_ID.equals(p1))
|
|
||||||
{
|
{
|
||||||
changeset.getParents().add(p1);
|
changeset.getParents().add(p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
in.upTo(':');
|
String p2 = readId(in);
|
||||||
|
|
||||||
String p2 = in.nextAsText(40);
|
if (!isNullId(p2))
|
||||||
|
|
||||||
if (!NULL_ID.equals(p2))
|
|
||||||
{
|
{
|
||||||
changeset.getParents().add(p2);
|
changeset.getParents().add(p2);
|
||||||
}
|
}
|
||||||
@@ -361,6 +362,45 @@ public class HgLogChangesetCommand extends AbstractCommand
|
|||||||
return revisions;
|
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
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -402,4 +442,25 @@ public class HgLogChangesetCommand extends AbstractCommand
|
|||||||
|
|
||||||
return changesets;
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
|||||||
configWizardLabelText: 'Start Configuration Wizard',
|
configWizardLabelText: 'Start Configuration Wizard',
|
||||||
encodingText: 'Encoding',
|
encodingText: 'Encoding',
|
||||||
disabledText: 'Disabled',
|
disabledText: 'Disabled',
|
||||||
|
showRevisionInIdText: 'Show Revision',
|
||||||
|
|
||||||
// helpText
|
// helpText
|
||||||
hgBinaryHelpText: 'Location of Mercurial binary.',
|
hgBinaryHelpText: 'Location of Mercurial binary.',
|
||||||
@@ -55,6 +56,8 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
|||||||
encodingHelpText: 'Repository Encoding.',
|
encodingHelpText: 'Repository Encoding.',
|
||||||
disabledHelpText: 'Enable or disable the Mercurial plugin. \n\
|
disabledHelpText: 'Enable or disable the Mercurial plugin. \n\
|
||||||
Note you have to reload the page, after changing this value.',
|
Note you have to reload the page, after changing this value.',
|
||||||
|
showRevisionInIdHelpText: 'Show revision as part of the node id. Note: \n\
|
||||||
|
You have to restart the ApplicationServer to affect cached changesets.',
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
|
|
||||||
@@ -95,6 +98,12 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
|||||||
fieldLabel: this.useOptimizedBytecodeText,
|
fieldLabel: this.useOptimizedBytecodeText,
|
||||||
inputValue: 'true',
|
inputValue: 'true',
|
||||||
helpText: this.useOptimizedBytecodeHelpText
|
helpText: this.useOptimizedBytecodeHelpText
|
||||||
|
},{
|
||||||
|
xtype: 'checkbox',
|
||||||
|
name: 'showRevisionInId',
|
||||||
|
fieldLabel: this.showRevisionInIdText,
|
||||||
|
inputValue: 'true',
|
||||||
|
helpText: this.showRevisionInIdHelpText
|
||||||
},{
|
},{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'disabled',
|
name: 'disabled',
|
||||||
@@ -200,6 +209,7 @@ if ( i18n != null && i18n.country == 'de' ){
|
|||||||
configWizardText: 'Konfigurations-Assistenten starten',
|
configWizardText: 'Konfigurations-Assistenten starten',
|
||||||
configWizardLabelText: 'Konfigurations-Assistent',
|
configWizardLabelText: 'Konfigurations-Assistent',
|
||||||
disabledText: 'Deaktivieren',
|
disabledText: 'Deaktivieren',
|
||||||
|
showRevisionInIdText: 'Zeige Revision an',
|
||||||
|
|
||||||
// helpText
|
// helpText
|
||||||
hgBinaryHelpText: 'Pfad zum "hg" Befehl.',
|
hgBinaryHelpText: 'Pfad zum "hg" Befehl.',
|
||||||
@@ -208,7 +218,10 @@ if ( i18n != null && i18n.country == 'de' ){
|
|||||||
repositoryDirectoryHelpText: 'Verzeichnis der Mercurial-Repositories.',
|
repositoryDirectoryHelpText: 'Verzeichnis der Mercurial-Repositories.',
|
||||||
useOptimizedBytecodeHelpText: 'Optimierten Bytecode verwenden (python -O).',
|
useOptimizedBytecodeHelpText: 'Optimierten Bytecode verwenden (python -O).',
|
||||||
disabledHelpText: 'Aktivieren oder deaktivieren des Mercurial Plugins.\n\
|
disabledHelpText: 'Aktivieren oder deaktivieren des Mercurial Plugins.\n\
|
||||||
Die Seite muss neu geladen werden wenn dieser Wert geändert wird.'
|
Die Seite muss neu geladen werden wenn dieser Wert geändert wird.',
|
||||||
|
showRevisionInIdHelpText: 'Zeige die Revision als teil der NodeId an. \n\
|
||||||
|
Der ApplicationServer muss neugestartet werden um zwischengespeicherte\n\
|
||||||
|
Changesets zuändern.'
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
header = "%{pattern}"
|
header = "%{pattern}"
|
||||||
changeset = "{node}{author}\n{date|hgdate}\n{branch}\n{parents}{tags}{file_adds}{file_mods}{file_dels}\n{desc}\0"
|
changeset = "{rev}:{node}{author}\n{date|hgdate}\n{branch}\n{parents}{tags}{file_adds}{file_mods}{file_dels}\n{desc}\0"
|
||||||
tag = "t {tag}\n"
|
tag = "t {tag}\n"
|
||||||
file_add = "a {file_add}\n"
|
file_add = "a {file_add}\n"
|
||||||
file_mod = "m {file_mod}\n"
|
file_mod = "m {file_mod}\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user