def merge(self,directory):
     commits = getCommits(directory)
     #print(commits)
     mycommits = self.getAllCommits()
     commits_to_fetch = set(commits).difference(set(mycommits))
     fp = open(self.statusfile,'a')
     for k in commits_to_fetch:
         fp.write(k)
     fp.close()
     c_to_fetch = [i.split()[1] for i in commits_to_fetch]
     cont = getCommitsContent(directory,c_to_fetch)
     self.uncompressAndWrite(cont)
     common_commit=[x for x in commits if x in set(mycommits)]
     #print (parent_commit.split()[1]) 
     parent_file_list=self.getFileList(getLastCommit(common_commit))
     my_file_list=self.getFileList(getLastCommit(mycommits))
     other_file_list=self.getFileList(getLastCommit(commits))
     flag=0
     for elem in my_file_list:
             for temp in other_file_list:
                     if(elem==temp):
                             dicts=merge3.devilMerge(self.getFile(getLastCommit(common_commit),elem[0]),self.getFile(getLastCommit(mycommits),elem[0]),self.getFile(getLastCommit(commits),elem[0]))
                             files=open(elem[0],'w')
                             files.write(dicts['md_content'])
                             files.close()
                             if(dicts['conflict']==0 and dicts['merged']!=0):
                                     print("Merged "+elem[0]+"\n")
                             else:
                                     print("Merged with conflicts in "+elem[0]+" not commiting.Please commit after manually changing")
                                     flag=1
     if(flag==0):
             self.commit('auto-merged successfull')
Esempio n. 2
0
    def gotCommitsContent(self, cont, commits, mycommits):
        obj = FileController(self.directory)
        #print ">>>",self.directory,"<<<"
        obj.uncompressAndWrite(cont)
        common_commit = [x for x in commits if x in set(mycommits)]
        #print getLastCommit(common_commit),"\n"
        #print (parent_commit.split()[1])
        parent_file_list = obj.getFileList(getLastCommit(common_commit))
        my_file_list = obj.getFileList(getLastCommit(mycommits))
        #print my_file_list,"\n"
        other_file_list = obj.getFileList(getLastCommit(commits))
        #print other_file_list,"\n"
        flag = 0
        for elem in other_file_list:
            if (elem[0] in [x[0] for x in my_file_list]):
                dicts = merge3.devilMerge(
                    obj.getFile(getLastCommit(common_commit), elem[0]),
                    obj.getFile(getLastCommit(mycommits), elem[0]),
                    obj.getFile(getLastCommit(commits), elem[0]))
                #print dicts
                #reactor.stop()
                #print str(dicts)
                #print "opening file ",elem[0]
                #print os.getcwd()
                #print elem[0]
                try:
                    os.makedirs(os.path.dirname(elem[0]))
                except:
                    pass
                files = open(elem[0], 'w')
                files.write(dicts['md_content'])
                files.close()
                #obj.add(elem[0])
                if (dicts['conflict'] == 1):
                    print(
                        "Merged with conflicts in " + elem[0] +
                        " not commiting.Please commit after manually changing")
                    flag = 1
                else:
                    print("Merged " + elem[0] + " successfully\n")
            else:
                #print "Writing to elem[0]"
                try:
                    os.makedirs(os.path.dirname(elem[0]))
                except:
                    pass
                files = open(elem[0], 'w')
                content = obj.getFiler(getLastCommit(commits), elem[0])
                files.write(content)
                files.close()
                #print elem[0]
                obj.add(elem[0])

        if (flag == 0):
            obj.commit('auto-merged successfull')
        print "Pull Successfull\n"
        if self.stop:
            reactor.stop()
 def gotCommitsContent(self,cont,commits,mycommits):
      obj=FileController(self.directory)
      #print ">>>",self.directory,"<<<"
      obj.uncompressAndWrite(cont)
      common_commit=[x for x in commits if x in set(mycommits)]
      #print getLastCommit(common_commit),"\n"
      #print (parent_commit.split()[1])
      parent_file_list=obj.getFileList(getLastCommit(common_commit))
      my_file_list=obj.getFileList(getLastCommit(mycommits))
      #print my_file_list,"\n"
      other_file_list=obj.getFileList(getLastCommit(commits))
      #print other_file_list,"\n"
      flag=0
      for elem in other_file_list:
              if(elem[0] in [x[0] for x in my_file_list]):
                      dicts=merge3.devilMerge(obj.getFile(getLastCommit(common_commit),elem[0]),obj.getFile(getLastCommit(mycommits),elem[0]),obj.getFile(getLastCommit(commits),elem[0]))
                      #print dicts
                      #reactor.stop()
                      #print str(dicts)
                      #print "opening file ",elem[0]
                      #print os.getcwd()
                      #print elem[0]
                      try:
                              os.makedirs(os.path.dirname(elem[0]))
                      except:
                              pass
                      files=open(elem[0],'w')
                      files.write(dicts['md_content'])
                      files.close()
                      #obj.add(elem[0])
                      if(dicts['conflict']==1):
                              print("Merged with conflicts in "+elem[0]+" not commiting.Please commit after manually changing")
                              flag=1
                      else:
                                      print("Merged "+elem[0]+" successfully\n")
              else:
                      #print "Writing to elem[0]"
                      try:
                              os.makedirs(os.path.dirname(elem[0]))
                      except:
                              pass
                      files=open(elem[0],'w')
                      content=obj.getFiler(getLastCommit(commits),elem[0])
                      files.write(content)
                      files.close()
                      #print elem[0]
                      obj.add(elem[0])
                      
      if(flag==0):
              obj.commit('auto-merged successfull')
      print "Pull Successfull\n"
      if self.stop:
          reactor.stop()
Esempio n. 4
0
 def merge(self, directory):
     commits = getCommits(directory)
     #print(commits)
     mycommits = self.getAllCommits()
     commits_to_fetch = set(commits).difference(set(mycommits))
     fp = open(self.statusfile, 'a')
     for k in commits_to_fetch:
         fp.write(k)
     fp.close()
     c_to_fetch = [i.split()[1] for i in commits_to_fetch]
     cont = getCommitsContent(directory, c_to_fetch)
     self.uncompressAndWrite(cont)
     common_commit = [x for x in commits if x in set(mycommits)]
     #print (parent_commit.split()[1])
     parent_file_list = self.getFileList(getLastCommit(common_commit))
     my_file_list = self.getFileList(getLastCommit(mycommits))
     other_file_list = self.getFileList(getLastCommit(commits))
     flag = 0
     for elem in my_file_list:
         for temp in other_file_list:
             if (elem == temp):
                 dicts = merge3.devilMerge(
                     self.getFile(getLastCommit(common_commit), elem[0]),
                     self.getFile(getLastCommit(mycommits), elem[0]),
                     self.getFile(getLastCommit(commits), elem[0]))
                 files = open(elem[0], 'w')
                 files.write(dicts['md_content'])
                 files.close()
                 if (dicts['conflict'] == 0 and dicts['merged'] != 0):
                     print("Merged " + elem[0] + "\n")
                 else:
                     print(
                         "Merged with conflicts in " + elem[0] +
                         " not commiting.Please commit after manually changing"
                     )
                     flag = 1
     if (flag == 0):
         self.commit('auto-merged successfull')