summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2015-05-01 07:51:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-05-01 07:51:52 +0000
commitace097c36ef2d27991cb8186ddd65ce365f28ee8 (patch)
tree3f2b98cff76755a0904ca224b5e618e902d82406
parentb4d43b9f664d6472b6c1e91c98f951037d00cea5 (diff)
parentb155354034a7ac18d83ab28cc3756dc36591435f (diff)
downloadgit-repo-ace097c36ef2d27991cb8186ddd65ce365f28ee8.tar.gz
Merge "Add option on sync to avoid fetching from remotes for existing sha1"
-rw-r--r--project.py14
-rw-r--r--subcmds/sync.py13
2 files changed, 21 insertions, 6 deletions
diff --git a/project.py b/project.py
index 1e525b38..4427575e 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)):
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 2bdab3a6..b4546c15 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -131,6 +131,10 @@ of a project from server.
131The -c/--current-branch option can be used to only fetch objects that 131The -c/--current-branch option can be used to only fetch objects that
132are on the branch specified by a project's revision. 132are on the branch specified by a project's revision.
133 133
134The --optimized-fetch option can be used to only fetch projects that
135are fixed to a sha1 revision if the sha1 revision does not already
136exist locally.
137
134SSH Connections 138SSH Connections
135--------------- 139---------------
136 140
@@ -206,6 +210,9 @@ later is required to fix a server side protocol bug.
206 p.add_option('--no-tags', 210 p.add_option('--no-tags',
207 dest='no_tags', action='store_true', 211 dest='no_tags', action='store_true',
208 help="don't fetch tags") 212 help="don't fetch tags")
213 p.add_option('--optimized-fetch',
214 dest='optimized_fetch', action='store_true',
215 help='only fetch projects fixed to sha1 if revision does not exist locally')
209 if show_smart: 216 if show_smart:
210 p.add_option('-s', '--smart-sync', 217 p.add_option('-s', '--smart-sync',
211 dest='smart_sync', action='store_true', 218 dest='smart_sync', action='store_true',
@@ -275,7 +282,8 @@ later is required to fix a server side protocol bug.
275 quiet=opt.quiet, 282 quiet=opt.quiet,
276 current_branch_only=opt.current_branch_only, 283 current_branch_only=opt.current_branch_only,
277 clone_bundle=not opt.no_clone_bundle, 284 clone_bundle=not opt.no_clone_bundle,
278 no_tags=opt.no_tags, archive=self.manifest.IsArchive) 285 no_tags=opt.no_tags, archive=self.manifest.IsArchive,
286 optimized_fetch=opt.optimized_fetch)
279 self._fetch_times.Set(project, time.time() - start) 287 self._fetch_times.Set(project, time.time() - start)
280 288
281 # Lock around all the rest of the code, since printing, updating a set 289 # Lock around all the rest of the code, since printing, updating a set
@@ -615,7 +623,8 @@ later is required to fix a server side protocol bug.
615 if not opt.local_only: 623 if not opt.local_only:
616 mp.Sync_NetworkHalf(quiet=opt.quiet, 624 mp.Sync_NetworkHalf(quiet=opt.quiet,
617 current_branch_only=opt.current_branch_only, 625 current_branch_only=opt.current_branch_only,
618 no_tags=opt.no_tags) 626 no_tags=opt.no_tags,
627 optimized_fetch=opt.optimized_fetch)
619 628
620 if mp.HasChanges: 629 if mp.HasChanges:
621 syncbuf = SyncBuffer(mp.config) 630 syncbuf = SyncBuffer(mp.config)