summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-12-13 14:23:33 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-12-13 15:37:54 +0000
commitbec9ecbbb7ab988488c77ea1fe995164ec0c073f (patch)
treed1cfa253711a26d99700d21943ee20e4d1e184f0 /morphlib/cachedrepo.py
parent351bfaf77e7a424053700f0d68a941e177215b59 (diff)
downloadmorph-bec9ecbbb7ab988488c77ea1fe995164ec0c073f.tar.gz
morph branch: Check if the ref already exists before anything else
This was done to ensure tests.branching/branch-fails-if-branch-exists always passes, but also seems like the right approach in general.
Diffstat (limited to 'morphlib/cachedrepo.py')
-rw-r--r--morphlib/cachedrepo.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py
index 312f580f..0a085bb2 100644
--- a/morphlib/cachedrepo.py
+++ b/morphlib/cachedrepo.py
@@ -104,6 +104,15 @@ class CachedRepo(object):
self.path = path
self.is_mirror = not url.startswith('file://')
+ def ref_exists(self, ref):
+ '''Returns True if the given ref exists in the repo'''
+
+ try:
+ self._rev_parse(ref)
+ except cliapp.AppException:
+ return False
+ return True
+
def resolve_ref(self, ref):
'''Attempts to resolve a ref into its SHA1 and tree SHA1.