Beispiel #1
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])
        status, dummy = popen('git svn dcommit', True, True)

        if not is_svn():
            print "This only works on svn checkouts!"
            sys.exit(1)

        if status == 0:
            popen('svn up --force', True, True)
            print "Pushed local changes to svn."
        else:
            print "An error occurred, consult output above."
Beispiel #2
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])
        status, dummy = popen("git svn dcommit", True, True)

        if not is_svn():
            print "This only works on svn checkouts!"
            sys.exit(1)

        if status == 0:
            popen("svn up --force", True, True)
            print "Pushed local changes to svn."
        else:
            print "An error occurred, consult output above."
Beispiel #3
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])

        if not is_svn():
            print "This only works on svn checkouts!"
            sys.exit(1)

        stashed = False
        if local_changes():
            stashed = True
            print "Stashing uncommitted local changes."
            status, dummy = popen('git stash', False, False)
        status, dummy = popen('git svn rebase', False, False)
        for line in dummy:
            print line
        if stashed:
            status, dummy = popen('git stash pop', False, False)
Beispiel #4
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])

        if not is_svn():
            print "This only works on svn checkouts!"
            sys.exit(1)

        stashed = False
        if local_changes():
            stashed = True
            print "Stashing uncommitted local changes."
            status, dummy = popen("git stash", False, False)
        status, dummy = popen("git svn rebase", False, False)
        for line in dummy:
            print line
        if stashed:
            status, dummy = popen("git stash pop", False, False)
Beispiel #5
0
    def __call__(self, **kwargs):

        if len(kwargs) == 0:
            if is_git():
                print "This seems to be a local git repository!"
                return

            if not is_svn():
                print "This only works on svn checkouts!"
                return

        self.cmd_push = CmdPush(self)
        self.cmd_fetch = CmdFetch(self)
        self.cmd_update = CmdUpdate(self)
        self.cmd_gitify = CmdGitify(self)
        self.cmd_help = CmdHelp(self)

        self.commands = dict(
            help=self.cmd_help,
            update=self.cmd_update,
            up=self.cmd_update,
            h=self.cmd_help,
            fetch = self.cmd_fetch,
            push = self.cmd_push,
            gitify = self.cmd_gitify,
        )

        # allow sys.argv to be overridden (used for testing)
        if 'args' in kwargs:
            self.args = ['gitify'] + kwargs['args']
        else:
            self.args = sys.argv

        try:
            command = self.args[1]
        except IndexError:
            command = 'gitify'

        self.commands.get(command, self.unknown)()
Beispiel #6
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])

        if not is_svn():
            print "This only works on svn checkouts!"
            sys.exit(1)

        package_name = basename()
        svntype = svn_type()

        if svntype == 'tags':
            print "Can't work on tags!"
            sys.exit(1)
        elif svntype == 'unrecognized':
            print "Unrecognized svn structure!"
            sys.exit(1)

        if not exists(config.GIT_CACHE + package_name):
            print "No git repository found in %s." % config.GIT_CACHE
            print "Initiating cloning into cache."
            clone()
        else:
            # if we already have a cached copy, make sure it's up-to-date:
            print "Updating existing cache:"
            gitify(args=['fetch', package_name])

        # get the branch svn is on
        remote_branch = svn_branch()
        # the following is just convention:
        local_branch = "local/%s" % remote_branch

        cwd = os.getcwd()
        # perform all index updates in the cache to avoid conflicts
        os.chdir(config.GIT_CACHE + package_name)

        dummy, existing_branches = popen('git branch', False, False)
        existing_branches = [b.strip('* ') for b in existing_branches]
        if local_branch in existing_branches:
            popen('git checkout -f %s' % local_branch, False, False)
        else:
            popen('git checkout -f -b %s %s' % (local_branch, remote_branch),
                  False, False)

        os.chdir(cwd)
        if not exists('.git'):
            popen('cp -Rp %s%s/.git .' % (config.GIT_CACHE, package_name),
                  False, False)

        # if the working copy is on another branch, switch:
        if local_branch != git_branch():
            if local_branch in existing_branches:
                popen('git checkout -f %s' % local_branch)
            else:
                popen('git checkout -b %s' % local_branch)

        assert git_branch() == local_branch, (
            "Changing branches failed, is on %r but should be on %r" %
            (git_branch(), local_branch))
        print "Git branch '%s' is now following svn branch '%s':" % (
            local_branch, remote_branch)
        popen('svn status')
        popen('git status')