summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2014-09-04 21:28:09 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-04-30 14:29:02 +0000
commitb155354034a7ac18d83ab28cc3756dc36591435f (patch)
treef273424f6b01482197113508d11a841f75818f57 /project.py
parent4ccad7554b958c701653c41a72442cccf301e71a (diff)
downloadgit-repo-b155354034a7ac18d83ab28cc3756dc36591435f.tar.gz
Add option on sync to avoid fetching from remotes for existing sha1
In 2fb6466f795eb30c1dfa598501f5b5d2981e6a5f an optimisation was added to avoid fetching from remotes if the project is fixed to a revision and the revision is already available locally. This causes problems for users who expect all objects to be fetched by default. Change the logic so that the optimized behaviour is only enabled if an option is explicitly given to repo sync. Change-Id: I3b2794ddd8e0071b1787e166463cd8347ca9e24f
Diffstat (limited to 'project.py')
-rw-r--r--project.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/project.py b/project.py
index 6217aec8..6112c404 100644
--- a/project.py
+++ b/project.py
@@ -529,7 +529,8 @@ class Project(object):
529 upstream=None, 529 upstream=None,
530 parent=None, 530 parent=None,
531 is_derived=False, 531 is_derived=False,
532 dest_branch=None): 532 dest_branch=None,
533 optimized_fetch=False):
533 """Init a Project object. 534 """Init a Project object.
534 535
535 Args: 536 Args:
@@ -551,6 +552,8 @@ class Project(object):
551 is_derived: False if the project was explicitly defined in the manifest; 552 is_derived: False if the project was explicitly defined in the manifest;
552 True if the project is a discovered submodule. 553 True if the project is a discovered submodule.
553 dest_branch: The branch to which to push changes for review by default. 554 dest_branch: The branch to which to push changes for review by default.
555 optimized_fetch: If True, when a project is set to a sha1 revision, only
556 fetch from the remote if the sha1 is not present locally.
554 """ 557 """
555 self.manifest = manifest 558 self.manifest = manifest
556 self.name = name 559 self.name = name
@@ -579,6 +582,7 @@ class Project(object):
579 self.upstream = upstream 582 self.upstream = upstream
580 self.parent = parent 583 self.parent = parent
581 self.is_derived = is_derived 584 self.is_derived = is_derived
585 self.optimized_fetch = optimized_fetch
582 self.subprojects = [] 586 self.subprojects = []
583 587
584 self.snapshots = {} 588 self.snapshots = {}
@@ -1060,7 +1064,8 @@ class Project(object):
1060 current_branch_only=False, 1064 current_branch_only=False,
1061 clone_bundle=True, 1065 clone_bundle=True,
1062 no_tags=False, 1066 no_tags=False,
1063 archive=False): 1067 archive=False,
1068 optimized_fetch=False):
1064 """Perform only the network IO portion of the sync process. 1069 """Perform only the network IO portion of the sync process.
1065 Local working directory/branch state is not affected. 1070 Local working directory/branch state is not affected.
1066 """ 1071 """
@@ -1129,8 +1134,9 @@ class Project(object):
1129 elif self.manifest.default.sync_c: 1134 elif self.manifest.default.sync_c:
1130 current_branch_only = True 1135 current_branch_only = True
1131 1136
1132 has_sha1 = ID_RE.match(self.revisionExpr) and self._CheckForSha1() 1137 need_to_fetch = not (optimized_fetch and \
1133 if (not has_sha1 #Need to fetch since we don't already have this revision 1138 (ID_RE.match(self.revisionExpr) and self._CheckForSha1()))
1139 if (need_to_fetch
1134 and not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, 1140 and not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
1135 current_branch_only=current_branch_only, 1141 current_branch_only=current_branch_only,
1136 no_tags=no_tags)): 1142 no_tags=no_tags)):