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,17 @@ # if remotestore is a null store, upload is a no-op and can be skipped return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) +def _prepushhookimpl(repo, missing): + ''' Implementation of prepush hook + + Move implementation to the separate function so that infinitepush can call + it too + ''' + if _canskipupload(repo): + return + pointers = extractpointers(repo, missing) + uploadblobs(repo, pointers) + def prepush(pushop): """Prepush hook. @@ -186,10 +197,7 @@ 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 _prepushhookimpl(pushop.repo, pushop.outgoing.missing) def writenewbundle(orig, ui, repo, source, filename, bundletype, outgoing, *args, **kwargs): 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,11 @@ _validaterevset(repo, revsetlang.formatspec('%ln', outgoing.missing), bookmark) - cgversion = '02' + if '03' in changegroup.supportedoutgoingversions(repo): + cgversion = '03' + _handlelfs(repo, outgoing.missing) + else: + cgversion = '02' cg = changegroup.getlocalchangegroupraw(repo, 'push', outgoing, version=cgversion) @@ -77,3 +82,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') + except KeyError: + # Ignore if lfs extension is not enabled + return + lfsmod.wrapper._prepushhookimpl(repo, missing) 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-backup.t b/tests/test-infinitepush-backup.t --- a/tests/test-infinitepush-backup.t +++ b/tests/test-infinitepush-backup.t @@ -56,8 +56,8 @@ remote: 7e6a6fd9c7c8 commit finished in \d+\.(\d+)? seconds (re) $ scratchnodes - 606a357e69adb2e36d559ae3237626e82a955c9d 9fa7f02468b18919035248ab21c8267674c0a3d6 - 7e6a6fd9c7c8c8c307ee14678f03d63af3a7b455 168423c30397d95ef5f44d883f0887f0f5be0936 + 606a357e69adb2e36d559ae3237626e82a955c9d bf656537c95d51e96ecea395a6ca90e46ef2598e + 7e6a6fd9c7c8c8c307ee14678f03d63af3a7b455 7e1f8a571275235810769f3ceae419abe1d716b1 $ scratchbookmarks infinitepush/backups/test/[0-9a-zA-Z.-]+\$TESTTMP/client/heads/7e6a6fd9c7c8c8c307ee14678f03d63af3a7b455 7e6a6fd9c7c8c8c307ee14678f03d63af3a7b455 (re) diff --git a/tests/test-infinitepush-bundlestore.t b/tests/test-infinitepush-bundlestore.t --- a/tests/test-infinitepush-bundlestore.t +++ b/tests/test-infinitepush-bundlestore.t @@ -1,7 +1,16 @@ +#testcases default changegroup3 Create an ondisk bundlestore in .hg/scratchbranches $ . "$TESTDIR/library.sh" $ . "$TESTDIR/library-infinitepush.sh" + +changegroup3 is enabled by default in library.sh +#if default + $ cat >> $HGRCPATH << EOF + > [experimental] + > changegroup3=False + > EOF +#endif $ cp $HGRCPATH $TESTTMP/defaulthgrc $ setupcommon $ hg init repo @@ -47,6 +56,20 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: initialcommit +#if changegroup3 + $ find ../repo/.hg/scratchbranches | sort + ../repo/.hg/scratchbranches + ../repo/.hg/scratchbranches/filebundlestore + ../repo/.hg/scratchbranches/filebundlestore/c9 + ../repo/.hg/scratchbranches/filebundlestore/c9/ca + ../repo/.hg/scratchbranches/filebundlestore/c9/ca/c9cab2f33fcc4408ff805b3afc3560ec44b95732 + ../repo/.hg/scratchbranches/index + ../repo/.hg/scratchbranches/index/bookmarkmap + ../repo/.hg/scratchbranches/index/bookmarkmap/scratch + ../repo/.hg/scratchbranches/index/bookmarkmap/scratch/mybranch + ../repo/.hg/scratchbranches/index/nodemap + ../repo/.hg/scratchbranches/index/nodemap/20759b6926ce827d5a8c73eb1fa9726d6f7defb2 +#else $ find ../repo/.hg/scratchbranches | sort ../repo/.hg/scratchbranches ../repo/.hg/scratchbranches/filebundlestore @@ -59,6 +82,7 @@ ../repo/.hg/scratchbranches/index/bookmarkmap/scratch/mybranch ../repo/.hg/scratchbranches/index/nodemap ../repo/.hg/scratchbranches/index/nodemap/20759b6926ce827d5a8c73eb1fa9726d6f7defb2 +#endif From another client we can get the scratchbranch if we ask for it explicitely @@ -127,9 +151,15 @@ | o initialcommit public +#if changegroup3 + $ scratchnodes + 1de1d7d92f8965260391d0513fe8a8d5973d3042 82a6684c052f3fc6250c050e2e265395dcd6bd8b + 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 82a6684c052f3fc6250c050e2e265395dcd6bd8b +#else $ scratchnodes 1de1d7d92f8965260391d0513fe8a8d5973d3042 bed63daed3beba97fff2e819a148cf415c217a85 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 bed63daed3beba97fff2e819a148cf415c217a85 +#endif $ scratchbookmarks scratch/mybranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 @@ -203,10 +233,17 @@ o initialcommit public +#if changegroup3 + $ scratchnodes + 1de1d7d92f8965260391d0513fe8a8d5973d3042 5114841c6273a30ed5a198127ae327937ae79673 + 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 5114841c6273a30ed5a198127ae327937ae79673 + 2b5d271c7e0d25d811359a314d413ebcc75c9524 5114841c6273a30ed5a198127ae327937ae79673 +#else $ scratchnodes 1de1d7d92f8965260391d0513fe8a8d5973d3042 66fa08ff107451320512817bed42b7f467a1bec3 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 66fa08ff107451320512817bed42b7f467a1bec3 2b5d271c7e0d25d811359a314d413ebcc75c9524 66fa08ff107451320512817bed42b7f467a1bec3 +#endif Test with pushrebase $ cp $TESTTMP/defaulthgrc $HGRCPATH @@ -233,11 +270,19 @@ | o initialcommit public +#if changegroup3 + $ scratchnodes + 1de1d7d92f8965260391d0513fe8a8d5973d3042 b3c0eb035f96e55a8e196fcf3f78151455291048 + 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 b3c0eb035f96e55a8e196fcf3f78151455291048 + 2b5d271c7e0d25d811359a314d413ebcc75c9524 b3c0eb035f96e55a8e196fcf3f78151455291048 + d8c4f54ab678fd67cb90bb3f272a2dc6513a59a7 b3c0eb035f96e55a8e196fcf3f78151455291048 +#else $ scratchnodes 1de1d7d92f8965260391d0513fe8a8d5973d3042 e3cb2ac50f9e1e6a5ead3217fc21236c84af4397 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 e3cb2ac50f9e1e6a5ead3217fc21236c84af4397 2b5d271c7e0d25d811359a314d413ebcc75c9524 e3cb2ac50f9e1e6a5ead3217fc21236c84af4397 d8c4f54ab678fd67cb90bb3f272a2dc6513a59a7 e3cb2ac50f9e1e6a5ead3217fc21236c84af4397 +#endif Change the order of pushrebase and infinitepush $ cp $TESTTMP/defaulthgrc $HGRCPATH @@ -265,12 +310,21 @@ | o initialcommit public +#if changegroup3 + $ scratchnodes + 1de1d7d92f8965260391d0513fe8a8d5973d3042 cb6b91e58b4ca41d1ef0ca93a249dac91e266e89 + 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 cb6b91e58b4ca41d1ef0ca93a249dac91e266e89 + 2b5d271c7e0d25d811359a314d413ebcc75c9524 cb6b91e58b4ca41d1ef0ca93a249dac91e266e89 + 6c10d49fe92751666c40263f96721b918170d3da cb6b91e58b4ca41d1ef0ca93a249dac91e266e89 + d8c4f54ab678fd67cb90bb3f272a2dc6513a59a7 cb6b91e58b4ca41d1ef0ca93a249dac91e266e89 +#else $ scratchnodes 1de1d7d92f8965260391d0513fe8a8d5973d3042 cd0586065eaf8b483698518f5fc32531e36fd8e0 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 cd0586065eaf8b483698518f5fc32531e36fd8e0 2b5d271c7e0d25d811359a314d413ebcc75c9524 cd0586065eaf8b483698518f5fc32531e36fd8e0 6c10d49fe92751666c40263f96721b918170d3da cd0586065eaf8b483698518f5fc32531e36fd8e0 d8c4f54ab678fd67cb90bb3f272a2dc6513a59a7 cd0586065eaf8b483698518f5fc32531e36fd8e0 +#endif Non-fastforward scratch bookmark push $ hg up 6c10d49fe927 @@ -508,6 +562,16 @@ remote: 2b5d271c7e0d scratchcommitnobook remote: d8c4f54ab678 scratchcommitwithpushrebase remote: 8611afacb870 newscratchhead +#if changegroup3 + $ scratchnodes + 1de1d7d92f8965260391d0513fe8a8d5973d3042 b96c724214ad747196dee6de4f836d5b04da6580 + 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 b96c724214ad747196dee6de4f836d5b04da6580 + 2b5d271c7e0d25d811359a314d413ebcc75c9524 b96c724214ad747196dee6de4f836d5b04da6580 + 6c10d49fe92751666c40263f96721b918170d3da cb6b91e58b4ca41d1ef0ca93a249dac91e266e89 + 8611afacb87078300a6d6b2f0c4b49fa506a8db9 b96c724214ad747196dee6de4f836d5b04da6580 + 8872775dd97a750e1533dc1fbbca665644b32547 4508f50a43adec5470c2583f5610262244fc5a35 + d8c4f54ab678fd67cb90bb3f272a2dc6513a59a7 b96c724214ad747196dee6de4f836d5b04da6580 +#else $ scratchnodes 1de1d7d92f8965260391d0513fe8a8d5973d3042 d1b4f12087a79b2b1d342e222686a829d09d399b 20759b6926ce827d5a8c73eb1fa9726d6f7defb2 d1b4f12087a79b2b1d342e222686a829d09d399b @@ -516,6 +580,7 @@ 8611afacb87078300a6d6b2f0c4b49fa506a8db9 d1b4f12087a79b2b1d342e222686a829d09d399b 8872775dd97a750e1533dc1fbbca665644b32547 ac7f12436d58e685616ffc1f619bcecce8829e25 d8c4f54ab678fd67cb90bb3f272a2dc6513a59a7 d1b4f12087a79b2b1d342e222686a829d09d399b +#endif Recreate the repo $ cd .. @@ -551,9 +616,15 @@ remote: pushing 2 commits: remote: bc22f9a30a82 multihead1 remote: ee4802bf6864 multihead2 +#if changegroup3 + $ scratchnodes + bc22f9a30a821118244deacbd732e394ed0b686c 8f293539ef7442027bce12eea99b6c4daae9a98d + ee4802bf6864326a6b3dcfff5a03abc2a0a69b8f 8f293539ef7442027bce12eea99b6c4daae9a98d +#else $ scratchnodes bc22f9a30a821118244deacbd732e394ed0b686c ab1bc557aa090a9e4145512c734b6e8a828393a5 ee4802bf6864326a6b3dcfff5a03abc2a0a69b8f ab1bc557aa090a9e4145512c734b6e8a828393a5 +#endif Create two new scratch bookmarks $ hg up 0 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-logging.t b/tests/test-infinitepush-logging.t --- a/tests/test-infinitepush-logging.t +++ b/tests/test-infinitepush-logging.t @@ -33,8 +33,8 @@ remote: infinitepush: b2x:infinitepush \(eventtype=start, hostname=.+, requestid=\d+, user=\w+\) (re) remote: pushing 1 commit: remote: 7e6a6fd9c7c8 commit - remote: infinitepush: bundlestore \(bundlesize=546, eventtype=start, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) - remote: infinitepush: bundlestore \(bundlesize=546, elapsedms=.+, eventtype=success, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) + remote: infinitepush: bundlestore \(bundlesize=556, eventtype=start, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) + remote: infinitepush: bundlestore \(bundlesize=556, elapsedms=.+, eventtype=success, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) remote: infinitepush: index \(eventtype=start, hostname=[-.0-9a-z]+, newheadscount=1, reponame=babar, requestid=\d+, user=\w+\) (re) remote: infinitepush: index \(elapsedms=.+, eventtype=success, hostname=[-.0-9a-z]+, newheadscount=1, reponame=babar, requestid=\d+, user=\w+\) (re) remote: infinitepush: b2x:infinitepush \(elapsedms=.+, eventtype=success, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) @@ -70,8 +70,8 @@ remote: pushing 2 commits: remote: 7e6a6fd9c7c8 commit remote: bba29d9d577a failpushcommit - remote: infinitepush: bundlestore \(bundlesize=1067, eventtype=start, hostname=.+, requestid=\d+, user=\w+\) (re) - remote: infinitepush: bundlestore \(bundlesize=1067, elapsedms=[-+0-9.e]+, errormsg=\[Errno 20\] Not a directory: '/dev/null/\d+', eventtype=failure, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) - remote: infinitepush: b2x:infinitepush \(elapsedms=[-+0-9.e]+, errormsg=\[Errno 20\] Not a directory: '/dev/null/\d+', eventtype=failure, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) - remote: abort: Not a directory: '/dev/null/\d+' (re) + remote: infinitepush: bundlestore \(bundlesize=1083, eventtype=start, hostname=.+, requestid=\d+, user=\w+\) (re) + remote: infinitepush: bundlestore \(bundlesize=1083, elapsedms=[-+0-9.e]+, errormsg=\[Errno 20\] Not a directory: '/dev/null/\w+', eventtype=failure, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) + remote: infinitepush: b2x:infinitepush \(elapsedms=[-+0-9.e]+, errormsg=\[Errno 20\] Not a directory: '/dev/null/\w+', eventtype=failure, hostname=[-.0-9a-z]+, reponame=babar, requestid=\d+, user=\w+\) (re) + remote: abort: Not a directory: '/dev/null/\w+' (re) [255] 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