aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-08-17 11:15:06 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-08-17 11:16:20 -0400
commit991384155575d17f220879746020563649ebb425 (patch)
tree3ecbc0d2a75398aeec930d8f0c18fa0322c74ae0
parent6cae8161c18ec316b84e73743d9e63f0d532173b (diff)
downloadgrokmirror-991384155575d17f220879746020563649ebb425.tar.gz
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>
-rw-r--r--grokmirror.conf5
-rwxr-xr-xgrokmirror/pull.py13
-rw-r--r--man/grok-pull.13
-rw-r--r--man/grok-pull.1.rst1
4 files changed, 18 insertions, 4 deletions
diff --git a/grokmirror.conf b/grokmirror.conf
index 99496f2..968557d 100644
--- a/grokmirror.conf
+++ b/grokmirror.conf
@@ -117,7 +117,10 @@ projectslist_symlinks = no
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 @@ def fill_todo_from_manifest(config, active_actions, nomtime=False, forcepurge=Fa
# 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 @@ def parse_args():
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 @@ def parse_args():
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 @@ def grok_pull(cfgfile, verbose=False, nomtime=False, forcepurge=False, runonce=F
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 @@ def command():
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 @@ Run continuously (no effect if refresh is not set)
.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 @@ OPTIONS
-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