mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
pull modify changes from working copy to central repository so that mercurial hooks gets triggered
This commit is contained in:
@@ -4,7 +4,7 @@ import com.aragost.javahg.Changeset;
|
||||
import com.aragost.javahg.Repository;
|
||||
import com.aragost.javahg.commands.CommitCommand;
|
||||
import com.aragost.javahg.commands.ExecutionException;
|
||||
import com.aragost.javahg.commands.PushCommand;
|
||||
import com.aragost.javahg.commands.PullCommand;
|
||||
import com.aragost.javahg.commands.RemoveCommand;
|
||||
import com.aragost.javahg.commands.StatusCommand;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -118,14 +118,26 @@ public class HgModifyCommand implements ModifyCommand {
|
||||
throw new NoChangesMadeException(context.getScmRepository());
|
||||
}
|
||||
CommitCommand.on(workingRepository).user(String.format("%s <%s>", request.getAuthor().getName(), request.getAuthor().getMail())).message(request.getCommitMessage()).execute();
|
||||
List<Changeset> execute = PushCommand.on(workingRepository).execute();
|
||||
List<Changeset> execute = pullModifyChangesToCentralRepository(request, workingCopy);
|
||||
return execute.get(0).getNode();
|
||||
} catch (IOException | ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throwInternalRepositoryException("could not execute command on repository", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Changeset> pullModifyChangesToCentralRepository(ModifyCommandRequest request, WorkingCopy<com.aragost.javahg.Repository> workingCopy) {
|
||||
try {
|
||||
com.aragost.javahg.commands.PullCommand pullCommand = PullCommand.on(workingCopy.getCentralRepository());
|
||||
workdirFactory.configure(pullCommand);
|
||||
return pullCommand.execute(workingCopy.getDirectory().getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
throw new IntegrateChangesFromWorkdirException(context.getScmRepository(),
|
||||
String.format("Could not pull modify changes from working copy to central repository", request.getBranch()),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
private String throwInternalRepositoryException(String message, Exception e) {
|
||||
throw new InternalRepositoryException(context.getScmRepository(), message, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user