mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 21:48:36 +03:00
pull: use transaction
Summary: Without this change, the next diff will fail tests with metalog programming errors (write outside transaction). Some test changes are caused by the being deprecated `rollback` command. Reviewed By: DurhamG Differential Revision: D19380939 fbshipit-source-id: 7c893d3025bb697102835670b8a38f8fb9a624c8
This commit is contained in:
parent
ba2d83b3f8
commit
dd1b9cc98d
@ -4732,60 +4732,62 @@ def pull(ui, repo, source="default", **opts):
|
||||
ui.status(_("pulling from %s\n") % util.hidepassword(source))
|
||||
|
||||
with repo.connectionpool.get(source, opts=opts) as conn:
|
||||
other = conn.peer
|
||||
revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get("rev"))
|
||||
with repo.wlock(), repo.lock(), repo.transaction("pull"):
|
||||
other = conn.peer
|
||||
revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get("rev"))
|
||||
|
||||
pullopargs = {}
|
||||
if opts.get("bookmark"):
|
||||
if not revs:
|
||||
revs = []
|
||||
# The list of bookmark used here is not the one used to actually
|
||||
# update the bookmark name. This can result in the revision pulled
|
||||
# not ending up with the name of the bookmark because of a race
|
||||
# condition on the server. (See issue 4689 for details)
|
||||
remotebookmarks = other.listkeys("bookmarks")
|
||||
remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
|
||||
pullopargs["remotebookmarks"] = remotebookmarks
|
||||
for b in opts["bookmark"]:
|
||||
b = repo._bookmarks.expandname(b)
|
||||
if b not in remotebookmarks:
|
||||
raise error.Abort(_("remote bookmark %s not found!") % b)
|
||||
revs.append(hex(remotebookmarks[b]))
|
||||
pullopargs = {}
|
||||
if opts.get("bookmark"):
|
||||
if not revs:
|
||||
revs = []
|
||||
# The list of bookmark used here is not the one used to actually
|
||||
# update the bookmark name. This can result in the revision pulled
|
||||
# not ending up with the name of the bookmark because of a race
|
||||
# condition on the server. (See issue 4689 for details)
|
||||
remotebookmarks = other.listkeys("bookmarks")
|
||||
remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
|
||||
pullopargs["remotebookmarks"] = remotebookmarks
|
||||
for b in opts["bookmark"]:
|
||||
b = repo._bookmarks.expandname(b)
|
||||
if b not in remotebookmarks:
|
||||
raise error.Abort(_("remote bookmark %s not found!") % b)
|
||||
revs.append(hex(remotebookmarks[b]))
|
||||
|
||||
if revs:
|
||||
try:
|
||||
# When 'rev' is a bookmark name, we cannot guarantee that it
|
||||
# will be updated with that name because of a race condition
|
||||
# server side. (See issue 4689 for details)
|
||||
oldrevs = revs
|
||||
revs = [] # actually, nodes
|
||||
for r in oldrevs:
|
||||
node = other.lookup(r)
|
||||
revs.append(node)
|
||||
if r == checkout:
|
||||
checkout = node
|
||||
except error.CapabilityError:
|
||||
err = _(
|
||||
"other repository doesn't support revision lookup, "
|
||||
"so a rev cannot be specified."
|
||||
)
|
||||
raise error.Abort(err)
|
||||
if revs:
|
||||
try:
|
||||
# When 'rev' is a bookmark name, we cannot guarantee that it
|
||||
# will be updated with that name because of a race condition
|
||||
# server side. (See issue 4689 for details)
|
||||
oldrevs = revs
|
||||
revs = [] # actually, nodes
|
||||
for r in oldrevs:
|
||||
node = other.lookup(r)
|
||||
revs.append(node)
|
||||
if r == checkout:
|
||||
checkout = node
|
||||
except error.CapabilityError:
|
||||
err = _(
|
||||
"other repository doesn't support revision lookup, "
|
||||
"so a rev cannot be specified."
|
||||
)
|
||||
raise error.Abort(err)
|
||||
|
||||
pullopargs.update(opts.get("opargs", {}))
|
||||
modheads = exchange.pull(
|
||||
repo,
|
||||
other,
|
||||
heads=revs,
|
||||
force=opts.get("force"),
|
||||
bookmarks=opts.get("bookmark", ()),
|
||||
opargs=pullopargs,
|
||||
).cgresult
|
||||
pullopargs.update(opts.get("opargs", {}))
|
||||
modheads = exchange.pull(
|
||||
repo,
|
||||
other,
|
||||
heads=revs,
|
||||
force=opts.get("force"),
|
||||
bookmarks=opts.get("bookmark", ()),
|
||||
opargs=pullopargs,
|
||||
).cgresult
|
||||
|
||||
# brev is a name, which might be a bookmark to be activated at
|
||||
# the end of the update. In other words, it is an explicit
|
||||
# destination of the update
|
||||
brev = None
|
||||
# brev is a name, which might be a bookmark to be activated at
|
||||
# the end of the update. In other words, it is an explicit
|
||||
# destination of the update
|
||||
brev = None
|
||||
|
||||
# Run 'update' in another transaction.
|
||||
if checkout and checkout in repo:
|
||||
checkout = str(repo.changelog.rev(checkout))
|
||||
|
||||
|
@ -108,8 +108,7 @@ Pull full.hg into empty (using --cwd)
|
||||
|
||||
Rollback empty
|
||||
|
||||
$ hg -R empty rollback
|
||||
repository tip rolled back to revision -1 (undo pull)
|
||||
$ hg -R empty debugstrip 0 --no-backup
|
||||
|
||||
Pull full.hg into empty again (using --cwd)
|
||||
|
||||
@ -137,8 +136,7 @@ Pull full.hg into empty (using -R)
|
||||
|
||||
Rollback empty
|
||||
|
||||
$ hg -R empty rollback
|
||||
repository tip rolled back to revision -1 (undo pull)
|
||||
$ hg -R empty debugstrip 0 --no-backup
|
||||
|
||||
Pull full.hg into empty again (using -R)
|
||||
|
||||
@ -234,8 +232,7 @@ hg -R ../full.hg verify
|
||||
|
||||
Rollback empty
|
||||
|
||||
$ hg rollback
|
||||
repository tip rolled back to revision -1 (undo pull)
|
||||
$ hg debugstrip 0 --no-backup
|
||||
$ cd ..
|
||||
|
||||
Log -R bundle:empty+full.hg (broken with Rust code path)
|
||||
|
@ -117,8 +117,7 @@ pull
|
||||
1 new obsolescence markers
|
||||
pre-close-tip:24b6387c8c8c draft
|
||||
postclose-tip:24b6387c8c8c draft
|
||||
txnclose hook: HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_NODE_LAST=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull
|
||||
file:/*/$TESTTMP/main HG_URL=file:$TESTTMP/main (glob)
|
||||
txnclose hook: HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_NODE_LAST=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull HG_URL=file:$TESTTMP/main
|
||||
$ hg -R other log -G
|
||||
o 2:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
|
||||
|
|
||||
@ -141,8 +140,7 @@ pull empty (with phase movement)
|
||||
no changes found
|
||||
pre-close-tip:24b6387c8c8c public
|
||||
postclose-tip:24b6387c8c8c public
|
||||
txnclose hook: HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=0 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull
|
||||
file:/*/$TESTTMP/main HG_URL=file:$TESTTMP/main (glob)
|
||||
txnclose hook: HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=0 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull HG_URL=file:$TESTTMP/main
|
||||
$ hg -R other log -G
|
||||
o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
|
||||
|
|
||||
@ -161,8 +159,7 @@ pull empty
|
||||
no changes found
|
||||
pre-close-tip:24b6387c8c8c public
|
||||
postclose-tip:24b6387c8c8c public
|
||||
txnclose hook: HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=0 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull
|
||||
file:/*/$TESTTMP/main HG_URL=file:$TESTTMP/main (glob)
|
||||
txnclose hook: HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=0 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull HG_URL=file:$TESTTMP/main
|
||||
$ hg -R other log -G
|
||||
o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
|
||||
|
|
||||
@ -287,8 +284,7 @@ pull over ssh
|
||||
updating bookmark book_02de
|
||||
pre-close-tip:02de42196ebe draft book_02de
|
||||
postclose-tip:02de42196ebe draft book_02de
|
||||
txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_NODE_LAST=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull
|
||||
ssh://user@dummy/main HG_URL=ssh://user@dummy/main
|
||||
txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_NODE_LAST=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull HG_URL=ssh://user@dummy/main
|
||||
$ hg -R other debugobsolete
|
||||
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
|
||||
2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
|
||||
@ -312,8 +308,7 @@ pull over http
|
||||
updating bookmark book_42cc
|
||||
pre-close-tip:42ccdea3bb16 draft book_42cc
|
||||
postclose-tip:42ccdea3bb16 draft book_42cc
|
||||
txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_NODE_LAST=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull
|
||||
http://localhost:$HGPORT/ HG_URL=http://localhost:$HGPORT/ (glob)
|
||||
txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_NODE_LAST=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_TXNNAME=pull HG_URL=http://localhost:$HGPORT/ (glob)
|
||||
$ cat main-error.log
|
||||
$ hg -R other debugobsolete
|
||||
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
|
||||
|
@ -92,9 +92,9 @@ Pull the new commits in the clone
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
pretxnchangegroup hook: HG_HOOKNAME=pretxnchangegroup HG_HOOKTYPE=pretxnchangegroup HG_NODE=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_NODE_LAST=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_PENDING=$TESTTMP/clone HG_PHASES_MOVED=1 HG_SHAREDPENDING=$TESTTMP/clone HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
pullop.cgresult is 1
|
||||
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_NODE_LAST=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_NODE_LAST=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
pullop.cgresult is 1
|
||||
$ hg update
|
||||
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ hg log -G
|
||||
@ -159,9 +159,9 @@ pullop.cgresult
|
||||
adding file changes
|
||||
added 3 changesets with 3 changes to 3 files
|
||||
pretxnchangegroup hook: HG_HOOKNAME=pretxnchangegroup HG_HOOKTYPE=pretxnchangegroup HG_NODE=7f219660301fe4c8a116f714df5e769695cc2b46 HG_NODE_LAST=5cd59d311f6508b8e0ed28a266756c859419c9f1 HG_PENDING=$TESTTMP/clone HG_PHASES_MOVED=1 HG_SHAREDPENDING=$TESTTMP/clone HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
pullop.cgresult is 1
|
||||
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e HG_NODE_LAST=8a5212ebc8527f9fb821601504794e3eb11a1ed3 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=7f219660301fe4c8a116f714df5e769695cc2b46 HG_NODE_LAST=5cd59d311f6508b8e0ed28a266756c859419c9f1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
pullop.cgresult is 1
|
||||
$ hg log -G
|
||||
o 7:5cd59d311f65 public test H
|
||||
|
|
||||
@ -226,9 +226,9 @@ pullop.cgresult
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
pretxnchangegroup hook: HG_HOOKNAME=pretxnchangegroup HG_HOOKTYPE=pretxnchangegroup HG_NODE=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_NODE_LAST=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_PENDING=$TESTTMP/clone HG_PHASES_MOVED=1 HG_SHAREDPENDING=$TESTTMP/clone HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
pullop.cgresult is 1
|
||||
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_NODE_LAST=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_NODE_LAST=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/repo
|
||||
pullop.cgresult is 1
|
||||
$ hg log -G
|
||||
o 9:9d18e5bd9ab0 public test H
|
||||
|
|
||||
|
@ -54,7 +54,7 @@
|
||||
no changes found
|
||||
|
||||
$ hg rollback --dry-run --verbose
|
||||
repository tip rolled back to revision 0 (undo clone)
|
||||
repository tip rolled back to revision 0 (undo pull)
|
||||
|
||||
Test pull of non-existing 20 character revision specification, making sure plain ascii identifiers
|
||||
not are encoded like a node:
|
||||
|
@ -163,8 +163,7 @@ No new revs, no update:
|
||||
$ hg parents -q
|
||||
0:1f0dee641bb7
|
||||
|
||||
$ hg rollback
|
||||
repository tip rolled back to revision 1 (undo pull)
|
||||
$ hg debugstrip 1 --no-backup
|
||||
|
||||
$ hg parents -q
|
||||
0:1f0dee641bb7
|
||||
@ -180,12 +179,12 @@ Pull -u takes us back to branch foo:
|
||||
date: Thu Jan 01 00:00:00 1970 +0000
|
||||
summary: new head of branch foo
|
||||
|
||||
$ hg rollback
|
||||
repository tip rolled back to revision 1 (undo pull)
|
||||
working directory now based on revision 0
|
||||
$ hg debugstrip 2 --no-backup
|
||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
|
||||
$ hg up -C 0
|
||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
(leaving bookmark foo)
|
||||
|
||||
$ hg parents -q
|
||||
0:1f0dee641bb7
|
||||
|
Loading…
Reference in New Issue
Block a user