diff --git a/hgext3rd/lfs/wrapper.py b/hgext3rd/lfs/wrapper.py --- a/hgext3rd/lfs/wrapper.py +++ b/hgext3rd/lfs/wrapper.py @@ -179,6 +179,16 @@ # if remotestore is a null store, upload is a no-op and can be skipped return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) +def uploadblobsfromrevs(repo, revs): + '''upload lfs blobs introduced by revs + + Note: also used by other extensions e. g. infinitepush. avoid renaming. + ''' + if _canskipupload(repo): + return + pointers = extractpointers(repo, revs) + uploadblobs(repo, pointers) + def prepush(pushop): """Prepush hook. @@ -186,18 +196,12 @@ deserialized into metadata so that we can block the push on their upload to the remote blobstore. """ - if _canskipupload(pushop.repo): - return - pointers = extractpointers(pushop.repo, pushop.outgoing.missing) - uploadblobs(pushop.repo, pointers) + return uploadblobsfromrevs(pushop.repo, pushop.outgoing.missing) def writenewbundle(orig, ui, repo, source, filename, bundletype, outgoing, *args, **kwargs): """upload LFS blobs added by outgoing revisions on 'hg bundle'""" - if _canskipupload(repo): - return - pointers = extractpointers(repo, outgoing.missing) - uploadblobs(repo, pointers) + uploadblobsfromrevs(repo, outgoing.missing) return orig(ui, repo, source, filename, bundletype, outgoing, *args, **kwargs) diff --git a/infinitepush/__init__.py b/infinitepush/__init__.py --- a/infinitepush/__init__.py +++ b/infinitepush/__init__.py @@ -286,6 +286,13 @@ wrapfunction(discovery, 'checkheads', _checkheads) + def infinitepushsupported(orig, repo): + versions = orig(repo) + versions.discard('01') + return versions + + wrapfunction(changegroup, 'supportedoutgoingversions', + infinitepushsupported) wireproto.wirepeer.listkeyspatterns = listkeyspatterns # Move infinitepush part before pushrebase part diff --git a/infinitepush/bundleparts.py b/infinitepush/bundleparts.py --- a/infinitepush/bundleparts.py +++ b/infinitepush/bundleparts.py @@ -11,6 +11,7 @@ bundle2, changegroup, error, + extensions, revsetlang, ) from mercurial.i18n import _ @@ -29,7 +30,8 @@ _validaterevset(repo, revsetlang.formatspec('%ln', outgoing.missing), bookmark) - cgversion = '02' + cgversion = changegroup.safeversion(repo) + _handlelfs(repo, outgoing.missing) cg = changegroup.getlocalchangegroupraw(repo, 'push', outgoing, version=cgversion) @@ -77,3 +79,16 @@ if len(heads) > 1: raise error.Abort( _('cannot push more than one head to a scratch branch')) + +def _handlelfs(repo, missing): + '''Special case if lfs is enabled + + If lfs is enabled then we need to call prepush hook + to make sure large files are uploaded to lfs + ''' + try: + lfsmod = extensions.find('lfs') + lfsmod.wrapper.uploadblobsfromrevs(repo, missing) + except KeyError: + # Ignore if lfs extension is not enabled + return diff --git a/tests/library-infinitepush.sh b/tests/library-infinitepush.sh --- a/tests/library-infinitepush.sh +++ b/tests/library-infinitepush.sh @@ -40,6 +40,8 @@ [infinitepush] branchpattern=re:scratch/.+ server=False +[experimental] +changegroup3=True [paths] default = ssh://user@dummy/server EOF @@ -47,6 +49,8 @@ setupsqlserverhgrc() { cat << EOF > .hg/hgrc +[experimental] +changegroup3=True [ui] ssh=python "$TESTDIR/dummyssh" [extensions] diff --git a/tests/test-infinitepush-lfs.t b/tests/test-infinitepush-lfs.t new file mode 100644 --- /dev/null +++ b/tests/test-infinitepush-lfs.t @@ -0,0 +1,63 @@ + +Setup common infinitepush + $ . "$TESTDIR/library.sh" + $ . "$TESTDIR/library-infinitepush.sh" + $ setupcommon + +Setup lfs + $ cat >> $HGRCPATH << EOF + > [experimental] + > changegroup3=True + > [extensions] + > lfs=$TESTDIR/../hgext3rd/lfs/ + > [lfs] + > threshold=10B + > url=file:$TESTTMP/dummy-remote/ + > EOF + +Setup server repo + $ hg init repo + $ cd repo + $ setupserver + $ echo 1 > 1 + $ hg add 1 + $ hg ci -m initial + +Setup client + $ cd .. + $ hg clone ssh://user@dummy/repo client -q + $ cd client + $ echo aaaaaaaaaaa > largefile + $ hg ci -Aqm commit + $ hg debugdata largefile 0 + version https://git-lfs.github.com/spec/v1 + oid sha256:ab483e1d855ad0ea27a68eeea02a04c1de6ccd2dc2c05e3a48c9a1ebb8af5f99 + size 12 + x-is-binary 0 + + $ hg push -r . --to scratch/lfscommit --create + pushing to ssh://user@dummy/repo + searching for changes + remote: pushing 1 commit: + remote: 0da81a72db1a commit + + $ scratchbookmarks + scratch/lfscommit 0da81a72db1a2d8256845e3808971f33e73d24c4 + + $ cd .. + +Setup another client + $ hg clone ssh://user@dummy/repo client2 -q + $ cd client2 + $ hg update scratch/lfscommit + 'scratch/lfscommit' does not exist locally - looking for it remotely... + pulling from ssh://user@dummy/repo + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + (run 'hg update' to get a working copy) + 'scratch/lfscommit' found remotely + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark scratch/lfscommit) diff --git a/tests/test-infinitepush-remotenames.t b/tests/test-infinitepush-remotenames.t --- a/tests/test-infinitepush-remotenames.t +++ b/tests/test-infinitepush-remotenames.t @@ -1,4 +1,5 @@ $ . $TESTDIR/require-ext.sh remotenames + $ . "$TESTDIR/library.sh" $ cat >> $HGRCPATH << EOF > [extensions] > infinitepush=$TESTDIR/../infinitepush