summaryrefslogtreecommitdiffstats
path: root/scripts/combo-layer
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2015-03-12 17:09:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-03-20 11:21:24 +0000
commite0d3cabc5a25c611531e66b80a4d372f76e2b828 (patch)
tree8f9a473be04978c81fd6417e2daf7cf9cd178f9e /scripts/combo-layer
parent14eac2a474f5fb347312b7257cc385d495a06c2d (diff)
downloadpoky-e0d3cabc5a25c611531e66b80a4d372f76e2b828.tar.gz
combo-layer: partial import for '--history init'
The new "since_revision" property can be used to cut off the imported history at some point. This is useful to keep the resulting repository smaller while still preserving enough history that "git annotate" reports the right author and commit for most lines. The initial, squashed import commit shows up with "unknown" as author in the "git annotate" output. It has the repository name as prefix in the subject line; importing that commit works best with a layer hook which does not add the repository name again when it is already present. Adding it here is useful for hooks which do not extend the subject line. (From OE-Core rev: 74f4c9e3bcdb3c4ca919623086e92a9379bd81ff) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-xscripts/combo-layer40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 6d24ce3ee1..cbff61803b 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -284,6 +284,46 @@ def action_init(conf, args):
284 runcmd("git branch -D %s" % refname, ldir) 284 runcmd("git branch -D %s" % refname, ldir)
285 # Make that the head revision. 285 # Make that the head revision.
286 runcmd("git checkout -b %s %s" % (name, initialrev)) 286 runcmd("git checkout -b %s %s" % (name, initialrev))
287 # Optional: cut the history by replacing the given
288 # start point(s) with commits providing the same
289 # content (aka tree), but with commit information that
290 # makes it clear that this is an artifically created
291 # commit and nothing the original authors had anything
292 # to do with.
293 since_rev = repo.get('since_revision', '')
294 if since_rev:
295 committer = runcmd('git var GIT_AUTHOR_IDENT').strip()
296 # Same time stamp, no name.
297 author = re.sub('.* (\d+ [+-]\d+)', r'unknown <unknown> \1', committer)
298 logger.info('author %s' % author)
299 for rev in since_rev.split():
300 # Resolve in component repo...
301 rev = runcmd('git log --oneline --no-abbrev-commit -n1 %s' % rev, ldir).split()[0]
302 # ... and then get the tree in current
303 # one. The commit should be in both repos with
304 # the same tree, but better check here.
305 tree = runcmd('git show -s --pretty=format:%%T %s' % rev).strip()
306 with tempfile.NamedTemporaryFile() as editor:
307 editor.write('''cat >$1 <<EOF
308tree %s
309author %s
310committer %s
311
312%s: squashed import of component
313
314This commit copies the entire set of files as found in
315%s %s
316
317For more information about previous commits, see the
318upstream repository.
319
320Commit created by combo-layer.
321EOF
322''' % (tree, author, committer, name, name, since_rev))
323 editor.flush()
324 os.environ['GIT_EDITOR'] = 'sh %s' % editor.name
325 runcmd('git replace --edit %s' % rev)
326
287 # Optional: rewrite history to change commit messages or to move files. 327 # Optional: rewrite history to change commit messages or to move files.
288 if 'hook' in repo or dest_dir and dest_dir != ".": 328 if 'hook' in repo or dest_dir and dest_dir != ".":
289 filter_branch = ['git', 'filter-branch', '--force'] 329 filter_branch = ['git', 'filter-branch', '--force']