prefer 'infinitepush' path instead of 'default'

Reviewed By: markbt

Differential Revision: D8734958

fbshipit-source-id: 7ed7910befdbd7081af645c0bd89927a9f0c0ce4
This commit is contained in:
Stanislau Hlebik 2018-07-06 07:49:47 -07:00 committed by Facebook Github Bot
parent b159ed37b8
commit 4f70dea422
2 changed files with 102 additions and 0 deletions

View File

@ -852,10 +852,20 @@ def _update(orig, ui, repo, node=None, rev=None, **opts):
pullstarttime = time.time()
try:
# Prefer to pull from 'infinitepush' path if it exists.
# 'infinitepush' path has both infinitepush and non-infinitepush
# revisions, so pulling from it is safer.
# This is useful for dogfooding other hg backend that stores
# only public commits (e.g. Mononoke)
if "infinitepush" in ui.paths:
path = "infinitepush"
else:
path = "default"
(pullcmd, pullopts) = cmdutil.getcmdanddefaultopts(
"pull", commands.table
)
pullopts.update(kwargs)
pullopts["source"] = path
pullcmd(ui, repo, **pullopts)
except Exception:
remoteerror = str(sys.exc_info()[1])
@ -887,6 +897,15 @@ def _update(orig, ui, repo, node=None, rev=None, **opts):
def _pull(orig, ui, repo, source="default", **opts):
# If '-r' or '-B' option is set, then prefer to pull from 'infinitepush' path
# if it exists. 'infinitepush' path has both infinitepush and non-infinitepush
# revisions, so pulling from it is safer.
# This is useful for dogfooding other hg backend that stores only public commits
# (e.g. Mononoke)
if opts.get("rev") or opts.get("bookmark"):
if "infinitepush" in ui.paths:
source = "infinitepush"
# Copy paste from `pull` command
source, branches = hg.parseurl(ui.expandpath(source), opts.get("branch"))

View File

@ -0,0 +1,83 @@
$ cat >> $HGRCPATH << EOF
> [extensions]
> EOF
$ setup() {
> cat << EOF >> .hg/hgrc
> [extensions]
> fbamend=
> [experimental]
> evolution=createmarkers
> EOF
> }
$ . "$TESTDIR/library.sh"
$ . "$TESTDIR/infinitepush/library.sh"
$ setupcommon
Setup server
$ hg init repo
$ cd repo
$ setupserver
$ cd ..
Setup the first client
$ hg clone ssh://user@dummy/repo first_client -q
$ cd first_client
$ setup
$ cd ..
Setup the second client
$ hg clone ssh://user@dummy/repo second_client -q
$ cd second_client
$ setup
$ mkcommit commit
$ hg log -r . -T '{node}\n'
7e6a6fd9c7c8c8c307ee14678f03d63af3a7b455
$ mkcommit commit2
$ hg pushbackup -q
$ mkcommit commitwithbook
$ hg push -r . --to scratch/commit --create -q
$ hg up -q null
$ mkcommit onemorecommit
$ hg log -r . -T '{node}\n'
94f1e8b68592fbdd8e8606b6426bbd075a59c94c
$ hg pushbackup -q
$ cd ..
Change the paths: 'default' path should be incorrect, but 'infinitepush' path should be correct
`hg up` should nevertheless succeed
$ cd first_client
$ hg paths
default = ssh://user@dummy/repo
$ cat << EOF >> .hg/hgrc
> [paths]
> default=ssh://user@dummy/broken
> infinitepush=ssh://user@dummy/repo
> EOF
$ hg paths
default = ssh://user@dummy/broken
infinitepush = ssh://user@dummy/repo
$ hg up 7e6a6fd9c7c8c8 -q
'7e6a6fd9c7c8c8' does not exist locally - looking for it remotely...
'7e6a6fd9c7c8c8' found remotely
pull finished in * sec (glob)
Same goes for updating to a bookmark
$ hg up scratch/commit -q
'scratch/commit' does not exist locally - looking for it remotely...
'scratch/commit' found remotely
pull finished in * sec (glob)
Now try to pull it
$ hg pull -r 94f1e8b68592 -q
Now change the paths again try pull with no parameters. It should use default path
$ cat << EOF >> .hg/hgrc
> [paths]
> default=ssh://user@dummy/repo
> infinitepush=ssh://user@dummy/broken
> EOF
$ hg pull
pulling from ssh://user@dummy/repo
searching for changes
no changes found