@unbare_repo
    def move(self, module_path, configuration=True, module=True):
        if module + configuration < 1:
            raise ValueError("You must specify to move at least the module or the configuration of the submodule")
        # END handle input

        module_checkout_path = self._to_relative_path(self.repo, module_path)

        # VERIFY DESTINATION
        if module_checkout_path == self.path:
            return self
        # END handle no change

        module_checkout_abspath = join_path_native(self.repo.working_tree_dir, module_checkout_path)
        if os.path.isfile(module_checkout_abspath):
            raise ValueError("Cannot move repository onto a file: %s" % module_checkout_abspath)
        # END handle target files

        index = self.repo.index
        tekey = index.entry_key(module_checkout_path, 0)
        # if the target item already exists, fail
        if configuration and tekey in index.entries:
            raise ValueError("Index entry for target path did already exist")
        # END handle index key already there

        # remove existing destination
        if module:
            if os.path.exists(module_checkout_abspath):
                if len(os.listdir(module_checkout_abspath)):
                    raise ValueError("Destination module directory was not empty")
                # END handle non-emptiness

                if os.path.islink(module_checkout_abspath):
                    os.remove(module_checkout_abspath)
                else:
                    os.rmdir(module_checkout_abspath)
                # END handle link
            else:
                # recreate parent directories
                # NOTE: renames() does that now
                pass
            # END handle existence
        # END handle module

        # move the module into place if possible
        cur_path = self.abspath
        renamed_module = False
        if module and os.path.exists(cur_path):
            os.renames(cur_path, module_checkout_abspath)
            renamed_module = True

            if os.path.isfile(os.path.join(module_checkout_abspath, '.git')):
                module_abspath = self._module_abspath(self.repo, self.path, self.name)
                self._write_git_file_and_module_config(module_checkout_abspath, module_abspath)
            # end handle git file rewrite
        # END move physical module

        # rename the index entry - have to manipulate the index directly as
        # git-mv cannot be used on submodules ... yeah
        previous_sm_path = self.path
        try:
            if configuration:
                try:
                    ekey = index.entry_key(self.path, 0)
                    entry = index.entries[ekey]
                    del(index.entries[ekey])
                    nentry = git.IndexEntry(entry[:3] + (module_checkout_path,) + entry[4:])
                    index.entries[tekey] = nentry
                except KeyError:
                    raise InvalidGitRepositoryError("Submodule's entry at %r did not exist" % (self.path))
                # END handle submodule doesn't exist

                # update configuration
                writer = self.config_writer(index=index)        # auto-write
                writer.set_value('path', module_checkout_path)
                self.path = module_checkout_path
                writer.release()
                del(writer)
            # END handle configuration flag
        except Exception:
            if renamed_module:
                os.renames(module_checkout_abspath, cur_path)
            # END undo module renaming
            raise
        # END handle undo rename

        # Auto-rename submodule if it's name was 'default', that is, the checkout directory
        if previous_sm_path == self.name:
            self.rename(module_checkout_path)
        # end

        return self
Add a new meter to the supplied DPID
dataset/ETHPy150Open gitpython-developers/GitPython/git/objects/submodule/base.py/Submodule.move--crossover with--dataset/ETHPy150Open dave-tucker/hp-sdn-client/hpsdnclient/of.py/OfMixin.add_meter