示例#1
0
文件: mod.py 项目: epowers/arc
  def verify(self, old_revision, force_new_mod_path=None,
             android_source_list=None):
    if self._status is not None:
      return

    if not self._android_module_path:
      self._status = constants.RESULT_MOD_ANDROID_SUBMODULE_NOT_IDENTIFIED
      return

    # Verify the mod on disk validates against the copy of the old source file.
    with internal.old_file_content(
        old_revision, self._android_path,
        self._android_module_path) as tmp_android_path:
      if not internal.validate_android_mod(self._mod_path, tmp_android_path):
        logging.info('Detected error comparing %s to %s (%s at %s)',
                     self._mod_path, tmp_android_path, self._android_path,
                     old_revision)
        self._status = constants.RESULT_MOD_INCORRECT_FOR_OLD_VERSION
        return

    if self._status is not None:
      return

    self._find_new_mod_path(force_new_mod_path, android_source_list)

    # If the mod is moving, make sure there is not already a file in the new
    # location.
    if (self._new_mod_path != self._mod_path and
        os.path.exists(self._new_mod_path)):
      self._status = constants.RESULT_MOD_EXISTS_AT_NEW_LOCATION
      return

    self._verified = True
示例#2
0
文件: mod.py 项目: epowers/arc
  def rebase(self, old_revision, force_new_mod_path=None):
    if not self._verified:
      self.verify(old_revision, force_new_mod_path)

    if self._status is not None:
      return

    # Move the mod to the new location if different from the old location
    internal.move_mod_file(self._mod_path, self._new_mod_path)

    with internal.old_file_content(
        old_revision, self._android_path,
        self._android_module_path) as tmp_android_path:
      # Attempt an automatic three-way merge using the mod, the old source code
      # and the new source code.
      if not internal.merge3(
          self._new_mod_path, tmp_android_path, self._new_android_path):
        self._status = constants.RESULT_NO_CLEAN_MERGE
        return

    if not internal.validate_android_mod(
        self._new_mod_path, self._new_android_path):
      self._status = constants.RESULT_NO_CLEAN_MERGE
      return

    git.add_to_staging(self._new_mod_path, cwd=self._arc_git_root)
    self._status = constants.RESULT_OK
示例#3
0
    def rebase(self, old_revision, force_new_mod_path=None):
        if not self._verified:
            self.verify(old_revision, force_new_mod_path)

        if self._status is not None:
            return

        # Move the mod to the new location if different from the old location
        internal.move_mod_file(self._mod_path, self._new_mod_path)

        with internal.old_file_content(
                old_revision, self._android_path,
                self._android_module_path) as tmp_android_path:
            # Attempt an automatic three-way merge using the mod, the old source code
            # and the new source code.
            if not internal.merge3(self._new_mod_path, tmp_android_path,
                                   self._new_android_path):
                self._status = constants.RESULT_NO_CLEAN_MERGE
                return

        if not internal.validate_android_mod(self._new_mod_path,
                                             self._new_android_path):
            self._status = constants.RESULT_NO_CLEAN_MERGE
            return

        git.add_to_staging(self._new_mod_path, cwd=self._arc_git_root)
        self._status = constants.RESULT_OK
示例#4
0
    def verify(self,
               old_revision,
               force_new_mod_path=None,
               android_source_list=None):
        if self._status is not None:
            return

        if not self._android_module_path:
            self._status = constants.RESULT_MOD_ANDROID_SUBMODULE_NOT_IDENTIFIED
            return

        # Verify the mod on disk validates against the copy of the old source file.
        with internal.old_file_content(
                old_revision, self._android_path,
                self._android_module_path) as tmp_android_path:
            if not internal.validate_android_mod(self._mod_path,
                                                 tmp_android_path):
                logging.info('Detected error comparing %s to %s (%s at %s)',
                             self._mod_path, tmp_android_path,
                             self._android_path, old_revision)
                self._status = constants.RESULT_MOD_INCORRECT_FOR_OLD_VERSION
                return

        if self._status is not None:
            return

        self._find_new_mod_path(force_new_mod_path, android_source_list)

        # If the mod is moving, make sure there is not already a file in the new
        # location.
        if (self._new_mod_path != self._mod_path
                and os.path.exists(self._new_mod_path)):
            self._status = constants.RESULT_MOD_EXISTS_AT_NEW_LOCATION
            return

        self._verified = True
示例#5
0
文件: mod.py 项目: epowers/arc
 def is_rebased(self):
   return internal.validate_android_mod(self._mod_path, self._android_path)
示例#6
0
 def is_rebased(self):
     return internal.validate_android_mod(self._mod_path,
                                          self._android_path)