diff --git a/remotefilelog/__init__.py b/remotefilelog/__init__.py --- a/remotefilelog/__init__.py +++ b/remotefilelog/__init__.py @@ -748,7 +748,7 @@ 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 @@ 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) diff --git a/remotefilelog/repack.py b/remotefilelog/repack.py --- a/remotefilelog/repack.py +++ b/remotefilelog/repack.py @@ -28,6 +28,9 @@ 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 @@ 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. diff --git a/tests/test-remotefilelog-repack-fast.t b/tests/test-remotefilelog-repack-fast.t --- a/tests/test-remotefilelog-repack-fast.t +++ b/tests/test-remotefilelog-repack-fast.t @@ -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 diff --git a/tests/test-remotefilelog-repack.t b/tests/test-remotefilelog-repack.t --- a/tests/test-remotefilelog-repack.t +++ b/tests/test-remotefilelog-repack.t @@ -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