Esempio n. 1
0
    def setUp(self):
        self.powerline = mock.MagicMock()

        self.dirname = tempfile.mkdtemp()
        sh.cd(self.dirname)
        sh.hg("init", ".")

        self.segment = hg.Segment(self.powerline)
Esempio n. 2
0
    def setUp(self):
        self.powerline = mock.MagicMock()

        self.dirname = tempfile.mkdtemp()
        sh.cd(self.dirname)
        sh.hg("init", ".")

        self.segment = hg.Segment(self.powerline)
Esempio n. 3
0
    def setUp(self):
        self.powerline = mock.MagicMock()
        self.powerline.segment_conf.side_effect = dict_side_effect_fn({
            ("vcs", "show_symbol"):
            False,
        })

        self.dirname = tempfile.mkdtemp()
        sh.cd(self.dirname)
        sh.hg("init", ".")

        self.segment = hg.Segment(self.powerline, {})
Esempio n. 4
0
 def clone_locally(self, dst_dir):
     """clones the repo into dst_dir"""
     conf = self.configuration
     repo = conf.get('buildbot-configs', 'repo')
     cmd = ('clone', repo, dst_dir)
     log.debug('running sh {0}'.format(' '.join(cmd)))
     self.local_checkout_dir = dst_dir
     try:
         sh.hg('clone', repo, dst_dir)
     except sh.ErrorReturnCode as error:
         msg = 'clone failed'
         msg = '{0}: hg {1}'.format(msg, ' '.join(cmd))
         msg = '{0} - error: {1}'.format(msg, error)
         log.debug(msg)
         raise BuildbotConfigsError('clone failed')
Esempio n. 5
0
 def push(self):
     """pushes local changes to the remote repository"""
     self._update_hgrc()
     try:
         # logging what is about to be pushed
         cmd = ('out', '-p')
         for line in hg(cmd, _cwd=self.local_checkout_dir):
             log.debug(line.strip())
         # and now log the push command
         for line in hg('push', _cwd=self.local_checkout_dir):
             log.debug(line.strip())
     except ErrorReturnCode as error:
         msg = 'push failed: {0}'.format(error)
         log.debug(msg)
         raise RepositoryError(msg)
Esempio n. 6
0
def hg_push(url):
    """Push commits to repository, provided that we are already in the repo.
    """
    val = hg("push", "--insecure", url)
    if val.exit_code != 0:
        raise ValueError ("Commit failed with status ", val)
    else:
        return val
Esempio n. 7
0
def hg_push(url):
    """Push commits to repository, provided that we are already in the repo.
    """
    val = hg("push", "--insecure", url)
    if val.exit_code != 0:
        raise ValueError("Commit failed with status ", val)
    else:
        return val
Esempio n. 8
0
 def commit(self, commit_message):
     """commit local changes"""
     try:
         cmd = ('commit', '-m', commit_message)
         for line in hg(cmd, _cwd=self.local_checkout_dir):
             log.debug(line.strip())
     except ErrorReturnCode as error:
         msg = 'commit failed: {0}'.format(error)
         raise RepositoryError(msg)
Esempio n. 9
0
def clone_repo(*,
               branch: str,
               repo_url: str,
               apps_folder: Path,
               template_repo_url: str,
               app_path: Path,
               app_group: str,
               hg: bool,
               local: bool,
               verbose: int,
               ):

    app_name, app_user, _, _ = parse_url(repo_url, apps_folder=apps_folder, verbose=verbose,)
    rename_cloned_repo = False
    if template_repo_url:
        template_app_name, template_app_user, _, _ = parse_url(template_repo_url, apps_folder=apps_folder, verbose=verbose,)
        repo_to_clone_url = template_repo_url
        if template_app_name != app_name:
            rename_cloned_repo = True
    else:
        repo_to_clone_url = repo_url

    if hg:
        sh.hg('clone', repo_to_clone_url, str(app_path))
    else:
        sh.git.clone(repo_to_clone_url, str(app_path))

    if branch != "master":
        branch_cmd = "git checkout -b " + '"' + branch + '"'
        ic(branch_cmd)
        os.system(branch_cmd)

    if not rename_cloned_repo:  # when renaming a template repo, dont want to fork if its one of my repos
        git_fork_cmd = "hub fork"
        os.system(git_fork_cmd)
    else:
        rename_repo_at_app_path(app_path=app_path,
                                app_group=app_group,
                                local=local,
                                hg=hg,
                                old_name=template_app_name,
                                new_name=app_name,
                                verbose=verbose,
                                )
Esempio n. 10
0
def hgrepo(root):
    hglog = sh.hg('log', '-l', '1', template=HGLOG).split('\n', 5)
    branch = (os.environ.get('CIRCLE_BRANCH') or
              os.environ.get('TRAVIS_BRANCH', sh.hg('branch').strip()))
    remotes = [x.split(' = ') for x in sh.hg('paths')]
    return {
        'head': {
            'id': hglog[0],
            'author_name': hglog[1],
            'author_email': hglog[2],
            'committer_name': hglog[3],
            'committer_email': hglog[4],
            'message': hglog[5].strip(),
        },
        'branch': branch,
        'remotes': [{
            'name': remote[0], 'url': remote[1]
        } for remote in remotes]
    }
