Mercurial > hg
view tests/test-narrow-patterns.t @ 37147:a2566597acb5
lfs: add basic routing for the server side wire protocol processing
The recent hgweb refactoring yielded a clean point to wrap a function that could
handle this, so I moved the routing for this out of the core. While not an hg
wire protocol, this seems logically close enough. For now, these handlers do
nothing other than check permissions.
The protocol requires support for PUT requests, so that has been added to the
core, and funnels into the same handler as GET and POST. The permission
checking code was assuming that anything not checking 'pull' or None ops should
be using POST. But that breaks the upload check if it checks 'push'. So I
invented a new 'upload' permission, and used it to avoid the mandate to POST. A
function wrap point could be added, but security code should probably stay
grouped together. Given that anything not 'pull' or None was requiring POST,
the comment on hgweb.common.permhooks is probably wrong- there is no 'read'.
The rationale for the URIs is that the spec for the Batch API[1] defines the URL
as the LFS server url + '/objects/batch'. The default git URLs are:
Git remote: https://git-server.com/foo/bar
LFS server: https://git-server.com/foo/bar.git/info/lfs
Batch API: https://git-server.com/foo/bar.git/info/lfs/objects/batch
'.git/' seems like it's not something a user would normally track. If we adhere
to how git defines the URLs, then the hg-git extension should be able to talk to
a git based server without any additional work.
The URI for the transfer requests starts with '.hg/' to ensure that there are no
conflicts with tracked files. Since these are handed out by the Batch API, we
can change this at any point in the future. (Specifically, it might be a good
idea to use something under the proposed /api/ namespace.) In any case, no
files are stored at these locations in the repository directory.
I started a new module for this because it seems like a good idea to keep all of
the security sensitive server side code together. There's also an issue with
`hg verify` in that it will want to download *all* blobs in order to run.
Sadly, there's no way in the protocol to ask the server to verify the content of
a blob it may have. (The verify action is for storing files on a 3rd party
server, and then informing the LFS server when that completes.) So we may end
up implementing a custom transfer adapter that simply indicates if the blobs are
valid, and fall back to basic transfers for non-hg servers. In other words,
this code is likely to get bigger before this is made non-experimental.
[1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 17 Mar 2018 01:23:01 -0400 |
parents | 6767e7ce2c31 |
children | 7542e97c7867 |
line wrap: on
line source
$ . "$TESTDIR/narrow-library.sh" initialize nested directories to validate complex include/exclude patterns $ hg init master $ cd master $ cat >> .hg/hgrc <<EOF > [narrow] > serveellipses=True > EOF $ echo root > root $ hg add root $ hg commit -m 'add root' $ for d in dir1 dir2 dir1/dirA dir1/dirB dir2/dirA dir2/dirB > do > mkdir -p $d > echo $d/foo > $d/foo > hg add $d/foo > hg commit -m "add $d/foo" > echo $d/bar > $d/bar > hg add $d/bar > hg commit -m "add $d/bar" > done #if execbit $ chmod +x dir1/dirA/foo $ hg commit -m "make dir1/dirA/foo executable" #else $ hg import --bypass - <<EOF > # HG changeset patch > make dir1/dirA/foo executable > > diff --git a/dir1/dirA/foo b/dir1/dirA/foo > old mode 100644 > new mode 100755 > EOF applying patch from stdin $ hg update -qr tip #endif $ hg log -G -T '{rev} {node|short} {files}\n' @ 13 c87ca422d521 dir1/dirA/foo | o 12 951b8a83924e dir2/dirB/bar | o 11 01ae5a51b563 dir2/dirB/foo | o 10 5eababdf0ac5 dir2/dirA/bar | o 9 99d690663739 dir2/dirA/foo | o 8 8e80155d5445 dir1/dirB/bar | o 7 406760310428 dir1/dirB/foo | o 6 623466a5f475 dir1/dirA/bar | o 5 06ff3a5be997 dir1/dirA/foo | o 4 33227af02764 dir2/bar | o 3 5e1f9d8d7c69 dir2/foo | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da root $ cd .. clone a narrow portion of the master, such that we can widen it later $ hg clone --narrow ssh://user@dummy/master narrow \ > --include dir1 \ > --include dir2 \ > --exclude dir1/dirA \ > --exclude dir1/dirB \ > --exclude dir2/dirA \ > --exclude dir2/dirB requesting all changes adding changesets adding manifests adding file changes added 6 changesets with 4 changes to 4 files new changesets *:* (glob) updating to branch default 4 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow $ cat .hg/narrowspec [includes] path:dir1 path:dir2 [excludes] path:dir1/dirA path:dir1/dirB path:dir2/dirA path:dir2/dirB $ hg manifest -r tip dir1/bar dir1/dirA/bar dir1/dirA/foo dir1/dirB/bar dir1/dirB/foo dir1/foo dir2/bar dir2/dirA/bar dir2/dirA/foo dir2/dirB/bar dir2/dirB/foo dir2/foo root $ find * | sort dir1 dir1/bar dir1/foo dir2 dir2/bar dir2/foo $ hg log -G -T '{rev} {node|short}{if(ellipsis, "...")} {files}\n' @ 5 c87ca422d521... dir1/dirA/foo | o 4 33227af02764 dir2/bar | o 3 5e1f9d8d7c69 dir2/foo | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da... root widen the narrow checkout $ hg tracked --removeexclude dir1/dirA comparing with ssh://user@dummy/master searching for changes no changes found saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) adding changesets adding manifests adding file changes added 9 changesets with 6 changes to 6 files new changesets *:* (glob) $ cat .hg/narrowspec [includes] path:dir1 path:dir2 [excludes] path:dir1/dirB path:dir2/dirA path:dir2/dirB $ find * | sort dir1 dir1/bar dir1/dirA dir1/dirA/bar dir1/dirA/foo dir1/foo dir2 dir2/bar dir2/foo #if execbit $ test -x dir1/dirA/foo && echo executable executable $ test -x dir1/dirA/bar || echo not executable not executable #endif $ hg log -G -T '{rev} {node|short}{if(ellipsis, "...")} {files}\n' @ 8 c87ca422d521 dir1/dirA/foo | o 7 951b8a83924e... dir2/dirB/bar | o 6 623466a5f475 dir1/dirA/bar | o 5 06ff3a5be997 dir1/dirA/foo | o 4 33227af02764 dir2/bar | o 3 5e1f9d8d7c69 dir2/foo | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da... root widen narrow spec again, but exclude a file in previously included spec $ hg tracked --removeexclude dir2/dirB --addexclude dir1/dirA/bar comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths deleting data/dir1/dirA/bar.i no changes found saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) adding changesets adding manifests adding file changes added 11 changesets with 7 changes to 7 files new changesets *:* (glob) $ cat .hg/narrowspec [includes] path:dir1 path:dir2 [excludes] path:dir1/dirA/bar path:dir1/dirB path:dir2/dirA $ find * | sort dir1 dir1/bar dir1/dirA dir1/dirA/foo dir1/foo dir2 dir2/bar dir2/dirB dir2/dirB/bar dir2/dirB/foo dir2/foo $ hg log -G -T '{rev} {node|short}{if(ellipsis, "...")} {files}\n' @ 10 c87ca422d521 dir1/dirA/foo | o 9 951b8a83924e dir2/dirB/bar | o 8 01ae5a51b563 dir2/dirB/foo | o 7 5eababdf0ac5... dir2/dirA/bar | o 6 623466a5f475... dir1/dirA/bar | o 5 06ff3a5be997 dir1/dirA/foo | o 4 33227af02764 dir2/bar | o 3 5e1f9d8d7c69 dir2/foo | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da... root widen narrow spec yet again, excluding a directory in previous spec $ hg tracked --removeexclude dir2/dirA --addexclude dir1/dirA comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths deleting data/dir1/dirA/foo.i no changes found saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) adding changesets adding manifests adding file changes added 13 changesets with 8 changes to 8 files new changesets *:* (glob) $ cat .hg/narrowspec [includes] path:dir1 path:dir2 [excludes] path:dir1/dirA path:dir1/dirA/bar path:dir1/dirB $ find * | sort dir1 dir1/bar dir1/foo dir2 dir2/bar dir2/dirA dir2/dirA/bar dir2/dirA/foo dir2/dirB dir2/dirB/bar dir2/dirB/foo dir2/foo $ hg log -G -T '{rev} {node|short}{if(ellipsis, "...")} {files}\n' @ 12 c87ca422d521... dir1/dirA/foo | o 11 951b8a83924e dir2/dirB/bar | o 10 01ae5a51b563 dir2/dirB/foo | o 9 5eababdf0ac5 dir2/dirA/bar | o 8 99d690663739 dir2/dirA/foo | o 7 8e80155d5445... dir1/dirB/bar | o 6 623466a5f475... dir1/dirA/bar | o 5 06ff3a5be997... dir1/dirA/foo | o 4 33227af02764 dir2/bar | o 3 5e1f9d8d7c69 dir2/foo | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da... root include a directory that was previously explicitly excluded $ hg tracked --removeexclude dir1/dirA comparing with ssh://user@dummy/master searching for changes no changes found saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) adding changesets adding manifests adding file changes added 13 changesets with 9 changes to 9 files new changesets *:* (glob) $ cat .hg/narrowspec [includes] path:dir1 path:dir2 [excludes] path:dir1/dirA/bar path:dir1/dirB $ find * | sort dir1 dir1/bar dir1/dirA dir1/dirA/foo dir1/foo dir2 dir2/bar dir2/dirA dir2/dirA/bar dir2/dirA/foo dir2/dirB dir2/dirB/bar dir2/dirB/foo dir2/foo $ hg log -G -T '{rev} {node|short}{if(ellipsis, "...")} {files}\n' @ 12 c87ca422d521 dir1/dirA/foo | o 11 951b8a83924e dir2/dirB/bar | o 10 01ae5a51b563 dir2/dirB/foo | o 9 5eababdf0ac5 dir2/dirA/bar | o 8 99d690663739 dir2/dirA/foo | o 7 8e80155d5445... dir1/dirB/bar | o 6 623466a5f475... dir1/dirA/bar | o 5 06ff3a5be997 dir1/dirA/foo | o 4 33227af02764 dir2/bar | o 3 5e1f9d8d7c69 dir2/foo | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da... root $ cd .. clone a narrow portion of the master, such that we can widen it later $ hg clone --narrow ssh://user@dummy/master narrow2 --include dir1/dirA requesting all changes adding changesets adding manifests adding file changes added 5 changesets with 2 changes to 2 files new changesets *:* (glob) updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow2 $ find * | sort dir1 dir1/dirA dir1/dirA/bar dir1/dirA/foo $ hg tracked --addinclude dir1 comparing with ssh://user@dummy/master searching for changes no changes found saved backup bundle to $TESTTMP/narrow2/.hg/strip-backup/*-widen.hg (glob) adding changesets adding manifests adding file changes added 10 changesets with 6 changes to 6 files new changesets *:* (glob) $ find * | sort dir1 dir1/bar dir1/dirA dir1/dirA/bar dir1/dirA/foo dir1/dirB dir1/dirB/bar dir1/dirB/foo dir1/foo $ hg log -G -T '{rev} {node|short}{if(ellipsis, "...")} {files}\n' @ 9 c87ca422d521 dir1/dirA/foo | o 8 951b8a83924e... dir2/dirB/bar | o 7 8e80155d5445 dir1/dirB/bar | o 6 406760310428 dir1/dirB/foo | o 5 623466a5f475 dir1/dirA/bar | o 4 06ff3a5be997 dir1/dirA/foo | o 3 33227af02764... dir2/bar | o 2 594bc4b13d4a dir1/bar | o 1 47f480a08324 dir1/foo | o 0 2a4f0c3b67da... root