infinitepush: add background backup

Summary:
`hg backup --background` will be used as a `txnclose` hook to backup all of the
local commits to infinitepush.

Test Plan: Run `test-infinitepush-*`

Reviewers: rmcelroy, mitrandir, durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4175953

Tasks: 12479677

Signature: t1:4175953:1479145307:e698903b519361b376f6e182db7c49869c992617
This commit is contained in:
Stanislau Hlebik 2016-11-21 00:53:37 -08:00
parent 2a0e8205d4
commit 0a536f70fd
3 changed files with 22 additions and 2 deletions

View File

@ -60,6 +60,7 @@ import resource
import tempfile
from collections import defaultdict
from hgext3rd.extutil import runshellcommand
from mercurial import (
bundle2,
changegroup,
@ -621,13 +622,16 @@ def _push(orig, ui, repo, dest=None, *args, **opts):
exchange._localphasemove = oldphasemove
return result
@command('debugbackup')
def backup(ui, repo, dest=None):
@command('debugbackup', [('', 'background', None, 'run backup in background')])
def backup(ui, repo, dest=None, **opts):
"""
Saves new non-extinct commits since the last `hg backup` or from 0 revision
if this backup is the first.
"""
if opts.get('background'):
runshellcommand('hg backup', os.environ)
return 0
backuptipfile = 'infinitepushbackuptip'
backuptip = repo.svfs.tryread(backuptipfile)
try:

View File

@ -181,6 +181,7 @@ if not components:
dependencies = {
'absorb' : ['linelog'],
'fastannotate' : ['linelog'],
'infinitepush' : ['extutil'],
'remotefilelog' : ['cdatapack', 'extutil'],
'treemanifest' : ['ctreemanifest', 'cdatapack', 'fastmanifest'],
}

View File

@ -126,3 +126,18 @@ Create two more heads and backup them
remote: pushing 2 commits:
remote: f79c5017def3 newhead1
remote: 667453c0787e newhead2
Backup in background
$ cat .hg/store/infinitepushbackuptip
6 (no-eol)
$ mkcommit newcommit
$ tip=`hg log -r tip -T '{rev}'`
$ hg backup --background
>>> from time import sleep
>>> for i in range(5):
... sleep(0.1)
... backuptip = int(open('.hg/store/infinitepushbackuptip').read())
... if backuptip == 7:
... break
$ cat .hg/store/infinitepushbackuptip
7 (no-eol)