package test;

import org.junit.Test;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created by shuruiz on 9/7/15.
 */
public class MergeRepo {
    String path = "testcpp/originMarlin/";
    String main_repo = "testcpp/originMarlin/upstream/Marlin/Marlin/";
    TestInitial testInitial = new TestInitial(path);
    HashSet<String> forkName = new HashSet<>();
    List<String> mergedFiles = new ArrayList<>();

    public HashSet<String> inputFileInit() {
        File upstream = new File(main_repo);
        File[] matches = upstream.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(".cpp");
//                return name.endsWith(".h") || name.endsWith(".cpp");
            }
        });

        for (File f : matches) {
            if(!f.getName().equals("fastio.h")||f.getName().contains("language")) {
                mergedFiles.add(f.getName());
            }
        }
        File dir = new File(path);
        String[] names = dir.list();
        for (String name : names) {
            if (new File(path + name).isDirectory()) {
                if (!name.equals("upstream")) {
                    forkName.add(name);
                }
            }


        forkName.add("alromh87");
        return forkName;
    }


    @Test
    public void NWayMerge_Rev() {
        HashSet<String> forkNames = inputFileInit();
        for (String fork : forkNames) {

            for (String fileToBeMerged : mergedFiles) {
                testInitial.checkMergeRepo(path, fork, fileToBeMerged);
            }
        }

//         Set<Set<String>> combinationFiles = testInitial.getAllConfigurations(forkNames, 3);
//        for (Set<String> combination : combinationFiles) {
//            for (String fileToBeMerged : mergedFiles) {
//                testInitial.checkMergeRepo(path, combination, fileToBeMerged);
//
//            }
//        }
    }
}
@@ -872,24 +872,26 @@
        %7D);%0A%0A
+//
         for 
@@ -907,24 +907,26 @@
  matches) %7B%0A
+//
             
@@ -993,24 +993,26 @@
 nguage%22)) %7B%0A
+//
             
@@ -1045,16 +1045,18 @@
 ame());%0A
+//
         
@@ -1053,32 +1053,37 @@
 //            %7D%0A
+//%0A//
         %7D%0A      
@@ -1356,24 +1356,35 @@
          %7D%0A%0A
+        %7D%0A%0A
 %0A        for
@@ -1398,16 +1398,14 @@
 dd(%22
-alromh87
+drsdre
 %22);%0A

modify CppNodeArtifact conditionStack 1