diff --git a/project.py b/project.py index 5d8f61e1..0808af46 100644 --- a/project.py +++ b/project.py @@ -1110,7 +1110,8 @@ class Project(object): clone_bundle=True, no_tags=False, archive=False, - optimized_fetch=False): + optimized_fetch=False, + prune=False): """Perform only the network IO portion of the sync process. Local working directory/branch state is not affected. """ @@ -1181,7 +1182,7 @@ class Project(object): if (need_to_fetch and not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, current_branch_only=current_branch_only, - no_tags=no_tags)): + no_tags=no_tags, prune=prune)): return False if self.worktree: @@ -1795,7 +1796,8 @@ class Project(object): initial=False, quiet=False, alt_dir=None, - no_tags=False): + no_tags=False, + prune=False): is_sha1 = False tag_name = None @@ -1908,6 +1910,9 @@ class Project(object): else: cmd.append('--tags') + if prune: + cmd.append('--prune') + spec = [] if not current_branch_only: # Fetch whole repo diff --git a/subcmds/sync.py b/subcmds/sync.py index 2a77065c..e865e564 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -151,6 +151,9 @@ 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. +The --prune option can be used to remove any refs that no longer +exist on the remote. + SSH Connections --------------- @@ -234,6 +237,8 @@ later is required to fix a server side protocol bug. p.add_option('--optimized-fetch', dest='optimized_fetch', action='store_true', help='only fetch projects fixed to sha1 if revision does not exist locally') + p.add_option('--prune', dest='prune', action='store_true', + help='delete refs that no longer exist on the remote') if show_smart: p.add_option('-s', '--smart-sync', dest='smart_sync', action='store_true', @@ -305,7 +310,8 @@ later is required to fix a server side protocol bug. force_sync=opt.force_sync, clone_bundle=not opt.no_clone_bundle, no_tags=opt.no_tags, archive=self.manifest.IsArchive, - optimized_fetch=opt.optimized_fetch) + optimized_fetch=opt.optimized_fetch, + prune=opt.prune) self._fetch_times.Set(project, time.time() - start) # Lock around all the rest of the code, since printing, updating a set