diff --git a/infinitepush/__init__.py b/infinitepush/__init__.py --- a/infinitepush/__init__.py +++ b/infinitepush/__init__.py @@ -63,9 +63,6 @@ # Name of the repository reponame = '' - # Client-side option - pushbackuplog = FILE - # Client-side option. Used by --list-remote option. List of remote scratch # patterns to list if no patterns are specified. defaultremotepatterns = ['*'] diff --git a/infinitepush/backupcommands.py b/infinitepush/backupcommands.py --- a/infinitepush/backupcommands.py +++ b/infinitepush/backupcommands.py @@ -7,22 +7,10 @@ # path to the directory where pushback logs should be stored logdir = path/to/dir - # max number of logs for one repo for one user - maxlognumber = 5 - - # There can be at most one backup process per repo. This config options - # determines how much time to wait on the lock. If timeout happens then - # backups process aborts. - waittimeout = 30 - # Backup at most maxheadstobackup heads, other heads are ignored. # Negative number means backup everything. maxheadstobackup = -1 - # With probability 1/N confirm if current backup is consistent. If this is - # zero or negative then no backup checks will be performed - backupcheckfreq = 50 - # Previously there was a bug in infinitepush backup and it made separate # backup for the same repo if pushbackup was called from different working # copies. This option cleans up the mess @@ -46,7 +34,6 @@ import errno import json import os -import random import re import socket import stat @@ -145,10 +132,7 @@ reporoot = repo.origroot reponame = os.path.basename(reporoot) - - maxlogfilenumber = ui.configint('infinitepushbackup', - 'maxlognumber', 5) - _removeoldlogfiles(userlogdir, reponame, maxlogfilenumber) + _removeoldlogfiles(userlogdir, reponame) logfile = _getlogfilename(logdir, username, reponame) except (OSError, IOError) as e: ui.debug('infinitepush backup log is disabled: %s\n' % e) @@ -168,24 +152,14 @@ return 0 try: - timeout = ui.configint('infinitepushbackup', 'waittimeout', 30) + # Wait at most 30 seconds, because that's the average backup time + timeout = 30 srcrepo = _getsrcrepo(repo) with lockmod.lock(srcrepo.vfs, _backuplockname, timeout=timeout): - backupcheckfreq = ui.configint('infinitepushbackup', - 'backupcheckfreq', 50) - if backupcheckfreq > 0 and random.randrange(backupcheckfreq) == 0: - bkpstate = _readlocalbackupstate(ui, srcrepo) - if not _dobackupcheck(bkpstate, ui, srcrepo, dest, **opts): - ui.log('infinitepushbackup', - 'failed infinitepush backup check', - infinitepushbackupcheck='failure') - return _dobackup(ui, repo, dest, **opts) except error.LockHeld as e: if e.errno == errno.ETIMEDOUT: ui.warn(_('timeout waiting on backup lock\n')) - ui.log('infinitepushbackup', 'timeout waiting on backup lock', - infinitepushbackuplock='timeout') return 0 else: raise @@ -765,7 +739,7 @@ currentday = time.strftime(_timeformat) return os.path.join(logdir, username, reponame + currentday) -def _removeoldlogfiles(userlogdir, reponame, maxlogfilenumber): +def _removeoldlogfiles(userlogdir, reponame): existinglogfiles = [] for entry in osutil.listdir(userlogdir): filename = entry[0] @@ -780,6 +754,8 @@ # _timeformat gives us a property that if we sort log file names in # descending order then newer files are going to be in the beginning existinglogfiles = sorted(existinglogfiles, reverse=True) + # Delete logs that are older than 5 days + maxlogfilenumber = 5 if len(existinglogfiles) > maxlogfilenumber: for filename in existinglogfiles[maxlogfilenumber:]: os.unlink(os.path.join(userlogdir, filename)) diff --git a/tests/test-infinitepush-pullbackup.t b/tests/test-infinitepush-pullbackup.t --- a/tests/test-infinitepush-pullbackup.t +++ b/tests/test-infinitepush-pullbackup.t @@ -21,7 +21,7 @@ $ hg book abook Actually do a backup, make sure that backup check doesn't fail for empty backup state - $ hg pushbackup --config infinitepushbackup.backupcheckfreq=1 + $ hg pushbackup starting backup .* (re) searching for changes remote: pushing 1 commit: @@ -249,21 +249,6 @@ checking \$TESTTMP/backupsource on .* (re) checking \$TESTTMP/backupsource2 on .* (re) -Check infinitepushbackup.backupcheckfreq config option - $ HGUSER=anotheruser hg pushbackup --config infinitepushbackup.backupcheckfreq=1 - unknown revision 'e0230a60975b38a9014f098fb973199efd25c46f' - starting backup .* (re) - nothing to backup - finished in \d+\.(\d+)? seconds (re) - $ HGUSER=anotheruser hg pushbackup --config infinitepushbackup.backupcheckfreq=0 - starting backup .* (re) - nothing to backup - finished in \d+\.(\d+)? seconds (re) - $ HGUSER=anotheruser hg pushbackup --config infinitepushbackup.backupcheckfreq=-100 - starting backup .* (re) - nothing to backup - finished in \d+\.(\d+)? seconds (re) - Test getavailablebackups command $ hg getavailablebackups user test has 4 available backups: