[PATCH 4 of 4] localrepo: add unbundle support
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Thu Apr 10 12:13:17 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1396659044 25200
# Fri Apr 04 17:50:44 2014 -0700
# Node ID a90a6df5fd2ddace645e11bd7f27bc34d9564a20
# Parent 28d1d63edc24d908d974f29605a6af44613c800b
localrepo: add unbundle support
Localrepo now support the unbundle method of pushing changegroup. We plan to use
the unbundle call for bundle2 so it is important that all peers supports it. The
`peer.unbundle` and `peer.addchangegroup` code path have small difference. So
some test output changes. None of those changes seems problematic.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -61,11 +61,11 @@ def unfilteredmethod(orig):
def wrapper(repo, *args, **kwargs):
return orig(repo.unfiltered(), *args, **kwargs)
return wrapper
moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
- 'bundle2'))
+ 'bundle2', 'unbundle'))
legacycaps = moderncaps.union(set(['changegroupsubset']))
class localpeer(peer.peerrepository):
'''peer for a local repo; reflects only the most recent API'''
@@ -110,10 +110,20 @@ class localpeer(peer.peerrepository):
common=common, bundlecaps=bundlecaps)
# TODO We might want to move the next two calls into legacypeer and add
# unbundle instead.
+ def unbundle(self, cg, heads, url):
+ """apply a bundle on a repo
+
+ This function handle the repo locking itself."""
+ try:
+ return exchange.unbundle(self._repo, cg, heads, 'push', url)
+ except exchange.PushRaced, exc:
+ raise error.ResponseError(_('push failed:'), exc.message)
+
+
def lock(self):
return self._repo.lock()
def addchangegroup(self, cg, source, url):
return changegroup.addchangegroup(self._repo, cg, source, url)
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -114,13 +114,13 @@ Extension disabled for lack of a hook
adding foo/file.txt revisions
files: 2/3 chunks (66.67%)
adding quux/file.py revisions
files: 3/3 chunks (100.00%)
added 3 changesets with 3 changes to 3 files
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -175,13 +175,13 @@ Extension disabled for lack of acl.sourc
adding quux/file.py revisions
files: 3/3 chunks (100.00%)
added 3 changesets with 3 changes to 3 files
calling hook pretxnchangegroup.acl: hgext.acl.hook
acl: changes have source "push" - skipping
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -247,13 +247,13 @@ No [acl.allow]/[acl.deny]
acl: path access granted: "ef1ea85a6374"
acl: branch access granted: "f9cafe1212c8" on branch "default"
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -318,10 +318,14 @@ Empty [acl.allow]
acl: branch access granted: "ef1ea85a6374" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "fred" not allowed on "foo/file.txt" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "fred" not allowed on "foo/file.txt" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
fred is allowed inside foo/
@@ -389,10 +393,14 @@ fred is allowed inside foo/
acl: branch access granted: "911600dab2ae" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae")
transaction abort!
rollback completed
abort: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
Empty [acl.deny]
@@ -457,10 +465,14 @@ Empty [acl.deny]
acl: branch access granted: "ef1ea85a6374" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
fred is allowed inside foo/, but not foo/bar/ (case matters)
@@ -530,10 +542,14 @@ fred is allowed inside foo/, but not foo
acl: branch access granted: "911600dab2ae" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae")
transaction abort!
rollback completed
abort: acl: user "fred" not allowed on "quux/file.py" (changeset "911600dab2ae")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
fred is allowed inside foo/, but not foo/Bar/
@@ -602,10 +618,14 @@ fred is allowed inside foo/, but not foo
acl: branch access granted: "f9cafe1212c8" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8")
transaction abort!
rollback completed
abort: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
$ echo 'barney is not mentioned => not allowed anywhere'
@@ -671,10 +691,14 @@ fred is allowed inside foo/, but not foo
acl: branch access granted: "ef1ea85a6374" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "barney" not allowed on "foo/file.txt" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
barney is allowed everywhere
@@ -745,13 +769,13 @@ barney is allowed everywhere
acl: path access granted: "ef1ea85a6374"
acl: branch access granted: "f9cafe1212c8" on branch "default"
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -827,10 +851,14 @@ wilma can change files with a .txt exten
acl: branch access granted: "911600dab2ae" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "wilma" not allowed on "quux/file.py" (changeset "911600dab2ae")
transaction abort!
rollback completed
abort: acl: user "wilma" not allowed on "quux/file.py" (changeset "911600dab2ae")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
file specified by acl.config does not exist
@@ -982,10 +1010,14 @@ betty is allowed inside foo/ by a acl.co
acl: branch access granted: "911600dab2ae" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "betty" not allowed on "quux/file.py" (changeset "911600dab2ae")
transaction abort!
rollback completed
abort: acl: user "betty" not allowed on "quux/file.py" (changeset "911600dab2ae")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
acl.config can set only [acl.allow]/[acl.deny]
@@ -1065,13 +1097,13 @@ acl.config can set only [acl.allow]/[acl
acl: path access granted: "ef1ea85a6374"
acl: branch access granted: "f9cafe1212c8" on branch "default"
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -1145,13 +1177,13 @@ fred is always allowed
acl: path access granted: "ef1ea85a6374"
acl: branch access granted: "f9cafe1212c8" on branch "default"
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -1222,10 +1254,14 @@ no one is allowed inside foo/Bar/
acl: branch access granted: "f9cafe1212c8" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8")
transaction abort!
rollback completed
abort: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
Groups
@@ -1298,13 +1334,13 @@ OS-level groups
acl: path access granted: "ef1ea85a6374"
acl: branch access granted: "f9cafe1212c8" on branch "default"
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 0 (undo push)
0:6675d58eff77
@@ -1377,10 +1413,14 @@ OS-level groups
acl: branch access granted: "f9cafe1212c8" on branch "default"
error: pretxnchangegroup.acl hook failed: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8")
transaction abort!
rollback completed
abort: acl: user "fred" denied on "foo/Bar/file.txt" (changeset "f9cafe1212c8")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
0:6675d58eff77
Invalid group
@@ -1499,13 +1539,13 @@ No branch acls specified
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
acl: branch access granted: "e8fc755d4d82" on branch "foobar"
acl: path access granted: "e8fc755d4d82"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 2 (undo push)
2:fb35475503ef
@@ -1584,10 +1624,15 @@ Branch acl deny test
acl: path access granted: "911600dab2ae"
error: pretxnchangegroup.acl hook failed: acl: user "astro" denied on branch "foobar" (changeset "e8fc755d4d82")
transaction abort!
rollback completed
abort: acl: user "astro" denied on branch "foobar" (changeset "e8fc755d4d82")
+ listing keys for "phases"
+ pushing key for "phases:fb35475503efed933514ec92cd0c9f341c73bffa"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
2:fb35475503ef
Branch acl empty allow test
@@ -1657,10 +1702,14 @@ Branch acl empty allow test
acl: acl.deny not enabled
error: pretxnchangegroup.acl hook failed: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
2:fb35475503ef
Branch acl allow other
@@ -1732,10 +1781,14 @@ Branch acl allow other
acl: acl.deny not enabled
error: pretxnchangegroup.acl hook failed: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
2:fb35475503ef
$ do_push george
Pushing as user george
@@ -1805,13 +1858,13 @@ Branch acl allow other
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
acl: branch access granted: "e8fc755d4d82" on branch "foobar"
acl: path access granted: "e8fc755d4d82"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 2 (undo push)
2:fb35475503ef
@@ -1836,10 +1889,11 @@ push foobar into the remote
"""
pushing to ../b
query 1; heads
searching for changes
all remote heads known locally
+ invalid branchheads cache (served): tip differs
listing keys for "bookmarks"
4 changesets found
list of changesets:
ef1ea85a6374b77d6da9dcda9541f498f2d17df7
f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1893,13 +1947,13 @@ push foobar into the remote
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
acl: branch access granted: "e8fc755d4d82" on branch "foobar"
acl: path access granted: "e8fc755d4d82"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 2 (undo push)
2:fb35475503ef
@@ -1923,10 +1977,11 @@ Branch acl conflicting deny
"""
pushing to ../b
query 1; heads
searching for changes
all remote heads known locally
+ invalid branchheads cache (served): tip differs
listing keys for "bookmarks"
4 changesets found
list of changesets:
ef1ea85a6374b77d6da9dcda9541f498f2d17df7
f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1976,10 +2031,14 @@ Branch acl conflicting deny
acl: acl.deny not enabled
error: pretxnchangegroup.acl hook failed: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
2:fb35475503ef
User 'astro' must not be denied
@@ -1997,10 +2056,11 @@ User 'astro' must not be denied
"""
pushing to ../b
query 1; heads
searching for changes
all remote heads known locally
+ invalid branchheads cache (served): tip differs
listing keys for "bookmarks"
4 changesets found
list of changesets:
ef1ea85a6374b77d6da9dcda9541f498f2d17df7
f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -2054,13 +2114,13 @@ User 'astro' must not be denied
acl: path access granted: "f9cafe1212c8"
acl: branch access granted: "911600dab2ae" on branch "default"
acl: path access granted: "911600dab2ae"
acl: branch access granted: "e8fc755d4d82" on branch "foobar"
acl: path access granted: "e8fc755d4d82"
+ updating the branch cache
listing keys for "phases"
try to push obsolete markers to remote
- updating the branch cache
checking for updated bookmarks
listing keys for "bookmarks"
repository tip rolled back to revision 2 (undo push)
2:fb35475503ef
@@ -2078,10 +2138,11 @@ Non-astro users must be denied
"""
pushing to ../b
query 1; heads
searching for changes
all remote heads known locally
+ invalid branchheads cache (served): tip differs
listing keys for "bookmarks"
4 changesets found
list of changesets:
ef1ea85a6374b77d6da9dcda9541f498f2d17df7
f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -2131,9 +2192,13 @@ Non-astro users must be denied
acl: acl.deny not enabled
error: pretxnchangegroup.acl hook failed: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374")
transaction abort!
rollback completed
abort: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374")
+ listing keys for "phases"
+ try to push obsolete markers to remote
+ checking for updated bookmarks
+ listing keys for "bookmarks"
no rollback information available
2:fb35475503ef
diff --git a/tests/test-eol-hook.t b/tests/test-eol-hook.t
--- a/tests/test-eol-hook.t
+++ b/tests/test-eol-hook.t
@@ -44,11 +44,11 @@ Create repo
a.txt in a8ee6548cd86 should not have CRLF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
a.txt in a8ee6548cd86 should not have CRLF line endings
- [255]
+ [1]
$ printf "first\nsecond\nthird\n" > a.txt
$ hg commit -m 'LF a.txt (fixed)'
$ hg push ../main
pushing to ../main
@@ -72,11 +72,11 @@ Create repo
crlf.txt in 004ba2132725 should not have LF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
crlf.txt in 004ba2132725 should not have LF line endings
- [255]
+ [1]
$ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt
$ hg commit -m 'CRLF crlf.txt (fixed)'
$ hg push ../main
pushing to ../main
@@ -100,11 +100,11 @@ Create repo
b.txt in fbcf9b1025f5 should not have CRLF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
- [255]
+ [1]
$ hg up -r -2
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ printf "some\nother\nfile" > c.txt
$ hg add c.txt
@@ -121,11 +121,11 @@ Create repo
b.txt in fbcf9b1025f5 should not have CRLF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
- [255]
+ [1]
Test checkheadshook alias
$ cat > ../main/.hg/hgrc <<EOF
> [hooks]
@@ -142,11 +142,11 @@ Test checkheadshook alias
b.txt in fbcf9b1025f5 should not have CRLF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
- [255]
+ [1]
We can fix the head and push again
$ hg up 6
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -179,11 +179,11 @@ Test it still fails with checkallhook
b.txt in fbcf9b1025f5 should not have CRLF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
- [255]
+ [1]
But we can push the clean head
$ hg push -r7 -f ../main
pushing to ../main
@@ -211,8 +211,8 @@ Test multiple files/revisions output
transaction abort!
rollback completed
abort: end-of-line check failed:
d.txt in a7040e68714f should not have CRLF line endings
b.txt in fbcf9b1025f5 should not have CRLF line endings
- [255]
+ [1]
$ cd ..
diff --git a/tests/test-lock-badness.t b/tests/test-lock-badness.t
--- a/tests/test-lock-badness.t
+++ b/tests/test-lock-badness.t
@@ -32,10 +32,11 @@ Pushing to a local read-only repo that c
$ chmod 100 a/.hg/store
$ hg -R b push a
pushing to a
+ searching for changes
abort: could not lock repository a: Permission denied
[255]
$ chmod 700 a/.hg/store
#endif
diff --git a/tests/test-push-validation.t b/tests/test-push-validation.t
--- a/tests/test-push-validation.t
+++ b/tests/test-push-validation.t
@@ -50,11 +50,11 @@ Expected to fail:
adding manifests
adding file changes
transaction abort!
rollback completed
abort: received spurious file revlog entry
- [255]
+ [1]
$ hg -q rollback
$ mv tmp1 .hg/store/data/beta.i
$ echo beta > beta
@@ -85,8 +85,8 @@ Expected to fail:
adding manifests
adding file changes
transaction abort!
rollback completed
abort: missing file data for beta:dddc47b3ba30e54484720ce0f4f768a0f4b6efb9 - run hg verify
- [255]
+ [1]
$ cd ..
diff --git a/tests/test-win32text.t b/tests/test-win32text.t
--- a/tests/test-win32text.t
+++ b/tests/test-win32text.t
@@ -76,11 +76,11 @@ push should fail
[decode]
** = cleverdecode:
transaction abort!
rollback completed
abort: pretxnchangegroup.crlf hook failed
- [255]
+ [1]
$ mv .hg/hgrc.bak .hg/hgrc
$ echo hello > f
$ hg rm g
More information about the Mercurial-devel
mailing list