mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Add option on sync to avoid fetching from remotes for existing sha1
In 2fb6466f79
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
This commit is contained in:
parent
4ccad7554b
commit
b155354034
14
project.py
14
project.py
@ -529,7 +529,8 @@ class Project(object):
|
|||||||
upstream=None,
|
upstream=None,
|
||||||
parent=None,
|
parent=None,
|
||||||
is_derived=False,
|
is_derived=False,
|
||||||
dest_branch=None):
|
dest_branch=None,
|
||||||
|
optimized_fetch=False):
|
||||||
"""Init a Project object.
|
"""Init a Project object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -551,6 +552,8 @@ class Project(object):
|
|||||||
is_derived: False if the project was explicitly defined in the manifest;
|
is_derived: False if the project was explicitly defined in the manifest;
|
||||||
True if the project is a discovered submodule.
|
True if the project is a discovered submodule.
|
||||||
dest_branch: The branch to which to push changes for review by default.
|
dest_branch: The branch to which to push changes for review by default.
|
||||||
|
optimized_fetch: If True, when a project is set to a sha1 revision, only
|
||||||
|
fetch from the remote if the sha1 is not present locally.
|
||||||
"""
|
"""
|
||||||
self.manifest = manifest
|
self.manifest = manifest
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -579,6 +582,7 @@ class Project(object):
|
|||||||
self.upstream = upstream
|
self.upstream = upstream
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.is_derived = is_derived
|
self.is_derived = is_derived
|
||||||
|
self.optimized_fetch = optimized_fetch
|
||||||
self.subprojects = []
|
self.subprojects = []
|
||||||
|
|
||||||
self.snapshots = {}
|
self.snapshots = {}
|
||||||
@ -1060,7 +1064,8 @@ class Project(object):
|
|||||||
current_branch_only=False,
|
current_branch_only=False,
|
||||||
clone_bundle=True,
|
clone_bundle=True,
|
||||||
no_tags=False,
|
no_tags=False,
|
||||||
archive=False):
|
archive=False,
|
||||||
|
optimized_fetch=False):
|
||||||
"""Perform only the network IO portion of the sync process.
|
"""Perform only the network IO portion of the sync process.
|
||||||
Local working directory/branch state is not affected.
|
Local working directory/branch state is not affected.
|
||||||
"""
|
"""
|
||||||
@ -1129,8 +1134,9 @@ class Project(object):
|
|||||||
elif self.manifest.default.sync_c:
|
elif self.manifest.default.sync_c:
|
||||||
current_branch_only = True
|
current_branch_only = True
|
||||||
|
|
||||||
has_sha1 = ID_RE.match(self.revisionExpr) and self._CheckForSha1()
|
need_to_fetch = not (optimized_fetch and \
|
||||||
if (not has_sha1 #Need to fetch since we don't already have this revision
|
(ID_RE.match(self.revisionExpr) and self._CheckForSha1()))
|
||||||
|
if (need_to_fetch
|
||||||
and not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
|
and not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
|
||||||
current_branch_only=current_branch_only,
|
current_branch_only=current_branch_only,
|
||||||
no_tags=no_tags)):
|
no_tags=no_tags)):
|
||||||
|
@ -131,6 +131,10 @@ of a project from server.
|
|||||||
The -c/--current-branch option can be used to only fetch objects that
|
The -c/--current-branch option can be used to only fetch objects that
|
||||||
are on the branch specified by a project's revision.
|
are on the branch specified by a project's revision.
|
||||||
|
|
||||||
|
The --optimized-fetch option can be used to only fetch projects that
|
||||||
|
are fixed to a sha1 revision if the sha1 revision does not already
|
||||||
|
exist locally.
|
||||||
|
|
||||||
SSH Connections
|
SSH Connections
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
@ -206,6 +210,9 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option('--no-tags',
|
p.add_option('--no-tags',
|
||||||
dest='no_tags', action='store_true',
|
dest='no_tags', action='store_true',
|
||||||
help="don't fetch tags")
|
help="don't fetch tags")
|
||||||
|
p.add_option('--optimized-fetch',
|
||||||
|
dest='optimized_fetch', action='store_true',
|
||||||
|
help='only fetch projects fixed to sha1 if revision does not exist locally')
|
||||||
if show_smart:
|
if show_smart:
|
||||||
p.add_option('-s', '--smart-sync',
|
p.add_option('-s', '--smart-sync',
|
||||||
dest='smart_sync', action='store_true',
|
dest='smart_sync', action='store_true',
|
||||||
@ -275,7 +282,8 @@ later is required to fix a server side protocol bug.
|
|||||||
quiet=opt.quiet,
|
quiet=opt.quiet,
|
||||||
current_branch_only=opt.current_branch_only,
|
current_branch_only=opt.current_branch_only,
|
||||||
clone_bundle=not opt.no_clone_bundle,
|
clone_bundle=not opt.no_clone_bundle,
|
||||||
no_tags=opt.no_tags, archive=self.manifest.IsArchive)
|
no_tags=opt.no_tags, archive=self.manifest.IsArchive,
|
||||||
|
optimized_fetch=opt.optimized_fetch)
|
||||||
self._fetch_times.Set(project, time.time() - start)
|
self._fetch_times.Set(project, time.time() - start)
|
||||||
|
|
||||||
# Lock around all the rest of the code, since printing, updating a set
|
# 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.
|
|||||||
if not opt.local_only:
|
if not opt.local_only:
|
||||||
mp.Sync_NetworkHalf(quiet=opt.quiet,
|
mp.Sync_NetworkHalf(quiet=opt.quiet,
|
||||||
current_branch_only=opt.current_branch_only,
|
current_branch_only=opt.current_branch_only,
|
||||||
no_tags=opt.no_tags)
|
no_tags=opt.no_tags,
|
||||||
|
optimized_fetch=opt.optimized_fetch)
|
||||||
|
|
||||||
if mp.HasChanges:
|
if mp.HasChanges:
|
||||||
syncbuf = SyncBuffer(mp.config)
|
syncbuf = SyncBuffer(mp.config)
|
||||||
|
Loading…
Reference in New Issue
Block a user