Source:
private List<AccurevTransaction> filterTransactions( List<AccurevTransaction> transactions, UpdateLog updateLog) { List<AccurevTransaction> filteredTransactions; if (updateLog.hasUpdate()) { filteredTransactions = new ArrayList<>(); if (updateLog.hasChanges()) { List<String> changesFiles = updateLog.changedFiles; List<String> filteredFiles = new ArrayList<>(changesFiles); for (AccurevTransaction transaction : transactions) { List<String> rawPaths = transaction.getAffectedRawPaths(); boolean includeTransaction = true; for (String rawPath : rawPaths) { if (!changesFiles.contains(rawPath)) { includeTransaction = false; break; } } if (includeTransaction) { filteredTransactions.add(transaction); filteredFiles.removeAll(rawPaths); } } if (!filteredFiles.isEmpty()) { AccurevTransaction extraFiles = new AccurevTransaction(); extraFiles.setDate(new Date()); extraFiles.setAction("promote"); extraFiles.setId("upstream"); extraFiles.setMsg("Upstream changes"); extraFiles.setUser("upstream"); filteredFiles.forEach(extraFiles::addAffectedPath); filteredTransactions.add(extraFiles); } } } else { filteredTransactions = transactions; } filteredTransactions.removeIf(t -> t.getAction().equalsIgnoreCase("dispatch")); logger.info("subpath:" + subpath); if (subpath != null && !subpath.isEmpty()) { logger.info("before filter by subpath process.."); filteredTransactions.forEach(transaction -> logger.info("transaction:" + transaction)); logger.info("starting filter by subpath process.."); filteredTransactions = filterBySubpath(filteredTransactions); logger.info("starting filter by subpath process.."); logger.info("after filter by subpath process.."); filteredTransactions.forEach(transaction -> logger.info("transaction:" + transaction)); } else { logger.info("subpath filter is not applied."); } return filteredTransactions; }

Target:
private List<AccurevTransaction> filterTransactions( List<AccurevTransaction> transactions, UpdateLog updateLog) { List<AccurevTransaction> filteredTransactions; if (updateLog.hasUpdate()) { filteredTransactions = new ArrayList<>(); if (updateLog.hasChanges()) { List<String> changesFiles = updateLog.changedFiles; List<String> filteredFiles = new ArrayList<>(changesFiles); for (AccurevTransaction transaction : transactions) { List<String> rawPaths = transaction.getAffectedRawPaths(); boolean includeTransaction = true; for (String rawPath : rawPaths) { if (!changesFiles.contains(rawPath)) { includeTransaction = false; break; } } if (includeTransaction) { filteredTransactions.add(transaction); filteredFiles.removeAll(rawPaths); } } if (!filteredFiles.isEmpty()) { AccurevTransaction extraFiles = new AccurevTransaction(); extraFiles.setDate(new Date()); extraFiles.setAction("promote"); extraFiles.setId("upstream"); extraFiles.setMsg("Upstream changes"); extraFiles.setUser("upstream"); filteredFiles.forEach(extraFiles::addAffectedPath); filteredTransactions.add(extraFiles); } } } else { filteredTransactions = transactions; } filteredTransactions.removeIf(t -> t.getAction().equalsIgnoreCase("dispatch")); logger.fine("subpath:" + subpath); if (StringUtils.isNotEmpty(subpath)) { logger.fine("before filtering by subpath process.."); filteredTransactions.forEach(transaction -> logger.fine("transaction:" + transaction)); filteredTransactions = filterBySubpath(filteredTransactions); logger.fine("after filter by subpath process.."); filteredTransactions.forEach(transaction -> logger.fine("transaction:" + transaction)); } else { logger.fine("subpath filter is not applied."); } return filteredTransactions; }