Example #1
0
    def run(self, args):
        '''
        Run the given command and arguments against the current working directory.
        '''
        
        executed = self.executeExtension(args[0], args[1:])

        # If no extension was found then we execute the command as if
        # it was naturally called.
        if not executed:
            commandWithArgs = args[:]
            commandWithArgs.insert(0, "vcs")

            if isGit():
                commandWithArgs[0] = "git"
                subprocess.call(commandWithArgs)
                executed = True
            
            if isMercurial():
                commandWithArgs[0] = "hg"
                subprocess.call(commandWithArgs)
                executed = True

            if isBazaar():
                commandWithArgs[0] = "bzr"
                subprocess.call(commandWithArgs)
                executed = True

        if not executed:
            print("No repository found")
            exit(3)
Example #2
0
def init(arguments):
    '''
    Initializes (or re-initializes) a repository.
    '''
    
    if "git" in arguments or isGit():
        execute(["git", "init"])

    if "hg" in arguments or isMercurial():
        execute(["hg", "init"])

    if "bzr" in arguments or isBazaar():
        execute(["bzr", "init"])
Example #3
0
def push(arguments):
    '''
    Push commits to target.
    '''
    
    if isGit():
        command = ["git", "push"]
        command.extend(arguments)
        execute(command)

    if isMercurial():
        command = ["hg", "push"]
        command.extend(arguments)
        execute(command)

    if isBazaar():
        command = ["bzr", "push"]
        command.extend(arguments)
        execute(command)
Example #4
0
def pull(arguments):
    '''
    Pull the latest changes.
    '''
    
    if isGit():
        command = ["git", "pull"]
        command.extend(arguments)
        execute(command)

    if isMercurial():
        command = ["hg", "pull", "-u"]
        command.extend(arguments)
        execute(command)

    if isBazaar():
        command = ["bzr", "update"]
        command.extend(arguments)
        execute(command)
Example #5
0
def merge(arguments):
    '''
    Merge incoming changes with the current branch.
    '''
    
    if isGit():
        command = ["git", "merge"]
        command.extend(arguments)
        execute(command)

    if isMercurial():
        command = ["hg", "merge"]
        command.extend(arguments)
        execute(command)

    if isBazaar():
        command = ["bzr", "merge"]
        command.extend(arguments)
        execute(command)
Example #6
0
def mv(arguments):
    '''
    Move file(s)
    '''
    
    if isGit():
        command = ["git", "mv"]
        command.extend(arguments)
        execute(command)

    if isMercurial():
        command = ["hg", "mv"]
        command.extend(arguments)
        execute(command)

    if isBazaar():
        command = ["bzr", "mv"]
        command.extend(arguments)
        execute(command)
Example #7
0
def rm(arguments):
    '''
    Remove file(s) from the pending changes.
    '''
    
    if isGit():
        command = ["git", "rm"]
        command.extend(arguments)
        execute(command)

    if isMercurial():
        command = ["hg", "rm"]
        command.extend(arguments)
        execute(command)

    if isBazaar():
        command = ["bzr", "rm"]
        command.extend(arguments)
        execute(command)
Example #8
0
def incoming(arguments):
    """
    Shows incoming commits.
    """

    if isGit():
        out, err = executeAndReturnResponse(["git", "remote"])
        if not err and out:
            executeAndReturnResponse(["git", "remote", "update", "-p"])
            execute(["git", "log", "..@{u}"])

    if isMercurial():
        out, err = executeAndReturnResponse(["hg", "paths"])
        if not err and out:
            execute(["hg", "incoming"])

    if isBazaar():
        out, err = executeAndReturnResponse(["bzr", "missing"])
        if not err and out:
            execute(["bzr", "missing"])
Example #9
0
def add(arguments):
    '''
    Add file(s) to the pending changes.
    '''
    
    if isGit():
        # If no additional arguments were passed assume
        # we want to add all pending changes.
        if len(arguments) == 0:
            arguments.append(".")

        command = ["git", "add"]
        command.extend(arguments)
        execute(command)

    if isMercurial():
        command = ["hg", "add"]
        command.extend(arguments)
        execute(command)

    if isBazaar():
        command = ["bzr", "add"]
        command.extend(arguments)
        execute(command)