summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/project.py b/project.py
index aa7a49d6..d07b5216 100644
--- a/project.py
+++ b/project.py
@@ -1078,6 +1078,13 @@ class Project(object):
1078 elif self.manifest.default.sync_c: 1078 elif self.manifest.default.sync_c:
1079 current_branch_only = True 1079 current_branch_only = True
1080 1080
1081 is_sha1 = False
1082 if ID_RE.match(self.revisionExpr) is not None:
1083 is_sha1 = True
1084 if is_sha1 and self._CheckForSha1():
1085 # Don't need to fetch since we already have this revision
1086 return True
1087
1081 if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, 1088 if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
1082 current_branch_only=current_branch_only, 1089 current_branch_only=current_branch_only,
1083 no_tags=no_tags): 1090 no_tags=no_tags):
@@ -1644,6 +1651,15 @@ class Project(object):
1644 1651
1645 1652
1646## Direct Git Commands ## 1653## Direct Git Commands ##
1654 def _CheckForSha1(self):
1655 try:
1656 # if revision (sha or tag) is not present then following function
1657 # throws an error.
1658 self.bare_git.rev_parse('--verify', '%s^0' % self.revisionExpr)
1659 return True
1660 except GitError:
1661 # There is no such persistent revision. We have to fetch it.
1662 return False
1647 1663
1648 def _FetchArchive(self, tarpath, cwd=None): 1664 def _FetchArchive(self, tarpath, cwd=None):
1649 cmd = ['archive', '-v', '-o', tarpath] 1665 cmd = ['archive', '-v', '-o', tarpath]
@@ -1668,16 +1684,6 @@ class Project(object):
1668 is_sha1 = False 1684 is_sha1 = False
1669 tag_name = None 1685 tag_name = None
1670 1686
1671 def CheckForSha1():
1672 try:
1673 # if revision (sha or tag) is not present then following function
1674 # throws an error.
1675 self.bare_git.rev_parse('--verify', '%s^0' % self.revisionExpr)
1676 return True
1677 except GitError:
1678 # There is no such persistent revision. We have to fetch it.
1679 return False
1680
1681 if self.clone_depth: 1687 if self.clone_depth:
1682 depth = self.clone_depth 1688 depth = self.clone_depth
1683 else: 1689 else:
@@ -1693,7 +1699,7 @@ class Project(object):
1693 tag_name = self.revisionExpr[len(R_TAGS):] 1699 tag_name = self.revisionExpr[len(R_TAGS):]
1694 1700
1695 if is_sha1 or tag_name is not None: 1701 if is_sha1 or tag_name is not None:
1696 if CheckForSha1(): 1702 if self._CheckForSha1():
1697 return True 1703 return True
1698 if is_sha1 and (not self.upstream or ID_RE.match(self.upstream)): 1704 if is_sha1 and (not self.upstream or ID_RE.match(self.upstream)):
1699 current_branch_only = False 1705 current_branch_only = False
@@ -1808,7 +1814,7 @@ class Project(object):
1808 # We just synced the upstream given branch; verify we 1814 # We just synced the upstream given branch; verify we
1809 # got what we wanted, else trigger a second run of all 1815 # got what we wanted, else trigger a second run of all
1810 # refs. 1816 # refs.
1811 if not CheckForSha1(): 1817 if not self._CheckForSha1():
1812 return self._RemoteFetch(name=name, current_branch_only=False, 1818 return self._RemoteFetch(name=name, current_branch_only=False,
1813 initial=False, quiet=quiet, alt_dir=alt_dir) 1819 initial=False, quiet=quiet, alt_dir=alt_dir)
1814 1820