mirror of
https://github.com/facebook/sapling.git
synced 2024-12-26 22:47:26 +03:00
pull: automatically pull selective bookmarks unless it's a no-argument pull
Summary: This enforces certain selective pull logic in core. Namely, rewrite `pull -r X` to `pull -r X -B master`. Unlike selectivepull in remotenames, `pull` (pulls everything) won't be rewritten to `pull -B master` (which pulls less commits and names). Therefore this change always adds more commits to pull, and therefore should not break existing users. Eventually we want the "not pulling everything" behavior, but right now this just fixes `pull -r X` to also update important remote names. Reviewed By: markbt Differential Revision: D20531121 fbshipit-source-id: af457b5ddb1265b61956eb2ee6afb7b7208293e0
This commit is contained in:
parent
afe479ff4d
commit
8bd55436a4
@ -133,6 +133,9 @@ check unhydrated infinitepush pulls
|
||||
remote: capabilities: * (glob)
|
||||
remote: * (glob)
|
||||
sending clienttelemetry command
|
||||
preparing listkeys for "bookmarks"
|
||||
sending listkeys command
|
||||
received listkey for "bookmarks": 57 bytes
|
||||
sending lookup command
|
||||
query 1; heads
|
||||
sending batch command
|
||||
@ -149,9 +152,7 @@ check unhydrated infinitepush pulls
|
||||
bundle2-input-part: total payload size * (glob)
|
||||
bundle2-input-part: "phase-heads" supported
|
||||
bundle2-input-part: total payload size * (glob)
|
||||
bundle2-input-part: "listkeys" (params: 1 mandatory) supported
|
||||
bundle2-input-part: total payload size * (glob)
|
||||
bundle2-input-bundle: 2 parts total
|
||||
bundle2-input-bundle: 1 parts total
|
||||
checking for updated bookmarks
|
||||
|
||||
-- update to the recently pullued draft commit
|
||||
@ -213,6 +214,9 @@ check hydrated infinitepush pulls
|
||||
remote: capabilities: * (glob)
|
||||
remote: * (glob)
|
||||
sending clienttelemetry command
|
||||
preparing listkeys for "bookmarks"
|
||||
sending listkeys command
|
||||
received listkey for "bookmarks": 57 bytes
|
||||
sending lookup command
|
||||
query 1; heads
|
||||
sending batch command
|
||||
@ -232,9 +236,7 @@ check hydrated infinitepush pulls
|
||||
bundle2-input-part: total payload size * (glob)
|
||||
bundle2-input-part: "phase-heads" supported
|
||||
bundle2-input-part: total payload size * (glob)
|
||||
bundle2-input-part: "listkeys" (params: 1 mandatory) supported
|
||||
bundle2-input-part: total payload size * (glob)
|
||||
bundle2-input-bundle: 3 parts total
|
||||
bundle2-input-bundle: 2 parts total
|
||||
checking for updated bookmarks
|
||||
|
||||
-- update to the recently pullued draft commit
|
||||
|
@ -4719,14 +4719,28 @@ def pull(ui, repo, source="default", **opts):
|
||||
other = conn.peer
|
||||
revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get("rev"))
|
||||
|
||||
implicitbookmarks = set()
|
||||
# If any revision is given, ex. pull -r HASH, include selectivepull
|
||||
# bookmarks automatically. This check exists so the no-argument
|
||||
# pull is unaffected (pulls everything instead of just
|
||||
# selectivepull bookmarks)
|
||||
if revs:
|
||||
remotename = ui.paths.getname(other.url()) # ex. 'default' or 'remote'
|
||||
# Include selective pull bookmarks automatically.
|
||||
implicitbookmarks.update(
|
||||
bookmarks.selectivepullbookmarknames(repo, remotename)
|
||||
)
|
||||
|
||||
pullopargs = {}
|
||||
if opts.get("bookmark"):
|
||||
if opts.get("bookmark") or implicitbookmarks:
|
||||
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)
|
||||
# TODO: Consider migrate to repo.pull to avoid the race
|
||||
# condition.
|
||||
remotebookmarks = other.listkeys("bookmarks")
|
||||
remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
|
||||
pullopargs["remotebookmarks"] = remotebookmarks
|
||||
@ -4735,6 +4749,10 @@ def pull(ui, repo, source="default", **opts):
|
||||
if b not in remotebookmarks:
|
||||
raise error.Abort(_("remote bookmark %s not found!") % b)
|
||||
revs.append(hex(remotebookmarks[b]))
|
||||
implicitbookmarks.discard(b)
|
||||
for b in implicitbookmarks:
|
||||
if b in remotebookmarks:
|
||||
revs.append(hex(remotebookmarks[b]))
|
||||
|
||||
if revs:
|
||||
try:
|
||||
|
@ -76,6 +76,6 @@ Pull exactly up to d into the client
|
||||
adding file changes
|
||||
added 2 changesets with 0 changes to 0 files
|
||||
{ metrics : { ssh : { connections : 1,
|
||||
read : { bytes : 1155},
|
||||
write : { bytes : 693}}}}
|
||||
read : { bytes : 1114},
|
||||
write : { bytes : 690}}}}
|
||||
|
||||
|
@ -13,8 +13,10 @@ feature.require(["py2"])
|
||||
|
||||
sh % "newrepo server"
|
||||
sh % "drawdag" << r"""
|
||||
B
|
||||
|
|
||||
D
|
||||
|
|
||||
B C
|
||||
|/
|
||||
A
|
||||
"""
|
||||
sh % 'hg bookmark -r "desc(B)" master'
|
||||
@ -29,6 +31,26 @@ sh % "hg pull" == r"""
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 2 changesets with 2 changes to 2 files
|
||||
added 4 changesets with 4 changes to 4 files
|
||||
adding remote bookmark master"""
|
||||
sh % 'hg dbsh -c "ui.write(repo.svfs.tryread(\\"remotenames\\") + \\"\\n\\")"' == "112478962961147124edd43549aedd1a335e44bf bookmarks default/master"
|
||||
|
||||
# pull -r should also pull master.
|
||||
|
||||
sh % "newrepo client2"
|
||||
sh % 'setconfig "paths.default=$TESTTMP/server" "extensions.remotenames=!"'
|
||||
|
||||
sh % "hg pull -r $C" == r"""
|
||||
pulling from $TESTTMP/server
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 3 changesets with 3 changes to 3 files
|
||||
adding remote bookmark master"""
|
||||
|
||||
sh % "hg log -Gr 'all()' -T '{desc} {remotenames}'" == r"""
|
||||
o C
|
||||
|
|
||||
| o B default/master
|
||||
|/
|
||||
o A"""
|
||||
|
@ -49,6 +49,7 @@ Looks like `ui.warn()` after getfiles might not make it's way to client hg. Let'
|
||||
$ hg pull -r ololo 2>&1 | grep wireproto_requests
|
||||
remote: wireproto_requests: (args=[], command=hello, duration=*, reponame=unknown, responselen=*) (glob)
|
||||
remote: wireproto_requests: (args=['0000000000000000000000000000000000000000-0000000000000000000000000000000000000000'], command=between, duration=*, reponame=unknown, responselen=*) (glob)
|
||||
remote: wireproto_requests: (args=['bookmarks'], command=listkeys, duration=*, reponame=unknown, responselen=0) (glob)
|
||||
remote: wireproto_requests: (args=['ololo'], command=lookup, duration=*, reponame=unknown, responselen=*) (glob)
|
||||
|
||||
Enable clienttelemetry and change reponame
|
||||
|
Loading…
Reference in New Issue
Block a user