diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 55 |
1 files changed, 37 insertions, 18 deletions
@@ -36,7 +36,7 @@ except ImportError: | |||
36 | 36 | ||
37 | from color import Coloring | 37 | from color import Coloring |
38 | from git_command import GitCommand | 38 | from git_command import GitCommand |
39 | from git_config import GitConfig, IsId, GetSchemeFromUrl | 39 | from git_config import GitConfig, IsId, GetSchemeFromUrl, ID_RE |
40 | from error import DownloadError | 40 | from error import DownloadError |
41 | from error import GitError, HookError, ImportError, UploadError | 41 | from error import GitError, HookError, ImportError, UploadError |
42 | from error import ManifestInvalidRevisionError | 42 | from error import ManifestInvalidRevisionError |
@@ -900,7 +900,7 @@ class Project(object): | |||
900 | 900 | ||
901 | ## Sync ## | 901 | ## Sync ## |
902 | 902 | ||
903 | def Sync_NetworkHalf(self, quiet=False, is_new=None): | 903 | def Sync_NetworkHalf(self, quiet=False, is_new=None, current_branch_only=False): |
904 | """Perform only the network IO portion of the sync process. | 904 | """Perform only the network IO portion of the sync process. |
905 | Local working directory/branch state is not affected. | 905 | Local working directory/branch state is not affected. |
906 | """ | 906 | """ |
@@ -926,21 +926,10 @@ class Project(object): | |||
926 | if alt_dir is None and self._ApplyCloneBundle(initial=is_new, quiet=quiet): | 926 | if alt_dir is None and self._ApplyCloneBundle(initial=is_new, quiet=quiet): |
927 | is_new = False | 927 | is_new = False |
928 | 928 | ||
929 | if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir): | 929 | if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, |
930 | current_branch_only=current_branch_only): | ||
930 | return False | 931 | return False |
931 | 932 | ||
932 | #Check that the requested ref was found after fetch | ||
933 | # | ||
934 | try: | ||
935 | self.GetRevisionId() | ||
936 | except ManifestInvalidRevisionError: | ||
937 | # if the ref is a tag. We can try fetching | ||
938 | # the tag manually as a last resort | ||
939 | # | ||
940 | rev = self.revisionExpr | ||
941 | if rev.startswith(R_TAGS): | ||
942 | self._RemoteFetch(None, rev[len(R_TAGS):], quiet=quiet) | ||
943 | |||
944 | if self.worktree: | 933 | if self.worktree: |
945 | self._InitMRef() | 934 | self._InitMRef() |
946 | else: | 935 | else: |
@@ -1335,10 +1324,30 @@ class Project(object): | |||
1335 | 1324 | ||
1336 | ## Direct Git Commands ## | 1325 | ## Direct Git Commands ## |
1337 | 1326 | ||
1338 | def _RemoteFetch(self, name=None, tag=None, | 1327 | def _RemoteFetch(self, name=None, |
1328 | current_branch_only=False, | ||
1339 | initial=False, | 1329 | initial=False, |
1340 | quiet=False, | 1330 | quiet=False, |
1341 | alt_dir=None): | 1331 | alt_dir=None): |
1332 | |||
1333 | is_sha1 = False | ||
1334 | tag_name = None | ||
1335 | |||
1336 | if current_branch_only: | ||
1337 | if ID_RE.match(self.revisionExpr) is not None: | ||
1338 | is_sha1 = True | ||
1339 | elif self.revisionExpr.startswith(R_TAGS): | ||
1340 | # this is a tag and its sha1 value should never change | ||
1341 | tag_name = self.revisionExpr[len(R_TAGS):] | ||
1342 | |||
1343 | if is_sha1 or tag_name is not None: | ||
1344 | try: | ||
1345 | self.GetRevisionId() | ||
1346 | return True | ||
1347 | except ManifestInvalidRevisionError: | ||
1348 | # There is no such persistent revision. We have to fetch it. | ||
1349 | pass | ||
1350 | |||
1342 | if not name: | 1351 | if not name: |
1343 | name = self.remote.name | 1352 | name = self.remote.name |
1344 | 1353 | ||
@@ -1401,9 +1410,19 @@ class Project(object): | |||
1401 | if not self.worktree: | 1410 | if not self.worktree: |
1402 | cmd.append('--update-head-ok') | 1411 | cmd.append('--update-head-ok') |
1403 | cmd.append(name) | 1412 | cmd.append(name) |
1404 | if tag is not None: | 1413 | |
1414 | if not current_branch_only or is_sha1: | ||
1415 | # Fetch whole repo | ||
1416 | cmd.append('--tags') | ||
1417 | cmd.append((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*')) | ||
1418 | elif tag_name is not None: | ||
1405 | cmd.append('tag') | 1419 | cmd.append('tag') |
1406 | cmd.append(tag) | 1420 | cmd.append(tag_name) |
1421 | else: | ||
1422 | branch = self.revisionExpr | ||
1423 | if branch.startswith(R_HEADS): | ||
1424 | branch = branch[len(R_HEADS):] | ||
1425 | cmd.append((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch)) | ||
1407 | 1426 | ||
1408 | ok = False | 1427 | ok = False |
1409 | for i in range(2): | 1428 | for i in range(2): |