in maven-scm-providers/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommand.java [51:107]
protected CheckInScmResult executeCheckInCommand(
ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion tag) throws ScmException {
if (tag != null && !StringUtils.isEmpty(tag.getName())) {
throw new ScmException("This provider can't handle tags for this operation");
}
File workingDir = fileSet.getBasedir();
String branchName = HgUtils.getCurrentBranchName(workingDir);
boolean differentOutgoingBranch =
repo.isPushChanges() ? HgUtils.differentOutgoingBranchFound(workingDir, branchName) : false;
// Get files that will be committed (if not specified in fileSet)
List<ScmFile> commitedFiles = new ArrayList<>();
List<File> files = fileSet.getFileList();
if (files.isEmpty()) { // Either commit all changes
HgStatusCommand statusCmd = new HgStatusCommand();
StatusScmResult status = statusCmd.executeStatusCommand(repo, fileSet);
List<ScmFile> statusFiles = status.getChangedFiles();
for (ScmFile file : statusFiles) {
if (file.getStatus() == ScmFileStatus.ADDED
|| file.getStatus() == ScmFileStatus.DELETED
|| file.getStatus() == ScmFileStatus.MODIFIED) {
commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
}
}
} else { // Or commit spesific files
for (File file : files) {
commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
}
}
// Commit to local branch
String[] commitCmd = new String[] {HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, message};
commitCmd = HgUtils.expandCommandLine(commitCmd, fileSet);
ScmResult result = HgUtils.execute(new HgConsumer(), fileSet.getBasedir(), commitCmd);
// Push to parent branch if any
HgScmProviderRepository repository = (HgScmProviderRepository) repo;
if (repo.isPushChanges()) {
if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) {
String[] pushCmd = new String[] {
HgCommandConstants.PUSH_CMD,
differentOutgoingBranch ? HgCommandConstants.REVISION_OPTION + branchName : null,
repository.getURI()
};
result = HgUtils.execute(new HgConsumer(), fileSet.getBasedir(), pushCmd);
}
return new CheckInScmResult(commitedFiles, result);
}
return new CheckInScmResult(commitedFiles, result);
}