##// END OF EJS Templates
named branches: server branchmap wire protocol support (issue736)...
Henrik Stuart -
r8562:e3495c39 default
parent child Browse files
Show More
@@ -5,7 +5,7 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2, incorporated herein by reference.
6 # GNU General Public License version 2, incorporated herein by reference.
7
7
8 import cStringIO, zlib, tempfile, errno, os, sys
8 import cStringIO, zlib, tempfile, errno, os, sys, urllib
9 from mercurial import util, streamclone
9 from mercurial import util, streamclone
10 from mercurial.node import bin, hex
10 from mercurial.node import bin, hex
11 from mercurial import changegroup as changegroupmod
11 from mercurial import changegroup as changegroupmod
@@ -17,6 +17,7 b' from common import ErrorResponse, HTTP_O'
17 __all__ = [
17 __all__ = [
18 'lookup', 'heads', 'branches', 'between', 'changegroup',
18 'lookup', 'heads', 'branches', 'between', 'changegroup',
19 'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
19 'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
20 'branchmap',
20 ]
21 ]
21
22
22 HGTYPE = 'application/mercurial-0.1'
23 HGTYPE = 'application/mercurial-0.1'
@@ -37,6 +38,17 b' def heads(repo, req):'
37 req.respond(HTTP_OK, HGTYPE, length=len(resp))
38 req.respond(HTTP_OK, HGTYPE, length=len(resp))
38 yield resp
39 yield resp
39
40
41 def branchmap(repo, req):
42 branches = repo.branchmap()
43 heads = []
44 for branch, nodes in branches.iteritems():
45 branchname = urllib.quote(branch)
46 branchnodes = [hex(node) for node in nodes]
47 heads.append('%s %s' % (branchname, ' '.join(branchnodes)))
48 resp = '\n'.join(heads)
49 req.respond(HTTP_OK, HGTYPE, length=len(resp))
50 yield resp
51
40 def branches(repo, req):
52 def branches(repo, req):
41 nodes = []
53 nodes = []
42 if 'nodes' in req.form:
54 if 'nodes' in req.form:
@@ -97,7 +109,7 b' def changegroupsubset(repo, req):'
97 yield z.flush()
109 yield z.flush()
98
110
99 def capabilities(repo, req):
111 def capabilities(repo, req):
100 caps = ['lookup', 'changegroupsubset']
112 caps = ['lookup', 'changegroupsubset', 'branchmap']
101 if repo.ui.configbool('server', 'uncompressed', untrusted=True):
113 if repo.ui.configbool('server', 'uncompressed', untrusted=True):
102 caps.append('stream=%d' % repo.changelog.version)
114 caps.append('stream=%d' % repo.changelog.version)
103 if changegroupmod.bundlepriority:
115 if changegroupmod.bundlepriority:
@@ -18,7 +18,7 b' import weakref, stat, errno, os, time, i'
18 propertycache = util.propertycache
18 propertycache = util.propertycache
19
19
20 class localrepository(repo.repository):
20 class localrepository(repo.repository):
21 capabilities = set(('lookup', 'changegroupsubset'))
21 capabilities = set(('lookup', 'changegroupsubset', 'branchmap'))
22 supported = set('revlogv1 store fncache'.split())
22 supported = set('revlogv1 store fncache'.split())
23
23
24 def __init__(self, baseui, path=None, create=0):
24 def __init__(self, baseui, path=None, create=0):
@@ -360,7 +360,7 b' class localrepository(repo.repository):'
360
360
361 return partial
361 return partial
362
362
363 def _branchheads(self):
363 def branchmap(self):
364 tip = self.changelog.tip()
364 tip = self.changelog.tip()
365 if self.branchcache is not None and self._branchcachetip == tip:
365 if self.branchcache is not None and self._branchcachetip == tip:
366 return self.branchcache
366 return self.branchcache
@@ -392,7 +392,7 b' class localrepository(repo.repository):'
392 '''return a dict where branch names map to the tipmost head of
392 '''return a dict where branch names map to the tipmost head of
393 the branch, open heads come before closed'''
393 the branch, open heads come before closed'''
394 bt = {}
394 bt = {}
395 for bn, heads in self._branchheads().iteritems():
395 for bn, heads in self.branchmap().iteritems():
396 head = None
396 head = None
397 for i in range(len(heads)-1, -1, -1):
397 for i in range(len(heads)-1, -1, -1):
398 h = heads[i]
398 h = heads[i]
@@ -1125,7 +1125,7 b' class localrepository(repo.repository):'
1125 def branchheads(self, branch=None, start=None, closed=True):
1125 def branchheads(self, branch=None, start=None, closed=True):
1126 if branch is None:
1126 if branch is None:
1127 branch = self[None].branch()
1127 branch = self[None].branch()
1128 branches = self._branchheads()
1128 branches = self.branchmap()
1129 if branch not in branches:
1129 if branch not in branches:
1130 return []
1130 return []
1131 bheads = branches[branch]
1131 bheads = branches[branch]
@@ -9,7 +9,7 b''
9 from i18n import _
9 from i18n import _
10 from node import bin, hex
10 from node import bin, hex
11 import streamclone, util, hook
11 import streamclone, util, hook
12 import os, sys, tempfile
12 import os, sys, tempfile, urllib
13
13
14 class sshserver(object):
14 class sshserver(object):
15 def __init__(self, ui, repo):
15 def __init__(self, ui, repo):
@@ -64,6 +64,15 b' class sshserver(object):'
64 success = 0
64 success = 0
65 self.respond("%s %s\n" % (success, r))
65 self.respond("%s %s\n" % (success, r))
66
66
67 def do_branchmap(self):
68 branchmap = self.repo.branchmap()
69 heads = []
70 for branch, nodes in branchmap.iteritems():
71 branchname = urllib.quote(branch)
72 branchnodes = [hex(node) for node in nodes]
73 heads.append('%s %s' % (branchname, ' '.join(branchnodes)))
74 self.respond('\n'.join(heads))
75
67 def do_heads(self):
76 def do_heads(self):
68 h = self.repo.heads()
77 h = self.repo.heads()
69 self.respond(" ".join(map(hex, h)) + "\n")
78 self.respond(" ".join(map(hex, h)) + "\n")
@@ -77,7 +86,7 b' class sshserver(object):'
77 capabilities: space separated list of tokens
86 capabilities: space separated list of tokens
78 '''
87 '''
79
88
80 caps = ['unbundle', 'lookup', 'changegroupsubset']
89 caps = ['unbundle', 'lookup', 'changegroupsubset', 'branchmap']
81 if self.ui.configbool('server', 'uncompressed'):
90 if self.ui.configbool('server', 'uncompressed'):
82 caps.append('stream=%d' % self.repo.changelog.version)
91 caps.append('stream=%d' % self.repo.changelog.version)
83 self.respond("capabilities: %s\n" % (' '.join(caps),))
92 self.respond("capabilities: %s\n" % (' '.join(caps),))
@@ -848,7 +848,7 b' graph.render(data);'
848 % capabilities
848 % capabilities
849 200 Script output follows
849 200 Script output follows
850
850
851 lookup changegroupsubset unbundle=HG10GZ,HG10BZ,HG10UN% heads
851 lookup changegroupsubset branchmap unbundle=HG10GZ,HG10BZ,HG10UN% heads
852 200 Script output follows
852 200 Script output follows
853
853
854 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe
854 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe
General Comments 0
You need to be logged in to leave comments. Login now