summaryrefslogtreecommitdiff
path: root/morphlib/gitindex.py
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2015-11-15 18:14:42 +0000
committerTiago Gomes <tiago.gomes@codethink.co.uk>2015-11-25 14:25:53 +0000
commit25617bd6277e2ec44c8d6acd742280a2708a6a2c (patch)
treeac4390dfe09a7678b546061c5664522b800dc4a8 /morphlib/gitindex.py
parent10a2f10450b6ff949d1387beef877f207fdbabdd (diff)
downloadmorph-25617bd6277e2ec44c8d6acd742280a2708a6a2c.tar.gz
Cease modifying the morphologies
With `morph edit` removed, there is no need to load all the morphologies, check whether a chunk was `morph edited`, change the current ref to the build ref and write back the morphologies to a temporary branch. That is a lot of work as code profiling demonstrated. With this patch applied, morph execution finishes around 10 seconds sooner on my machine. This is not a big achievement when a full build is performed where the wall clock time is dictated by the actual build commands, but it will provide a much quicker feedback when the build artifacts were already cached, or the semantic validation of morphologies fail. We add the option `--untracked-files` to _get_status() in the GitIndex class so that uncommitted morphologies on a uncommitted directory are considered. Previously this was being done by calling the following call in inject_build_refs(): self._root_index.add_files_from_index_info( self._hash_morphologies(self._root, morphs.morphologies)) This commit also removes some now unused code. Change-Id: I14215db5c06ab06045ce901131e4e341271a039d
Diffstat (limited to 'morphlib/gitindex.py')
-rw-r--r--morphlib/gitindex.py35
1 files changed, 2 insertions, 33 deletions
diff --git a/morphlib/gitindex.py b/morphlib/gitindex.py
index 00098fbf..c741718a 100644
--- a/morphlib/gitindex.py
+++ b/morphlib/gitindex.py
@@ -82,7 +82,8 @@ class GitIndex(object):
# a space, then the path.
# If our status code starts with R then it's a rename, hence
# has a second path, requiring us to pop an extra token.
- status = self._run_git('status', '-z', '--ignored')
+ status = self._run_git('status', '-z', '--ignored',
+ '--untracked-files')
tokens = collections.deque(status.split('\0'))
while True:
tok = tokens.popleft()
@@ -113,27 +114,6 @@ class GitIndex(object):
'''Modify the index to contain the contents of the treeish.'''
self._run_git('read-tree', treeish)
- def add_files_from_index_info(self, infos):
- '''Add files without interacting with the working tree.
-
- `infos` is an iterable of (file mode string, object sha1, path)
- There are no constraints on the size of the iterable
-
- '''
-
- # update-index may take NUL terminated input lines of the entries
- # to add so we generate a string for the input, rather than
- # having many command line arguments, since for a large amount
- # of entries, this can be too many arguments to process and the
- # exec will fail.
- # Generating the input as a string uses more memory than using
- # subprocess.Popen directly and using .communicate, but is much
- # less verbose.
- feed_stdin = '\0'.join('%o %s\t%s' % (mode, sha1, path)
- for mode, sha1, path in infos) + '\0'
- self._run_git('update-index', '--add', '-z', '--index-info',
- feed_stdin=feed_stdin)
-
def add_files_from_working_tree(self, paths):
'''Add existing files to the index.
@@ -142,17 +122,6 @@ class GitIndex(object):
add the contents of the files to git's object store,
and the index.
- This is similar to the following:
-
- gd = GitDirectory(...)
- idx = gd.get_index()
- for path in paths:
- fullpath = os.path.join(gd,dirname, path)
- with open(fullpath, 'r') as f:
- sha1 = gd.store_blob(f)
- idx.add_files_from_index_info([(os.stat(fullpath).st_mode,
- sha1, path)])
-
'''
if self._gd.is_bare():