Commit e414541c authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Imported convert-pull-local script

We'll run flake8 on it only afterwards.
parent d82be8bc8eb0
......@@ -126,4 +126,44 @@
git tag | grep vx.y.z
## Conversion to Mercurial and push
### For the main repository
A full conversion would be too much: it could take hours.
Instead, we have a script that converts only the current stable branches that
we care for.
From the directory where this README sits, run:
Check also ` --help` for interesting options.
### For Omnibus
Its almost 10 times smaller than the main repository, but that could still
be a pain. Its stable branches have (almost) the same names as the main
repository, so it can be done this way:
./ --gitlab-repo omnibus-gitlab --heptapod-repo omnibus-heptapod
### For other components
These are small enough that converting everything is a good option.
Example for Shell:
cd heptapod-shell
hg pull ../gitlab-shell
[the present project]:
#!/usr/bin/env python3
import argparse
import os
import time
from subprocess import Popen, PIPE, check_call, check_output
def extract_stable_branch_version(brname):
return tuple(int(segment)
for segment in brname[:-len(STABLE_BRANCH_SUFFIX)].split('-'))
parser = argparse.ArgumentParser()
parser.add_argument("--heptapod-repo", default='heptapod-rails')
parser.add_argument("--gitlab-repo", default='gitlab-ce')
cl_args = parser.parse_args()
def is_branch_to_pull(branch_name):
if not branch_name.endswith(STABLE_BRANCH_SUFFIX):
return False
prefix = cl_args.branch_prefix
if prefix is not None:
return branch_name.startswith(prefix)
return True
heptapod_repo, gitlab_repo = cl_args.heptapod_repo, cl_args.gitlab_repo
git_branches = check_output(('git', '-C', gitlab_repo, 'branch')).decode().splitlines()
git_branches = [b.strip() for b in git_branches]
stable_branches = [(extract_stable_branch_version(br), br)
for br in git_branches if is_branch_to_pull(br)]
print("Sorted stable branches: %r" % [b[1] for b in stable_branches])
for version, branch in stable_branches:
print("Pulling Git branch %r -- checking conversion" % branch)
log = Popen(('hg', 'log', '-R', heptapod_repo,
'-r', "bookmark(%s)" % branch),
if log.poll() == 0:
print(" already converted, pull will just be an update")
print(" full branch conversion, sleeping first for 10s for "
"easy interruption")
check_call(('hg', 'pull', '-R', heptapod_repo,
'-r', branch, gitlab_repo))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment