Example #1
0
    def showDetail(item):
        if item == None:
            return

        if item.detail != None:
            if item.code == 0:
                print Paint.green(item.detail.replace("\t", ""))
            else:
                print Paint.red(item.detail.replace("\t", ""))

        if item.solution != None:
            print Paint.green(item.solution.replace("\t", ""))
Example #2
0
    def report():

        if len(Error.FAILED_LIST) == 0:
            print Paint.green(
                "\n  Ask for advice? Please type 'coron help NO_CONFLICT' \n")
        else:
            Error.createAllRejects()

            Error.printDivide()
            for failed in Error.FAILED_LIST:
                print failed

            Error.printDivide()
            Error.showStatistic()
Example #3
0
    def singleMerge(target, older, newer):
        """ Incorporate changes from older to newer into target
        """

        # Find out the actual target loosely
        target = ReviseExecutor.TARGET_FINDER.find(target, loosely=True)

        execute = "  MERGE  " + target

        if not os.path.exists(target) :
            Error.fileNotFound(target)
            return "%s %s" % (Paint.red("  [FAIL]"), execute)

        action = Format.REMOVE_LINE | Format.ACCESS_TO_NAME | Format.RESID_TO_NAME
        formatTarget = Format(AutoPatch.TARGET_ROOT, target).do(action)
        formatOlder  = Format(AutoPatch.OLDER_ROOT,  older).do(action)
        formatNewer  = Format(AutoPatch.NEWER_ROOT,  newer).do(action)

        DiffPatch(target, older, newer).run()

        # Would not change res name back
        action = Format.REMOVE_LINE | Format.ACCESS_TO_NAME
        formatTarget.undo(action)
        formatOlder.undo(action)
        formatNewer.undo(action)

        conflictNum = Rejector(target).getConflictNum()

        if conflictNum > 0 :
            Error.conflict(conflictNum, target)
            return "%s %s" % (Paint.yellow("  [CFLT]"), execute)
        else:
            return "%s %s" % (Paint.green("  [PASS]"), execute)
Example #4
0
    def singleReplaceOrAdd(target, source):
        """ Add a file from source to target.
            Replace the target if exist.
        """

        # Find out the actual target
        target = ReviseExecutor.TARGET_FINDER.find(target)

        if os.path.exists(target):
            execute = "REPLACE  " + target
        else:
            execute = "    ADD  " + target
            ReviseExecutor.createIfNotExist(os.path.dirname(target))

        if not os.path.exists(source):
            Error.fileNotFound(source)

            return "%s %s" % (Paint.red("  [FAIL]"), execute)

        # Only format access method and res id
        action = Format.ACCESS_TO_NAME | Format.RESID_TO_NAME
        formatSource = Format(AutoPatch.NEWER_ROOT, source).do(action)
        formatTarget = Format(AutoPatch.TARGET_ROOT, target).do(action)

        shutil.copy(source, target)

        # Would not change res name back
        action = Format.ACCESS_TO_NAME
        formatSource.undo(action)
        formatTarget.undo(action)

        return "%s %s" % (Paint.green("  [PASS]"), execute)
Example #5
0
    def handleLightFix(self):
        target = os.path.relpath(self.rejSmali.getPath(), utils.REJECT)
        print "  "
        print "  %s %s" % (Paint.bold("FIX CONFLICTS IN"), target)
        for mEntry in self.mBSLib.getEntryList(self.getRejectEntryList()):
            (canReplaceEntry,
             canNotReplaceEntry) = self.mTSLib.getCanReplaceEntry(
                 self.mBSLib, self.rejSmali.getClassName(), [mEntry], False)
            if utils.has(canReplaceEntry, mEntry):
                print "  %s %s" % (Paint.green("[PASS]"), mEntry.getName())
                utils.SLog.ok("\n>>>> Fix reject %s %s in %s: " %
                              (mEntry.getType(), mEntry.getName(),
                               self.rejSmali.getPath()))
                self.replaceEntryToBosp(mEntry)

            for entry in canReplaceEntry:
                if entry != mEntry:
                    self.replaceEntryToBosp(entry)
            if len(canNotReplaceEntry) > 0:
                self.mCanNotReplaceEntry.extend(canNotReplaceEntry)
                if utils.has(canNotReplaceEntry, mEntry):
                    print "  %s %s" % (Paint.red("[FAIL]"), mEntry.getName())

                    utils.SLog.fail("  %s" % target)
                    #utils.SLog.fail("  CONFLICTS: %s %s in %s" % (mEntry.getType(), mEntry.getName(), self.getRealTargetPath(self.mTSLib.getSmali(mEntry.getClassName()))))
                    #utils.SLog.fail("  Can not be replaced by bosp, because of the follows:")
                for entry in canNotReplaceEntry:
                    #utils.SLog.fail("     %s %s in %s" % (entry.getType(), entry.getName(), self.getRealTargetPath(self.mTSLib.getSmali(entry.getClassName()))))
                    pass
Example #6
0
def show(key, category=None):
    """ Show the help item
    :param key: name or code of the help item
    :param category: help category, like config, newproject
    """

    item = __get_item(key, category)
    if item is None:
        return

    if item.detail is not None:
        print "%s: %s" % (Paint.bold(item.name), item.detail.replace("\t", "").strip())

    if item.solution is not None:
        print Paint.green(item.solution.replace("\t", "").lstrip())

    print ""
Example #7
0
    def singleDelete(target):
        """ delete the target
        """

        # Find out the actual target
        target = ReviseExecutor.TARGET_FINDER.find(target)

        execute = " DELETE  " + target

        if os.path.exists(target):
            os.remove(target)
            return "%s %s" % (Paint.green("  [PASS]"), execute)

        return "%s %s" % (Paint.red("  [FAIL]"), execute)