Example #1
0
def gclone(ui, git_url, hg_repo_path=None):
    # determine new repo name
    if not hg_repo_path:
        hg_repo_path = hg.defaultdest(git_url)
        if hg_repo_path.endswith('.git'):
            hg_repo_path = hg_repo_path[:-4]
        hg_repo_path += '-hg'
    dest_repo = hg.repository(ui, hg_repo_path, create=True)

    # fetch the initial git data
    git = GitHandler(dest_repo, ui)
    git.remote_add('origin', git_url)
    git.fetch('origin')
    
    # checkout the tip
    node = git.remote_head('origin')
    hg.update(dest_repo, node)
Example #2
0
    def __init__(self, ui, path, create=True):
        dest = hg.defaultdest(path)

        if dest.endswith('.git'):
            dest = dest[:-4]

        # create the local hg repo on disk
        dest_repo = hg.repository(ui, dest, create=True)

        # fetch the initial git data
        git = GitHandler(dest_repo, ui)
        git.remote_add('origin', path)
        git.fetch('origin')

        # checkout the tip
        node = git.remote_head('origin')
        hg.update(dest_repo, node)

        # exit to stop normal `hg clone` flow
        raise SystemExit
Example #3
0
def gremote(ui, repo, *args):
    git = GitHandler(repo, ui)

    if len(args) == 0:
        git.remote_list()
    elif len(args) < 2:
        repo.ui.warn(_("must supply an action and a remote\n"))
    else:
        verb = args[0]
        nick = args[1]

        if verb == 'add':
            if len(args) == 3:
                git.remote_add(nick, args[2])
            else:
                repo.ui.warn(_("must supply a url to add as a remote\n"))
        elif verb == 'rm':
            git.remote_remove(nick)
        elif verb == 'show':
            git.remote_show(nick)
        else:
            repo.ui.warn(_("unrecognized command to gremote\n"))