mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
cmdserver: allow to start server without repository
Typical use case is to clone repository through command server. Clone may require user interaction, so command-server protocol is beneficial over raw stdio channels.
This commit is contained in:
parent
8fcb453c5c
commit
b6eb1297a9
@ -5168,7 +5168,6 @@ def serve(ui, repo, **opts):
|
||||
s.serve_forever()
|
||||
|
||||
if opts["cmdserver"]:
|
||||
checkrepo()
|
||||
s = commandserver.server(ui, repo, opts["cmdserver"])
|
||||
return s.serve()
|
||||
|
||||
|
@ -142,11 +142,15 @@ class server(object):
|
||||
else:
|
||||
logfile = open(logpath, 'a')
|
||||
|
||||
# the ui here is really the repo ui so take its baseui so we don't end
|
||||
# up with its local configuration
|
||||
self.ui = repo.baseui
|
||||
self.repo = repo
|
||||
self.repoui = repo.ui
|
||||
if repo:
|
||||
# the ui here is really the repo ui so take its baseui so we don't
|
||||
# end up with its local configuration
|
||||
self.ui = repo.baseui
|
||||
self.repo = repo
|
||||
self.repoui = repo.ui
|
||||
else:
|
||||
self.ui = ui
|
||||
self.repo = self.repoui = None
|
||||
|
||||
if mode == 'pipe':
|
||||
self.cerr = channeledoutput(sys.stderr, sys.stdout, 'e')
|
||||
@ -183,12 +187,13 @@ class server(object):
|
||||
# copy the uis so changes (e.g. --config or --verbose) don't
|
||||
# persist between requests
|
||||
copiedui = self.ui.copy()
|
||||
self.repo.baseui = copiedui
|
||||
# clone ui without using ui.copy because this is protected
|
||||
repoui = self.repoui.__class__(self.repoui)
|
||||
repoui.copy = copiedui.copy # redo copy protection
|
||||
self.repo.ui = self.repo.dirstate._ui = repoui
|
||||
self.repo.invalidateall()
|
||||
if self.repo:
|
||||
self.repo.baseui = copiedui
|
||||
# clone ui without using ui.copy because this is protected
|
||||
repoui = self.repoui.__class__(self.repoui)
|
||||
repoui.copy = copiedui.copy # redo copy protection
|
||||
self.repo.ui = self.repo.dirstate._ui = repoui
|
||||
self.repo.invalidateall()
|
||||
|
||||
req = dispatch.request(args[:], copiedui, self.repo, self.cin,
|
||||
self.cout, self.cerr)
|
||||
|
@ -294,6 +294,11 @@ def mqoutsidechanges(server):
|
||||
# repo.mq should be recreated to point to new queue
|
||||
runcommand(server, ['qqueue', '--active'])
|
||||
|
||||
def startwithoutrepo(server):
|
||||
readchannel(server)
|
||||
runcommand(server, ['init', 'repo2'])
|
||||
runcommand(server, ['id', '-R', 'repo2'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.system('hg init repo')
|
||||
os.chdir('repo')
|
||||
@ -329,3 +334,7 @@ if __name__ == '__main__':
|
||||
hgrc.write('[extensions]\nmq=\n')
|
||||
hgrc.close()
|
||||
check(mqoutsidechanges)
|
||||
|
||||
os.chdir('..')
|
||||
check(hellomessage)
|
||||
check(startwithoutrepo)
|
||||
|
@ -237,3 +237,16 @@ popping 0.diff
|
||||
patch queue now empty
|
||||
runcommand qqueue --active
|
||||
foo
|
||||
|
||||
testing hellomessage:
|
||||
|
||||
o, 'capabilities: getencoding runcommand\nencoding: ***'
|
||||
runcommand id
|
||||
abort: there is no Mercurial repository here (.hg not found)
|
||||
[255]
|
||||
|
||||
testing startwithoutrepo:
|
||||
|
||||
runcommand init repo2
|
||||
runcommand id -R repo2
|
||||
000000000000 tip
|
||||
|
Loading…
Reference in New Issue
Block a user