mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
infinitepush: pull node during update
Summary: Let's pull node during update if not found locally. This is a part of selectivepull functionality. See remotenames extensions for details about selectivepull. Test Plan: arc unit Reviewers: #sourcecontrol, durham Reviewed By: durham Subscribers: indragie, mjpieters, sergeyb Differential Revision: https://phabricator.intern.facebook.com/D4536129 Tasks: 12479658 Signature: t1:4536129:1486667537:3d1df30cb5d1db0dd7451756102ccafee20789d5
This commit is contained in:
parent
41d4153092
commit
3c186b1ee4
@ -70,8 +70,10 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
@ -119,6 +121,7 @@ configscratchpush = 'infinitepush-scratchpush'
|
||||
confignonforwardmove = 'non-forward-move'
|
||||
|
||||
_scratchbranchmatcher = lambda x: False
|
||||
_maybehash = re.compile(r'^[a-f0-9]+$').search
|
||||
|
||||
def _buildexternalbundlestore(ui):
|
||||
put_args = ui.configlist('infinitepush', 'put_args', [])
|
||||
@ -253,6 +256,7 @@ def clientextsetup(ui):
|
||||
'name of the remote path to list the bookmarks'))
|
||||
|
||||
wrapcommand(commands.table, 'pull', _pull)
|
||||
wrapcommand(commands.table, 'update', _update)
|
||||
|
||||
wrapfunction(discovery, 'checkheads', _checkheads)
|
||||
|
||||
@ -506,6 +510,25 @@ def _decodebookmarks(stream):
|
||||
result[bookmark] = node
|
||||
return result
|
||||
|
||||
def _update(orig, ui, repo, node=None, rev=None, **opts):
|
||||
if rev and node:
|
||||
raise error.Abort(_("please specify just one revision"))
|
||||
|
||||
if not opts.get('date') and (rev or node) not in repo:
|
||||
mayberemotenode = rev or node
|
||||
if len(mayberemotenode) == 40 and _maybehash(mayberemotenode):
|
||||
ui.warn(
|
||||
_("'%s' does not exist locally - looking for it " +
|
||||
"remotely...\n") % mayberemotenode)
|
||||
# Try pulling node from remote repo
|
||||
try:
|
||||
commands.pull(ui, repo, rev=[mayberemotenode])
|
||||
except Exception:
|
||||
ui.warn(_('pull failed: %s\n') % sys.exc_info()[1])
|
||||
else:
|
||||
ui.warn(_("'%s' found remotely\n") % mayberemotenode)
|
||||
return orig(ui, repo, node, rev, **opts)
|
||||
|
||||
def _pull(orig, ui, repo, source="default", **opts):
|
||||
# Copy paste from `pull` command
|
||||
source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
|
||||
|
@ -677,3 +677,27 @@ Make sure phase on the client is public.
|
||||
|/
|
||||
o initialcommit public 67145f466344
|
||||
|
||||
Strip scratchontopofpublic commit and do hg update
|
||||
$ hg log -r tip -T '{node}\n'
|
||||
c70aee6da07d7cdb9897375473690df3a8563339
|
||||
$ hg strip -q tip
|
||||
$ hg up c70aee6da07d7cdb9897375473690df3a8563339
|
||||
'c70aee6da07d7cdb9897375473690df3a8563339' does not exist locally - looking for it remotely...
|
||||
pulling from ssh://user@dummy/repo
|
||||
searching for changes
|
||||
no changes found
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
'c70aee6da07d7cdb9897375473690df3a8563339' found remotely
|
||||
2 files updated, 0 files merged, 2 files removed, 0 files unresolved
|
||||
|
||||
Trying to pull from bad path
|
||||
$ hg strip -q tip
|
||||
$ hg --config paths.default=badpath up c70aee6da07d7cdb9897375473690df3a8563339
|
||||
'c70aee6da07d7cdb9897375473690df3a8563339' does not exist locally - looking for it remotely...
|
||||
pulling from $TESTTMP/client2/badpath (glob)
|
||||
pull failed: repository $TESTTMP/client2/badpath not found
|
||||
abort: unknown revision 'c70aee6da07d7cdb9897375473690df3a8563339'!
|
||||
[255]
|
||||
|
0
tests/test-infinitepush-update.t
Normal file
0
tests/test-infinitepush-update.t
Normal file
Loading…
Reference in New Issue
Block a user