diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-03-23 14:58:21 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-03-23 15:01:10 +0000 |
commit | 2679a0f3403926abbba4e6a096c43297a2894b66 (patch) | |
tree | 92275c5a864e10dfc07bedf3bcfab15ca2475741 | |
parent | 2987b637a787cb12a345e4f33bd7c47dd5e54e64 (diff) | |
download | morph-2679a0f3403926abbba4e6a096c43297a2894b66.tar.gz |
morph: add make_patch command
-rwxr-xr-x | morph | 40 | ||||
-rw-r--r-- | without-test-modules | 1 |
2 files changed, 41 insertions, 0 deletions
@@ -356,6 +356,46 @@ class Morph(cliapp.Application): tempdir.remove() + def cmd_make_patch(self, args): + assert os.path.exists(self.settings['cachedir']) + + tempdir = morphlib.tempdir.Tempdir(self.settings['tempdir']) + morph_loader = MorphologyLoader(self.settings) + source_manager = morphlib.sourcemanager.SourceManager(self, update=False) + factory = morphlib.builder.Factory(tempdir) + builder = morphlib.builder.Builder(tempdir, self, morph_loader, source_manager, factory) + cachedir = morphlib.cachedir.CacheDir(self.settings['cachedir']) + ex = morphlib.execute.Execute('.', self.msg) + + outpath = args[0] + args = args[1:] + trip_iter = self._itertriplets(args) + paths = {} + for name in ('source', 'target'): + repo, ref, filename = trip_iter() + treeish = source_manager.get_treeish(repo, ref) + morph = lorph_loader.load(treeish, filename) + paths[name] = cachedir.name(builder.get_cache_id(morph)) + + try: + for name in paths.iterkeys(): + # mount the system images + partition = morphlib.fsutils.setup_device_mapping(ex, paths[name]) + mount_point = tempdir.join('mnt_' + name) + morphlib.fsutils.mount(ex, partition, mount_point) + + # make a diff + ex.runv(['tbdiff-create', outpath, paths['source'], paths['target']]) + + except BaseException: + # cleanup + for name in paths.iterkeys(): + mount_point = tempdir.join('mnt_' + name) + morphlib.fsutils.unmount(ex, mount_point) + morphlib.fsutils.undo_device_mapping(ex, paths[name]) + raise + + def msg(self, msg): '''Show a message to the user about what is going on.''' logging.debug(msg) diff --git a/without-test-modules b/without-test-modules index 114afa1a..75070b46 100644 --- a/without-test-modules +++ b/without-test-modules @@ -2,3 +2,4 @@ morphlib/__init__.py morphlib/builddependencygraph.py morphlib/tester.py morphlib/git.py +morphlib/fsutils.py |