Reinstate --purge option for grok-pull
With very large repo collections it makes sense to run purge operations
infrequently, to avoid having to walk the entire tree after each
manifest check.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
diff --git a/grokmirror.conf b/grokmirror.conf
index 99496f2..968557d 100644
--- a/grokmirror.conf
+++ b/grokmirror.conf
@@ -117,7 +117,10 @@
post_update_hook =
#
# Should we purge repositories that are not present in the remote
-# manifest? See also: purgeprotect.
+# manifest? If set to "no" this can be overridden via the -p flag to
+# grok-pull (useful if you have a very large collection of repos
+# and don't want to walk the entire tree on each manifest run).
+# See also: purgeprotect.
purge = yes
#
# This prevents catastrophic mirror purges when our upstream gives us a
diff --git a/grokmirror/pull.py b/grokmirror/pull.py
index fcd8667..6d90ea2 100755
--- a/grokmirror/pull.py
+++ b/grokmirror/pull.py
@@ -845,7 +845,7 @@
# Finally, clone ourselves.
actions.append((gitdir, 'init'))
- if config['pull'].get('purge') == 'yes':
+ if config['pull'].getboolean('purge', False):
to_purge = set()
found_repos = 0
for founddir in grokmirror.find_all_gitdirs(toplevel, exclude_objstore=True):
@@ -1188,6 +1188,9 @@
op.add_option('-n', '--no-mtime-check', dest='nomtime',
action='store_true', default=False,
help='Run without checking manifest mtime.')
+ op.add_option('-p', '--purge', dest='purge',
+ action='store_true', default=False,
+ help='Remove any git trees that are no longer in manifest.')
op.add_option('', '--force-purge', dest='forcepurge',
action='store_true', default=False,
help='Force purge despite significant repo deletions.')
@@ -1205,7 +1208,7 @@
return opts, args
-def grok_pull(cfgfile, verbose=False, nomtime=False, forcepurge=False, runonce=False):
+def grok_pull(cfgfile, verbose=False, nomtime=False, purge=False, forcepurge=False, runonce=False):
global logger
config = grokmirror.load_config_file(cfgfile)
@@ -1218,6 +1221,10 @@
else:
loglevel = logging.INFO
+ if purge:
+ # Override the pull.purge setting
+ config['pull']['purge'] = 'yes'
+
logger = grokmirror.init_logger('pull', logfile, loglevel, verbose)
return pull_mirror(config, nomtime, forcepurge, runonce)
@@ -1227,7 +1234,7 @@
opts, args = parse_args()
retval = grok_pull(
- opts.config, opts.verbose, opts.nomtime, opts.forcepurge, opts.runonce)
+ opts.config, opts.verbose, opts.nomtime, opts.purge, opts.forcepurge, opts.runonce)
sys.exit(retval)
diff --git a/man/grok-pull.1 b/man/grok-pull.1
index 2c91a68..792ed88 100644
--- a/man/grok-pull.1
+++ b/man/grok-pull.1
@@ -83,6 +83,9 @@
.BI \-c \ CONFIG\fP,\fB \ \-\-config\fB= CONFIG
Location of the configuration file
.TP
+.B \-p\fP,\fB \-\-purge
+Remove any git trees that are no longer in manifest.
+.TP
.B \-\-force\-purge
Force purge operation despite significant repo deletions
.UNINDENT
diff --git a/man/grok-pull.1.rst b/man/grok-pull.1.rst
index 6920bf5..f146b64 100644
--- a/man/grok-pull.1.rst
+++ b/man/grok-pull.1.rst
@@ -49,6 +49,7 @@
-o, --continuous Run continuously (no effect if refresh is not set)
-c CONFIG, --config=CONFIG
Location of the configuration file
+ -p, --purge Remove any git trees that are no longer in manifest.
--force-purge Force purge operation despite significant repo deletions
EXAMPLES