Esempio n. 11
0
def hgrepo(root):
    hglog = sh.hg('log', '-l', '1', template=HGLOG).split('\n', 5)
    branch = (os.environ.get('CIRCLE_BRANCH')
              or os.environ.get('TRAVIS_BRANCH',
                                sh.hg('branch').strip()))
    remotes = [x.split(' = ') for x in sh.hg('paths')]
    return {
        'head': {
            'id': hglog[0],
            'author_name': hglog[1],
            'author_email': hglog[2],
            'committer_name': hglog[3],
            'committer_email': hglog[4],
            'message': hglog[5].strip(),
        },
        'branch': branch,
        'remotes': [{
            'name': remote[0],
            'url': remote[1]
        } for remote in remotes]
    }
Esempio n. 12
0
 def tag(self, tag='default'):
     """tags a repository with tag, if tag is not provided,
        it will use tag_name function do determine the tag"""
     conf = self.configuration
     if tag == 'default':
         products = conf.get_list('common', 'staging_release')
         version = conf.get('common', 'version')
         tag = tag_name(version, products)
     try:
         cmd = ('tag', '-f', tag)
         for line in hg(cmd, _cwd=self.local_checkout_dir):
             log.debug(line.strip())
     except ErrorReturnCode as error:
         msg = 'tag failed: {0}'.format(error)
         log.debug(msg)
         raise RepositoryError(msg)
Esempio n. 13
0
 def clone_locally(self, dst_dir, branch='default', clone_from='user'):
     """clones the repo into dst_dir"""
     conf = self.configuration
     repo = conf.get(self.name, 'mozilla_repo')
     if clone_from != 'mozilla':
         repo = conf.get(self.name, 'user_repo')
     cmd = ('clone', repo, dst_dir)
     log.debug('running sh {0}'.format(' '.join(cmd)))
     self.local_checkout_dir = dst_dir
     hg_cmd = ('clone', '-b', branch, repo, dst_dir)
     try:
         for line in hg(hg_cmd, _iter=True):
             log.debug(line.strip())
     except ErrorReturnCode as error:
         msg = 'clone failed'
         msg = '{0}: hg {1}'.format(msg, ' '.join(cmd))
         msg = '{0} - error: {1}'.format(msg, error)
         log.debug(msg)
         raise RepositoryError('clone failed')
Esempio n. 14
0
def hg_clone(remote, local):
    val = hg("clone", "--insecure", remote, local)
    if val.exit_code != 0:
        raise ValueError ("Clone failed with status ", val)
    else:
        return val
Esempio n. 15
0
def hg_clone(remote, local):
    val = hg("clone", "--insecure", remote, local)
    if val.exit_code != 0:
        raise ValueError("Clone failed with status ", val)
    else:
        return val
Esempio n. 16
0
 def _checkout_new_branch(self, branch):
     sh.hg("branch", branch)
Esempio n. 17
0
 def _add_and_commit(self, filename):
     sh.touch(filename)
     sh.hg("add", filename)
     sh.hg("commit", "-m", "add file " + filename)
Esempio n. 18
0
 def _add_and_commit(self, filename):
     sh.touch(filename)
     sh.hg("add", filename)
     sh.hg("commit", "-m", "add file " + filename)
Esempio n. 19
0
    mj = MasterJson(config, 'master_config.json.ini')
    mj.write('')

    bc = BuildbotConfigs(config)
#    url = config.get('locales', 'url')
#    locales = locales.get_shipped_locales(url)
#    print locales
#    bc.delete_user_repo()
#    bc.create_repo()
    tmp_dir = '/tmp/bc-conf'
#    shutil.rmtree(tmp_dir, ignore_errors=True)
#    bc.clone_locally('/tmp/bc-conf')
    bc.local_checkout_dir = tmp_dir
    #bc.prepare_for_staging()

    sh.hg('revert', '--all', _cwd=tmp_dir)
    replace_me = list()
    username = config.get('common', 'username')
    bug = config.get('common', 'tracking_bug')
    for repo in config.options('repositories'):
        src_repo = config.get(repo, 'src_repo_name')
        dst_repo = config.get(repo, 'dst_repo_name')
        src_repo = "{0}".format(src_repo)
        dst_repo = "{0}".format(dst_repo)
        a = (src_repo, dst_repo)
        replace_me.append(a)
        #fx_repo = 'users/stage-ffxbld/{0}'.format(repo)
        #user_repo = 'users/{0}_mozilla.com/{1}-{2}'.format(username, repo, bug)
        #a = (fx_repo, user_repo)
        #replace_me.append(a)
Esempio n. 20
0
 def _checkout_new_branch(self, branch):
     sh.hg("branch", branch)