Ejemplo n.º 1
0
    def merge_local_tracking_branches(self):
        logger.info('Merging local tracking branches')

        save_commit = Git.get_checked_out_commit(self.path)

        # checkout current branch in case repo has just been cloned and workdir
        # is empty
        if not Git.repo_is_clean(self.path):
            if save_commit in self.branches:
                self.branches[save_commit].cmd_checkout()

        stashed = False
        if not Git.repo_is_clean(self.path):
            if Git.stash(self.path):
                ioutils.inform('Repo is dirty, stashed at %s' % save_commit, minor=True)
                stashed = True

        for branch in self.branches.values():
            if branch.tracking:
                if not branch.cmd_merge(branch.tracking):
                    ioutils.complain('Merge failed at %s of %s/%s' %
                                     (branch.name, branch.tracking.remote.name,
                                      branch.tracking.name), minor=True)

        if Git.checkout(self.path, save_commit):
            if stashed and Git.stash(self.path, apply=True):
                ioutils.inform('Restored stash at %s' % save_commit, minor=True)
Ejemplo n.º 2
0
Archivo: git.py Proyecto: numerodix/re
    def cmd_fetch(self):
        ioutils.inform('Fetching %s' % self.path)

        if not os.path.exists(self.path):
            self.do_init_repo()

        success = True
        self.set_remotes_in_checkout()
        self.detect_branches(update_tracking=True)
        for remote in self.remotes.values():
            success = success and remote.cmd_fetch()
        self.detect_branches(only_remote=True)

        if not success:
            ioutils.complain('Failed fetching %s' % self.path)
        return success
Ejemplo n.º 3
0
    def cmd_fetch(self):
        ioutils.inform('Fetching %s' % self.path)

        if not os.path.exists(self.path):
            self.do_init_repo()

        success = True
        self.set_remotes_in_checkout()
        self.detect_branches(update_tracking=True)
        for remote in self.remotes.values():
            success = success and remote.cmd_fetch()
        self.detect_branches(only_remote=True)

        if not success:
            ioutils.complain('Failed fetching %s' % self.path)
        return success
Ejemplo n.º 4
0
    def merge_local_tracking_branches(self):
        logger.info('Merging local tracking branches')

        save_commit = Git.get_checked_out_commit(self.path)
        if save_commit is None:
            ioutils.complain('Failed to get last commit for %s' % self.path)
            return

        # checkout current branch in case repo has just been cloned and workdir
        # is empty
        if not Git.repo_is_clean(self.path):
            if save_commit in self.branches:
                self.branches[save_commit].cmd_checkout()

        # if the workdir is not clean we will stash it first
        stashed = False
        if not Git.repo_is_clean(self.path):
            if Git.stash(self.path):
                ioutils.inform('Repo is dirty, stashed at %s' % save_commit,
                               minor=True)
                stashed = True

        # merge all tracking branches
        for branch in self.branches.values():
            if branch.tracking:
                if not branch.cmd_merge(branch.tracking):
                    ioutils.complain('Merge failed at %s of %s/%s' %
                                     (branch.name, branch.tracking.remote.name,
                                      branch.tracking.name),
                                     minor=True)

        # check out the "current branch" again - so we end on the same branch
        # checked out as we had in the beginning
        if save_commit in self.branches:
            self.branches[save_commit].cmd_checkout()

        # apply the stash back onto the workdir (could create a conflict)
        if Git.checkout(self.path, save_commit):
            if stashed and Git.stash(self.path, apply=True):
                ioutils.inform('Restored stash at %s' % save_commit,
                               minor=True)
Ejemplo n.º 5
0
Archivo: git.py Proyecto: numerodix/re
    def merge_local_tracking_branches(self):
        logger.info('Merging local tracking branches')

        save_commit = Git.get_checked_out_commit(self.path)
        if save_commit is None:
            ioutils.complain('Failed to get last commit for %s' % self.path)
            return

        # checkout current branch in case repo has just been cloned and workdir
        # is empty
        if not Git.repo_is_clean(self.path):
            if save_commit in self.branches:
                self.branches[save_commit].cmd_checkout()

        # if the workdir is not clean we will stash it first
        stashed = False
        if not Git.repo_is_clean(self.path):
            if Git.stash(self.path):
                ioutils.inform('Repo is dirty, stashed at %s' % save_commit, minor=True)
                stashed = True

        # merge all tracking branches
        for branch in self.branches.values():
            if branch.tracking:
                if not branch.cmd_merge(branch.tracking):
                    ioutils.complain('Merge failed at %s of %s/%s' %
                                     (branch.name, branch.tracking.remote.name,
                                      branch.tracking.name), minor=True)

        # check out the "current branch" again - so we end on the same branch
        # checked out as we had in the beginning
        if save_commit in self.branches:
            self.branches[save_commit].cmd_checkout()

        # apply the stash back onto the workdir (could create a conflict)
        if Git.checkout(self.path, save_commit):
            if stashed and Git.stash(self.path, apply=True):
                ioutils.inform('Restored stash at %s' % save_commit, minor=True)
Ejemplo n.º 6
0
 def activate(self, paths):
     for path in paths:
         if path in self.repos:
             self.repos[path].is_active = True
         else:
             ioutils.complain("Skipping unknown repo: %s" % path)