Skip to content

Commit

Permalink
Allow to import cinnabarclone bundles from grafted repos
Browse files Browse the repository at this point in the history
When generating e.g. a cinnabarclone bundle for a grafted gecko-dev,
one would rather exclude everything from gecko-dev so that the bundle
is smaller, since gecko-dev was presumably already cloned. In that case,
the bundle is thin, and index-pack needs the --fix-thin command line
option.
Replace refs also need to be handled properly.
  • Loading branch information
glandium committed May 10, 2019
1 parent fae825e commit b358499
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -30,7 +30,7 @@ Please run `git cinnabar fsck` with version 0.3.0 first.
Requirements:
-------------

- Git (any version should work)
- Git (any version should work ; cinnabarclone bundles require 1.4.4)
- Python 2.7
- Mercurial version 1.9 or newer

Expand Down
21 changes: 13 additions & 8 deletions cinnabar/githg.py
Expand Up @@ -931,7 +931,7 @@ def merge(self, git_repo_url, hg_repo_url, branch=None):
return False

if bundle:
proc = GitProcess('index-pack', '--stdin', '-v',
proc = GitProcess('index-pack', '--stdin', '-v', '--fix-thin',
stdin=subprocess.PIPE,
stdout=open(os.devnull, 'wb'))
shutil.copyfileobj(bundle, proc.stdin)
Expand Down Expand Up @@ -968,19 +968,24 @@ def merge(self, git_repo_url, hg_repo_url, branch=None):
for line in Git.ls_tree(commit.tree):
mode, typ, sha1, path = line
if sha1 in by_sha1:
needed.append('%s:refs/cinnabar/replace/%s' % (
by_sha1[sha1], path))
ref = 'refs/cinnabar/replace/%s' % path
if bundle:
Git.update_ref(ref, sha1)
else:
needed.append(':'.join((by_sha1[sha1], ref)))
else:
logging.error('Missing commit: %s', sha1)
errors = True
if errors:
return False

proc = GitProcess('fetch', '--no-tags', '--no-recurse-submodules',
git_repo_url, *needed, stdout=sys.stdout)
if proc.wait():
logging.error('Failed to fetch cinnabar metadata.')
return False
if not bundle:
proc = GitProcess(
'fetch', '--no-tags', '--no-recurse-submodules',
git_repo_url, *needed, stdout=sys.stdout)
if proc.wait():
logging.error('Failed to fetch cinnabar metadata.')
return False

Git.update_ref('refs/cinnabar/metadata', commit.sha1)
self._metadata_sha1 = commit.sha1
Expand Down

0 comments on commit b358499

Please sign in to comment.