mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
infinitepush: select infinitepush path only for scratch bookmarks
Summary: At the moment "hg pull -B bookmark" always fetches from infinitepush path even if we do something like "hg pull -B master". Let's fetch from infinitepush only if a bookmark matches scratch mather Reviewed By: markbt Differential Revision: D25460577 fbshipit-source-id: 6563dcd3423c6a7a70ea1c1f7acdaf5db5e21875
This commit is contained in:
parent
7c7c575d35
commit
cbe07f0d17
@ -356,14 +356,14 @@ def _pull(orig, ui, repo, source="default", **opts):
|
||||
# This is useful for dogfooding other hg backend that stores only public commits
|
||||
# (e.g. Mononoke)
|
||||
if opts.get("rev") or opts.get("bookmark"):
|
||||
with _resetinfinitepushpath(ui, **opts):
|
||||
with _resetinfinitepushpath(repo, ui, **opts):
|
||||
return _dopull(orig, ui, repo, source, **opts)
|
||||
|
||||
return _dopull(orig, ui, repo, source, **opts)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _resetinfinitepushpath(ui, **opts):
|
||||
def _resetinfinitepushpath(repo, ui, **opts):
|
||||
"""
|
||||
Sets "default" path to "infinitepush" or "infinitepushbookmark" path and
|
||||
deletes "infinitepush"/"infinitepushbookmark" path ("infinitepushbookmark"
|
||||
@ -382,6 +382,17 @@ def _resetinfinitepushpath(ui, **opts):
|
||||
infinitepushwritepath = pathname.infinitepushwrite
|
||||
infinitepushbookmarkpath = pathname.infinitepushbookmark
|
||||
|
||||
if opts.get("bookmark"):
|
||||
for b in opts["bookmark"]:
|
||||
if repo._scratchbranchmatcher.match(b):
|
||||
break
|
||||
else:
|
||||
# Bookmarks were requested to pull, but not
|
||||
# a single bookmark matches scratch branch matcher.
|
||||
# Let's pull from normal path instead
|
||||
yield
|
||||
return
|
||||
|
||||
pullingsinglecommithash = False
|
||||
if opts.get("rev"):
|
||||
revs = opts.get("rev")
|
||||
|
@ -98,3 +98,18 @@ Update by full hash - infinitepush path should be used (if infinitepushbookmark
|
||||
$ hg update "$FULLHASH"
|
||||
pulling 'd15d0da9f84a9bebe6744eba3ec1dd86e2d46818' from 'ssh://user@dummy/repo'
|
||||
2 files updated, 0 files merged, 3 files removed, 0 files unresolved
|
||||
|
||||
Check that non-scratch bookmark is pulled from normal path
|
||||
$ cd "$TESTTMP/repo"
|
||||
$ hg book newbook
|
||||
$ cd "$TESTTMP/first_client"
|
||||
$ cat << EOF >> .hg/hgrc
|
||||
> [paths]
|
||||
> default=ssh://user@dummy/repo
|
||||
> infinitepush=ssh://user@dummy/broken
|
||||
> infinitepushbookmark=ssh://user@dummy/broken
|
||||
> EOF
|
||||
$ hg pull -B newbook
|
||||
pulling from ssh://user@dummy/repo
|
||||
no changes found
|
||||
adding remote bookmark newbook
|
||||
|
Loading…
Reference in New Issue
Block a user