Mercurial > evolve
annotate hgext/simple4server.py @ 978:8328337d23b2
docs: add new user guide
This has also been reviewed to death on evolve-testers. There are
still a couple of short sections to write (clearly marked "TODO"), and
one example to add. But (if I may be so bold) this is a gigantic
improvement over the current docs, so it really should get merged.
Incidentally, the figures are all SVG files created with Inkscape.
They're not perfect, but they're pretty nice. Anyone who knows a
better way to create technical diagrams is welcome to contribute.
One wart: there's a test script that accompanies the document and
largely duplicates it, but I haven't unified them. I've been
concentrating on writing the best possible content, not on fiddling
with tools. I suspect that unifying them will be non-trivial, but
definitely worth doing.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Thu, 05 Jun 2014 22:11:04 -0400 |
parents | f80e8e3c3726 |
children | 5d063fed9e3d |
rev | line source |
---|---|
660
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
1 '''enable experimental obsolescence feature of Mercurial |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
2 |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
3 OBSOLESCENCE IS AN EXPERIMENTAL FEATURE MAKE SURE YOU UNDERSTOOD THE INVOLVED |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
4 CONCEPT BEFORE USING IT. |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
5 |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
6 /!\ THIS EXTENSION IS INTENDED FOR SERVER SIDE ONLY USAGE /!\ |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
7 |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
8 For client side usages it is recommended to use the evolve extension for |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
9 improved user interface.''' |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
10 |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
11 testedwith = '3.0.1' |
873
c758717ff3c7
evolve: add 2.9.1 compatibility seal to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
872
diff
changeset
|
12 buglink = 'https://bitbucket.org/marmoute/mutable-history/issues' |
c758717ff3c7
evolve: add 2.9.1 compatibility seal to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
872
diff
changeset
|
13 |
660
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
14 import mercurial.obsolete |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
15 mercurial.obsolete._enabled = True |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
16 |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
17 import struct |
872
2a2db401a55b
simple4server: fix a missing import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
869
diff
changeset
|
18 from mercurial import util |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
19 from mercurial import wireproto |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
20 from mercurial import extensions |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
21 from mercurial import obsolete |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
22 from cStringIO import StringIO |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
23 from mercurial import node |
869
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
866
diff
changeset
|
24 from mercurial.hgweb import hgweb_mod |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
25 from mercurial import bundle2 |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
26 from mercurial import localrepo |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
27 from mercurial import exchange |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
28 _pack = struct.pack |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
29 |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
30 gboptslist = gboptsmap = None |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
31 try: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
32 from mercurial import obsolete |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
33 if not obsolete._enabled: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
34 obsolete._enabled = True |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
35 from mercurial import wireproto |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
36 gboptslist = getattr(wireproto, 'gboptslist', None) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
37 gboptsmap = getattr(wireproto, 'gboptsmap', None) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
38 except (ImportError, AttributeError): |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
39 raise util.Abort('Your Mercurial is too old for this version of Evolve\n' |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
40 'requires version 3.0.1 or above') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
41 |
882
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
42 # Start of simple4server specific content |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
43 |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
44 from mercurial import pushkey |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
45 |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
46 # specific content also include the wrapping int extsetup |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
47 def _nslist(orig, repo): |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
48 rep = orig(repo) |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
49 if not repo.ui.configbool('__temporary__', 'advertiseobsolete', True): |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
50 rep.pop('obsolete') |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
51 return rep |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
52 |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
53 # End of simple4server specific content |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
54 |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
55 |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
56 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
57 # from evolve extension: 1a23c7c52a43 |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
58 def srv_pushobsmarkers(repo, proto): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
59 """That receives a stream of markers and apply then to the repo""" |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
60 fp = StringIO() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
61 proto.redirect() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
62 proto.getfile(fp) |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
63 data = fp.getvalue() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
64 fp.close() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
65 lock = repo.lock() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
66 try: |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
67 tr = repo.transaction('pushkey: obsolete markers') |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
68 try: |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
69 repo.obsstore.mergemarkers(tr, data) |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
70 tr.close() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
71 finally: |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
72 tr.release() |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
73 finally: |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
74 lock.release() |
888
097ddcb0da25
evolve: add a hook related to the new pushobsmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
884
diff
changeset
|
75 repo.hook('evolve_pushobsmarkers') |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
76 return wireproto.pushres(0) |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
77 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
78 # from mercurial.obsolete: 19e9478c1a22 |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
79 def _encodemarkersstream(fp, markers): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
80 """write a binary version of a set of markers |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
81 |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
82 Includes the initial version number""" |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
83 fp.write(_pack('>B', 0)) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
84 for mark in markers: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
85 fp.write(obsolete._encodeonemarker(mark)) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
86 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
87 # from evolve extension: 1a23c7c52a43 |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
88 def _getobsmarkersstream(repo, heads=None, common=None): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
89 """Get a binary stream for all markers relevant to `::<heads> - ::<common>` |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
90 """ |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
91 revset = '' |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
92 args = [] |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
93 repo = repo.unfiltered() |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
94 if heads is None: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
95 revset = 'all()' |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
96 elif heads: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
97 revset += "(::%ln)" |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
98 args.append(heads) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
99 else: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
100 assert False, 'pulling no heads?' |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
101 if common: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
102 revset += ' - (::%ln)' |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
103 args.append(common) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
104 nodes = [c.node() for c in repo.set(revset, *args)] |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
105 markers = repo.obsstore.relevantmarkers(nodes) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
106 obsdata = StringIO() |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
107 _encodemarkersstream(obsdata, markers) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
108 obsdata.seek(0) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
109 return obsdata |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
110 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
111 # from evolve extension: 1a23c7c52a43 |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
112 class pruneobsstore(obsolete.obsstore): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
113 """And extended obsstore class that read parent information from v1 format |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
114 |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
115 Evolve extension adds parent information in prune marker. We use it to make |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
116 markers relevant to pushed changeset.""" |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
117 |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
118 def __init__(self, *args, **kwargs): |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
119 self.prunedchildren = {} |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
120 return super(pruneobsstore, self).__init__(*args, **kwargs) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
121 |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
122 def _load(self, markers): |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
123 markers = self._prunedetectingmarkers(markers) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
124 return super(pruneobsstore, self)._load(markers) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
125 |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
126 |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
127 def _prunedetectingmarkers(self, markers): |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
128 for m in markers: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
129 if not m[1]: # no successors |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
130 meta = obsolete.decodemeta(m[3]) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
131 if 'p1' in meta: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
132 p1 = node.bin(meta['p1']) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
133 self.prunedchildren.setdefault(p1, set()).add(m) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
134 if 'p2' in meta: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
135 p2 = node.bin(meta['p2']) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
136 self.prunedchildren.setdefault(p2, set()).add(m) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
137 yield m |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
138 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
139 # from evolve extension: 1a23c7c52a43 |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
140 def relevantmarkers(self, nodes): |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
141 """return a set of all obsolescence marker relevant to a set of node. |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
142 |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
143 "relevant" to a set of node mean: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
144 |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
145 - marker that use this changeset as successors |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
146 - prune marker of direct children on this changeset. |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
147 - recursive application of the two rules on precursors of these markers |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
148 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
149 It is a set so you cannot rely on order""" |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
150 seennodes = set(nodes) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
151 seenmarkers = set() |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
152 pendingnodes = set(nodes) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
153 precursorsmarkers = self.precursors |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
154 prunedchildren = self.prunedchildren |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
155 while pendingnodes: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
156 direct = set() |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
157 for current in pendingnodes: |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
158 direct.update(precursorsmarkers.get(current, ())) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
159 direct.update(prunedchildren.get(current, ())) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
160 direct -= seenmarkers |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
161 pendingnodes = set([m[0] for m in direct]) |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
162 seenmarkers |= direct |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
163 pendingnodes -= seennodes |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
164 seennodes |= pendingnodes |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
165 return seenmarkers |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
166 |
878
5cb2744a6d36
simple4server: update "from <changeset>" statement
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
877
diff
changeset
|
167 # from evolve extension: cf35f38d6a10 |
826
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
168 def srv_pullobsmarkers(repo, proto, others): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
169 """serves a binary stream of markers. |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
170 |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
171 Serves relevant to changeset between heads and common. The stream is prefix |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
172 by a -string- representation of an integer. This integer is the size of the |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
173 stream.""" |
826
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
174 opts = wireproto.options('', ['heads', 'common'], others) |
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
175 for k, v in opts.iteritems(): |
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
176 if k in ('heads', 'common'): |
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
177 opts[k] = wireproto.decodelist(v) |
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
178 obsdata = _getobsmarkersstream(repo, **opts) |
877
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
876
diff
changeset
|
179 finaldata = StringIO() |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
876
diff
changeset
|
180 obsdata = obsdata.getvalue() |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
876
diff
changeset
|
181 finaldata.write('%20i' % len(obsdata)) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
876
diff
changeset
|
182 finaldata.write(obsdata) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
876
diff
changeset
|
183 finaldata.seek(0) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
876
diff
changeset
|
184 return wireproto.streamres(proto.groupchunks(finaldata)) |
826
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
185 |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
186 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
187 # from evolve extension: 1a23c7c52a43 |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
188 def _obsrelsethashtree(repo): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
189 """Build an obshash for every node in a repo |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
190 |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
191 return a [(node), (obshash)] list. in revision order.""" |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
192 cache = [] |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
193 unfi = repo.unfiltered() |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
194 for i in unfi: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
195 ctx = unfi[i] |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
196 entry = 0 |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
197 sha = util.sha1() |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
198 # add data from p1 |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
199 for p in ctx.parents(): |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
200 p = p.rev() |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
201 if p < 0: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
202 p = node.nullid |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
203 else: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
204 p = cache[p][1] |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
205 if p != node.nullid: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
206 entry += 1 |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
207 sha.update(p) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
208 tmarkers = repo.obsstore.relevantmarkers([ctx.node()]) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
209 if tmarkers: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
210 bmarkers = [obsolete._encodeonemarker(m) for m in tmarkers] |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
211 bmarkers.sort() |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
212 for m in bmarkers: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
213 entry += 1 |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
214 sha.update(m) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
215 if entry: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
216 cache.append((ctx.node(), sha.digest())) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
217 else: |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
218 cache.append((ctx.node(), node.nullid)) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
219 return cache |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
220 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
221 # from evolve extension: 1a23c7c52a43 |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
222 def _obshash(repo, nodes): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
223 """hash of binary version of relevant markers + obsparent |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
224 |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
225 (special case so that all empty are hashed as nullid)""" |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
226 hashs = _obsrelsethashtree(repo) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
227 nm = repo.changelog.nodemap |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
228 return [hashs[nm.get(n)][1] for n in nodes] |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
229 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
230 # from evolve extension: 1a23c7c52a43 |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
231 def srv_obshash(repo, proto, nodes): |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
232 """give the obshash of a a set of node |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
233 |
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
234 Used for markes discovery""" |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
235 return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes))) |
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
236 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
237 # from evolve extension: 1a23c7c52a43 |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
238 def capabilities(orig, repo, proto): |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
239 """wrapper to advertise new capability""" |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
240 caps = orig(repo, proto) |
884
4ae115cf3efd
sinmple4server: advertise new cap only when advertising obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
882
diff
changeset
|
241 advertise = repo.ui.configbool('__temporary__', 'advertiseobsolete', True) |
4ae115cf3efd
sinmple4server: advertise new cap only when advertising obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
882
diff
changeset
|
242 if obsolete._enabled and advertise: |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
243 caps += ' _evoext_pushobsmarkers_0' |
826
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
244 caps += ' _evoext_pullobsmarkers_0' |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
245 caps += ' _evoext_obshash_0' |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
246 caps += ' _evoext_b2x_obsmarkers_0' |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
247 return caps |
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
248 |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
249 |
876
8c9601a6c4e0
simple4server: update "from <changeset>" statement
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
250 # from evolve extension: 10867a8e27c6 |
874
19a7ed6384a9
simple4server: add origin and documentation to most function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
873
diff
changeset
|
251 # heavily modified |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
252 def extsetup(ui): |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
253 localrepo.moderncaps.add('_evoext_b2x_obsmarkers_0') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
254 if gboptsmap is not None: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
255 gboptsmap['evo_obsmarker'] = 'plain' |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
256 gboptsmap['evo_obscommon'] = 'plain' |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
257 gboptsmap['evo_obsheads'] = 'plain' |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
258 else: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
259 gboptslist.append('evo_obsheads') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
260 gboptslist.append('evo_obscommon') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
261 gboptslist.append('evo_obsmarker') |
852
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
262 obsolete.obsstore = pruneobsstore |
aa722de36179
exchange: fix pulling from simple for server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
826
diff
changeset
|
263 obsolete.obsstore.relevantmarkers = relevantmarkers |
869
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
866
diff
changeset
|
264 hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push' |
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
866
diff
changeset
|
265 hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull' |
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
866
diff
changeset
|
266 hgweb_mod.perms['evoext_obshash'] = 'pull' |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
267 wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '') |
826
bee5e1105e6c
exchange: add the pullmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
822
diff
changeset
|
268 wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*') |
875
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
874
diff
changeset
|
269 # wrap module content |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
270 extensions.wrapfunction(exchange, '_getbundleextrapart', _getbundleextrapart) |
822
5f5d269278e9
exchange: add the pushmarker wireproto command to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
660
diff
changeset
|
271 extensions.wrapfunction(wireproto, 'capabilities', capabilities) |
875
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
874
diff
changeset
|
272 # wrap command content |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
874
diff
changeset
|
273 oldcap, args = wireproto.commands['capabilities'] |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
874
diff
changeset
|
274 def newcap(repo, proto): |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
874
diff
changeset
|
275 return capabilities(oldcap, repo, proto) |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
874
diff
changeset
|
276 wireproto.commands['capabilities'] = (newcap, args) |
866
c6dc5822e640
simple4server: add the wireproto command for obsolescence markers discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
852
diff
changeset
|
277 wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes') |
882
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
278 # specific simple4server content |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
279 extensions.wrapfunction(pushkey, '_nslist', _nslist) |
48804a8d7472
simple4server: option to advertise obsolescence support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
878
diff
changeset
|
280 pushkey._namespaces['namespaces'] = (lambda *x: False, pushkey._nslist) |
963
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
281 |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
282 |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
283 #from evolve extension |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
284 @bundle2.parthandler('evolve:b2x:obsmarkerv1') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
285 def handleobsmarkerv1(op, inpart): |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
286 """add a stream of obsmarker to the repo""" |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
287 tr = op.gettransaction() |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
288 advparams = dict(inpart.advisoryparams) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
289 length = advparams.get('totalbytes') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
290 if length is None: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
291 obsdata = inpart.read() |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
292 else: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
293 length = int(length) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
294 data = StringIO() |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
295 current = 0 |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
296 op.ui.progress('OBSEXC', current, unit="bytes", total=length) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
297 while current < length: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
298 readsize = min(length-current, 4096) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
299 data.write(inpart.read(readsize)) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
300 current += readsize |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
301 op.ui.progress('OBSEXC', current, unit="bytes", total=length) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
302 op.ui.progress('OBSEXC', None) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
303 obsdata = data.getvalue() |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
304 totalsize = len(obsdata) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
305 old = len(op.repo.obsstore._all) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
306 op.repo.obsstore.mergemarkers(tr, obsdata) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
307 new = len(op.repo.obsstore._all) - old |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
308 op.records.add('evo_obsmarkers', {'new': new, 'bytes': totalsize}) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
309 tr.hookargs['evolve_new_obsmarkers'] = str(new) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
310 |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
311 #from evolve extension |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
312 def _getbundleextrapart(orig, bundler, repo, source, **kwargs): |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
313 if int(kwargs.pop('evo_obsmarker', False)): |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
314 common = kwargs.pop('evo_obscommon') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
315 common = wireproto.decodelist(common) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
316 heads = kwargs.pop('evo_obsheads') |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
317 heads = wireproto.decodelist(heads) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
318 obsdata = _getobsmarkersstream(repo, common=common, heads=heads) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
319 if len(obsdata.getvalue()) > 5: |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
320 advparams = [('totalbytes', str(len(obsdata.getvalue())))] |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
321 obspart = bundle2.bundlepart('EVOLVE:B2X:OBSMARKERV1', |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
322 advisoryparams=advparams, |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
323 data=obsdata) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
324 bundler.addpart(obspart) |
f80e8e3c3726
simple4server: backport the bundle2 exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
888
diff
changeset
|
325 orig(bundler, repo, source) |