mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
repack: exit 0 if a repack is in progress
Previously we raised a LockHeld exception if a repack was already in progress, which caused hg repack to exit non-zero. This changes it to exit 0 since a repack is in progress to accomplish the desired result. This is useful in automation that wants to run repack to maintain the repository but depends on exit codes to know if a command succeeded or not. Differential Revision: https://phab.mercurial-scm.org/D1668
This commit is contained in:
parent
9cc2ca09bb
commit
1d65b29746
@ -748,7 +748,7 @@ def gcclient(ui, cachepath):
|
||||
repackmod.incrementalrepack(repo)
|
||||
filesrepacked = True
|
||||
continue
|
||||
except IOError:
|
||||
except (IOError, repackmod.RepackAlreadyRunning):
|
||||
# If repack cannot be performed due to not enough disk space
|
||||
# continue doing garbage collection of loose files w/o repack
|
||||
pass
|
||||
@ -1038,7 +1038,12 @@ def repack(ui, repo, *pats, **opts):
|
||||
|
||||
options = {'packsonly': opts.get('packsonly')}
|
||||
|
||||
if opts.get('incremental'):
|
||||
repackmod.incrementalrepack(repo, options=options)
|
||||
else:
|
||||
repackmod.fullrepack(repo, options=options)
|
||||
try:
|
||||
if opts.get('incremental'):
|
||||
repackmod.incrementalrepack(repo, options=options)
|
||||
else:
|
||||
repackmod.fullrepack(repo, options=options)
|
||||
except repackmod.RepackAlreadyRunning as ex:
|
||||
# Don't propogate the exception if the repack is already in
|
||||
# progress, since we want the command to exit 0.
|
||||
repo.ui.warn('%s\n' % ex)
|
||||
|
@ -28,6 +28,9 @@ import time
|
||||
|
||||
osutil = policy.importmod(r'osutil')
|
||||
|
||||
class RepackAlreadyRunning(error.Abort):
|
||||
pass
|
||||
|
||||
def backgroundrepack(repo, incremental=True, packsonly=False):
|
||||
cmd = [util.hgexecutable(), '-R', repo.origroot, 'repack']
|
||||
msg = _("(running background repack)\n")
|
||||
@ -360,8 +363,8 @@ def _runrepack(repo, data, history, packpath, category, fullhistory=None,
|
||||
try:
|
||||
packer.run(dpack, hpack)
|
||||
except error.LockHeld:
|
||||
raise error.Abort(_("skipping repack - another repack is "
|
||||
"already running"))
|
||||
raise RepackAlreadyRunning(_("skipping repack - another repack "
|
||||
"is already running"))
|
||||
|
||||
def keepset(repo, keyfn, lastkeepkeys=None):
|
||||
"""Computes a keepset which is not garbage collected.
|
||||
|
@ -124,8 +124,7 @@
|
||||
$ hg repack --config "hooks.prerepack=sleep 3" &
|
||||
$ sleep 1
|
||||
$ hg repack
|
||||
abort: skipping repack - another repack is already running
|
||||
[255]
|
||||
skipping repack - another repack is already running
|
||||
$ hg debugwaitonrepack >/dev/null 2>&1
|
||||
|
||||
# Run repack in the background
|
||||
|
@ -132,8 +132,7 @@
|
||||
$ hg repack --config "hooks.prerepack=sleep 3" &
|
||||
$ sleep 1
|
||||
$ hg repack
|
||||
abort: skipping repack - another repack is already running
|
||||
[255]
|
||||
skipping repack - another repack is already running
|
||||
$ hg debugwaitonrepack >/dev/null 2>&1
|
||||
|
||||
# Run repack in the background
|
||||
|
Loading…
Reference in New Issue
Block a user