summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo.py
Commit message (Collapse)AuthorAgeFilesLines
* Echo stderr of subcommands that do network IO when --verbose is usedSam Thursfield2014-10-291-1/+2
| | | | | | | | | | | | Morph can appear to hang in situations where it is actually waiting on a slow network operation. This change gives users a way to see the output of the subcommands that are doing the network IO (either 'wget', 'git clone' or 'git remote update'). The status information goes onto stderr, because that is where the subcommands write it. Morph tends to put its status output on stdout, but (a) some commands are machine-parsed, such as `serialise-artifact` and (b) it's tricky to get Git to put status output on stdout.
* Remove workaround for an old version of GitSam Thursfield2014-10-291-6/+2
|
* Prevent git-replace refs affecting git operationsRichard Maw2014-08-211-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We assumed that the sha1 of the tree of the commit of the ref we care about was sufficient to cache, but `git replace` means that you need to know the state of other branches too, since anything in refs/replace can completely change what the tree you check-out is. This behaviour can be disabled globally by setting GIT_NO_REPLACE_OBJECTS, so we're going to do that. If we need to integrate a project that uses git-replace to change the contents of their git trees then we could support that by: if any(refs/replace/*): potentially_replacable_objects = [ `git rev-parse HEAD`, `git rev-parse HEAD^{commit}`, `git rev-parse HEAD^{tree}`] potentially_replacable_objects.extend( `git ls-tree -r HEAD | awk '{print $3}'`) # NOTE: doesn't handle submodules, and you'd need to expand this # set whenever you process a replacement for object in refs/replace/*: if basename(object) not in potentially_replacable_objects: continue cache_key['replacements'][basename(object)] = `git rev-parse $object` If we were to support this would need to traverse the tree anyway, doing replacements, so we may as well use libgit to do the checkout anyway, and list which replacements were used. However, since the expected use-case of `git replace` is as a better way to do history grafting, we're unlikely to need it, as it would only have any effect if it replaced the commit we were using with a different one. Rubber-stamped-by: Daniel Silverstone
* cachedrepo: Remove unused load_morphology methodAdam Coldrick2014-08-141-9/+0
|
* Fix Morph failing to update some cached git reposSam Thursfield2014-07-071-1/+27
| | | | | | | | | | | | | | | | | | | | | | | I was getting the following error when running the 'do-release.py' script: ERROR:root:Command failed: morph --quiet --trove-host=git.baserock.org list-artifacts baserock:baserock/definitions sam/auto-release minimal-system-x86_32-generic ERROR: Ref d67a0e110187abd560a1de63fa172894a52839d5 is an invalid reference for repo git://git.baserock.org/delta/linux The commit that it wants did actually exist in git.baserock.org and the logs show that Morph hadn't done a `git remote update` to get the commit locally. This turned out to be because it'd had already looked up a different ref in linux.git. It hadn't needed to run 'git remote update', but it *had* added linux.git to a "don't need to update this repo again" list. Oops! I've moved the code in question to the cachedrepo module so that the repo object keeps that of whether it should be updated. The bug is now fixed. As a side effect this patch fixes the spurious 'Updating repo file:///...' messages, which were printed even though repos with file:/// URLs are never updated.
* Make CachedRepo.resolve_ref handle non-existent SHA1Lars Wirzenius2013-10-241-4/+9
| | | | | This changes how CachedRepo runs git to get the SHA1 information it needs, based on a suggestion by Richard Maw.
* morph branch: Check if the ref already exists before anything elseSam Thursfield2012-12-131-0/+9
| | | | | This was done to ensure tests.branching/branch-fails-if-branch-exists always passes, but also seems like the right approach in general.
* Always use `git rev-parse --verify` to resolve refsSam Thursfield2012-12-131-20/+9
| | | | | | | | | | | | | Previously some code used `git show-ref`, which is wrong -- given two refs named 'alpha/master' and 'master', `git show-ref master` will return both, sorted alphabetically. This can lead to build failures, etc. due to refs resolving to the wrong SHAs. We should also use `git rev-parse --verify` to verify SHA1s, which we previously did with `git rev-list`. Finally, `git rev-parse --verify` is more than twice as fast as `git show-ref`.
* Avoid caching repos that are on the local machine anywaySam Thursfield2012-11-121-1/+6
| | | | | Currently the message is still displayed "Updating xxx" but no update is actually done.
* Handle branch name kind changes more gracefully.Daniel Silverstone2012-10-081-1/+5
| | | | | | | | | | | | | | | | | | | Scenario: a repository contains a ref: refs/heads/foo and we have that in our repository cache. Action: upstream deletes that ref and then pushes a new refs at refs/heads/foo/bar. Action: we attempt to update the git and the update fails because git remote update cannot cope with the 'kind' change of refs/heads/foo from ref to directory. Remedy: If we get an exception from the remote update --prune we try the less efficient but more resilient combination of first pruning and then updating. Reviewed-By: Lars Wirzenius (over the shoulder) Reviewed-By: Richard Maw (over the shoulder)
* Use repository cache for git access other than current system branchSam Thursfield2012-10-031-0/+9
| | | | | | | | | | | | | | The origin/ refs in the system branch checkout repos may or may not be up to date, and may or may not have been tampered with by the user. Much better to use our central cache for everything other than changes to the system branch ref itself, where we should indeed be honouring the user's local changes. At a later date we could warn if the user modifies refs other than the system branch ref but does not push, as these changes will have no effect. NOTE: this commit breaks 'morph merge'. It is fixed in the next commit.
* Extract is_valid_sha1() to morphlib.gitSam Thursfield2012-10-031-9/+3
|
* Rework git caches to be bare mirrors of the repos.Daniel Silverstone2012-09-141-7/+43
| | | | | | | | This reworks the code for managing and using the git caches in morph to treat the caches as bare repositories which are mirrors of where we clone from. In addition we correctly prune the branches during updates, so that we don't end up accumulating pointless branches over and over. This is even more important with branch-and-merge generating temporary build refs for things.
* Give more useful errors when cloning from local cache failsSam Thursfield2012-09-131-8/+19
|
* Resolve tree SHA1 along with commit SHA1 when resolving refsJannis Pohlmann2012-09-051-14/+20
| | | | Adjust all other parts and the tests to work with this.
* Support 'git ls-tree' in local and remote reposSam Thursfield2012-08-241-0/+22
|
* python scripts: pep8ize codebaseRichard Maw2012-08-011-20/+21
| | | | | | | | | This was done with the aid of the pep8 script, available by running `easy_install pep8`. It may be worth making this part of ./check, but that will require putting pep8 into the development tools stratum. This should be easy, given pep8 has no external dependencies.
* morph: remove dead code and replace Execute with app.runcmdRichard Maw2012-05-301-17/+20
|
* Fix CachedRepo exceptions to initialize correctlyLars Wirzenius2012-05-091-10/+12
|
* Make morph's _clone_to_directory use CachedRepo.checkoutLars Wirzenius2012-05-041-7/+2
| | | | | | | | | This requires changing CachedRepo.checkout to handle non-sha1 refs, which resulted in some further changes in tests and their expected outputs. Also, a fix to CachedRepo to use the cwd keyword argument instead of pwd.
* Relax CachedRepo.checkout requirement that ref is a sha1Lars Wirzenius2012-05-041-6/+2
|
* Add original_name member to CachedRepo. Use it for SourcePool lookups.Jannis Pohlmann2012-04-171-2/+3
| | | | | | This is done to avoid a nasty mix of SourcePool lookups using CachedRepo objects (e.g. for strata within a system) versus lookups using repo names (e.g for sources within a stratum).
* Various small fixes to make the new update-gits work again.Jannis Pohlmann2012-04-101-3/+3
|
* Add doc strings to the CachedRepo class.Jannis Pohlmann2012-04-091-2/+55
|
* Remove unnecessary unhexlify calls.Jannis Pohlmann2012-04-091-3/+0
|
* Get rid of nested try/except blocks.Jannis Pohlmann2012-04-091-17/+21
|
* Add CachedRepo class with tests.Jannis Pohlmann2012-04-091-0/+147