History

[protocol #145] Unify the `previous` and `previous_result` parameters…

…to be called `previous_response` instead.

Sebastian Thiel committed 5 years ago

Commit 96f77c71 parent 8dfc9434 files · +42 −34Browse files

Unified · Split

4 files
  1. git-protocol/src/fetch/delegate.rs +30 −22
  2. git-protocol/tests/fetch/mod.rs +6 −6
  3. gitoxide-core/src/pack/receive.rs +3 −3
  4. gitoxide-core/src/remote.rs +3 −3
git-protocol/src/fetch/delegate.rs+30−22
@@ -81,10 +81,10 @@ pub trait DelegateBlocking { · 80 unmodified lines
81 81
82 /// A method called repeatedly to negotiate the objects to receive in [`receive_pack(…)`][Delegate::receive_pack()].82 /// A method called repeatedly to negotiate the objects to receive in [`receive_pack(…)`][Delegate::receive_pack()].
83 ///83 ///
84 /// The first call has `previous` set to `None` as there was no previous response. Every call that follows `previous`84 /// The first call has `previous_response` set to `None` as there was no previous response. Every call that follows `previous_response`
85 /// will be set to `Some`.85 /// will be set to `Some`.
86 ///86 ///
87 /// ### If `previous` is `None`…87 /// ### If `previous_response` is `None`…
88 ///88 ///
89 /// Given a list of `arguments` to populate with wants, want-refs, shallows, filters and other contextual information to be89 /// Given a list of `arguments` to populate with wants, want-refs, shallows, filters and other contextual information to be
90 /// sent to the server. This method is called once.90 /// sent to the server. This method is called once.
@@ -97,17 +97,21 @@ pub trait DelegateBlocking { · 6 unmodified lines
97 /// Return `Action::Close` if you know that there are no `haves` on your end to allow the server to send all of its objects97 /// Return `Action::Close` if you know that there are no `haves` on your end to allow the server to send all of its objects
98 /// as is the case during initial clones.98 /// as is the case during initial clones.
99 ///99 ///
100 /// ### If `previous` is `Some`…100 /// ### If `previous_response` is `Some`…
101 ///101 ///
102 /// Populate `arguments` with the objects you `have` starting from the tips of _your_ refs, taking into consideration102 /// Populate `arguments` with the objects you `have` starting from the tips of _your_ refs, taking into consideration
103 /// the `previous` response of the server to see which objects they acknowledged to have. You have to maintain103 /// the `previous_response` response of the server to see which objects they acknowledged to have. You have to maintain
104 /// enough state to be able to walk down from your tips on each call, if they are not in common, and keep setting `have`104 /// enough state to be able to walk down from your tips on each call, if they are not in common, and keep setting `have`
105 /// for those which are in common if that helps teaching the server about our state and to acknowledge their existence on _their_ end.105 /// for those which are in common if that helps teaching the server about our state and to acknowledge their existence on _their_ end.
106 /// This method is called until the other side signals they are ready to send a pack.106 /// This method is called until the other side signals they are ready to send a pack.
107 /// Return `Action::Close` if you want to give up before finding a common base. This can happen if the remote repository107 /// Return `Action::Close` if you want to give up before finding a common base. This can happen if the remote repository
108 /// has radically changed so there are no bases, or they are very far in the past, causing all objects to be sent.108 /// has radically changed so there are no bases, or they are very far in the past, causing all objects to be sent.
109 fn negotiate(&mut self, refs: &[Ref], arguments: &mut Arguments, previous: Option<&Response>)109 fn negotiate(
110 -> io::Result<Action>;110 &mut self,
111 refs: &[Ref],
112 arguments: &mut Arguments,
113 previous_response: Option<&Response>,
114 ) -> io::Result<Action>;
111 115
112 /// Return true if the server should be informed that the operation is completed and no further commands will be issued116 /// Return true if the server should be informed that the operation is completed and no further commands will be issued
113 /// at the end of the fetch operation.117 /// at the end of the fetch operation.
@@ -151,9 +155,9 @@ impl<T: DelegateBlocking> DelegateBlocking for Box<T> { · 37 unmodified lines
151 &mut self,155 &mut self,
152 refs: &[Ref],156 refs: &[Ref],
153 arguments: &mut Arguments,157 arguments: &mut Arguments,
154 previous: Option<&Response>,158 previous_response: Option<&Response>,
155 ) -> io::Result<Action> {159 ) -> io::Result<Action> {
156 self.deref_mut().negotiate(refs, arguments, previous)160 self.deref_mut().negotiate(refs, arguments, previous_response)
157 }161 }
158}162}
159 163
@@ -185,9 +189,9 @@ impl<T: DelegateBlocking> DelegateBlocking for &mut T { · 25 unmodified lines
185 &mut self,189 &mut self,
186 refs: &[Ref],190 refs: &[Ref],
187 arguments: &mut Arguments,191 arguments: &mut Arguments,
188 previous: Option<&Response>,192 previous_response: Option<&Response>,
189 ) -> io::Result<Action> {193 ) -> io::Result<Action> {
190 self.deref_mut().negotiate(refs, arguments, previous)194 self.deref_mut().negotiate(refs, arguments, previous_response)
191 }195 }
192}196}
193 197
@@ -212,14 +216,14 @@ mod blocking_io { · 18 unmodified lines
212 ///216 ///
213 /// Use `progress` to emit your own progress messages when decoding the pack.217 /// Use `progress` to emit your own progress messages when decoding the pack.
214 ///218 ///
215 /// `refs` of the remote side are provided for convenience, along with the parsed `previous` response in case you want219 /// `refs` of the remote side are provided for convenience, along with the parsed `previous_response` response in case you want
216 /// to check additional acks.220 /// to check additional acks.
217 fn receive_pack(221 fn receive_pack(
218 &mut self,222 &mut self,
219 input: impl io::BufRead,223 input: impl io::BufRead,
220 progress: impl Progress,224 progress: impl Progress,
221 refs: &[Ref],225 refs: &[Ref],
222 previous: &Response,226 previous_response: &Response,
223 ) -> io::Result<()>;227 ) -> io::Result<()>;
224 }228 }
225 229
@@ -229,9 +233,9 @@ mod blocking_io { · 3 unmodified lines
229 input: impl BufRead,233 input: impl BufRead,
230 progress: impl Progress,234 progress: impl Progress,
231 refs: &[Ref],235 refs: &[Ref],
232 previous: &Response,236 previous_response: &Response,
233 ) -> io::Result<()> {237 ) -> io::Result<()> {
234 self.deref_mut().receive_pack(input, progress, refs, previous)238 self.deref_mut().receive_pack(input, progress, refs, previous_response)
235 }239 }
236 }240 }
237 241
@@ -241,9 +245,9 @@ mod blocking_io { · 3 unmodified lines
241 input: impl BufRead,245 input: impl BufRead,
242 progress: impl Progress,246 progress: impl Progress,
243 refs: &[Ref],247 refs: &[Ref],
244 previous: &Response,248 previous_response: &Response,
245 ) -> io::Result<()> {249 ) -> io::Result<()> {
246 self.deref_mut().receive_pack(input, progress, refs, previous)250 self.deref_mut().receive_pack(input, progress, refs, previous_response)
247 }251 }
248 }252 }
249}253}
@@ -272,14 +276,14 @@ mod async_io { · 22 unmodified lines
272 ///276 ///
273 /// Use `progress` to emit your own progress messages when decoding the pack.277 /// Use `progress` to emit your own progress messages when decoding the pack.
274 ///278 ///
275 /// `refs` of the remote side are provided for convenience, along with the parsed `previous` response in case you want279 /// `refs` of the remote side are provided for convenience, along with the parsed `previous_response` response in case you want
276 /// to check additional acks.280 /// to check additional acks.
277 async fn receive_pack(281 async fn receive_pack(
278 &mut self,282 &mut self,
279 input: impl AsyncBufRead + Unpin + 'async_trait,283 input: impl AsyncBufRead + Unpin + 'async_trait,
280 progress: impl Progress,284 progress: impl Progress,
281 refs: &[Ref],285 refs: &[Ref],
282 previous: &Response,286 previous_response: &Response,
283 ) -> io::Result<()>;287 ) -> io::Result<()>;
284 }288 }
285 #[async_trait(?Send)]289 #[async_trait(?Send)]
@@ -289,9 +293,11 @@ mod async_io { · 3 unmodified lines
289 input: impl AsyncBufRead + Unpin + 'async_trait,293 input: impl AsyncBufRead + Unpin + 'async_trait,
290 progress: impl Progress,294 progress: impl Progress,
291 refs: &[Ref],295 refs: &[Ref],
292 previous: &Response,296 previous_response: &Response,
293 ) -> io::Result<()> {297 ) -> io::Result<()> {
294 self.deref_mut().receive_pack(input, progress, refs, previous).await298 self.deref_mut()
299 .receive_pack(input, progress, refs, previous_response)
300 .await
295 }301 }
296 }302 }
297 303
@@ -302,9 +308,11 @@ mod async_io { · 4 unmodified lines
302 input: impl AsyncBufRead + Unpin + 'async_trait,308 input: impl AsyncBufRead + Unpin + 'async_trait,
303 progress: impl Progress,309 progress: impl Progress,
304 refs: &[Ref],310 refs: &[Ref],
305 previous: &Response,311 previous_response: &Response,
306 ) -> io::Result<()> {312 ) -> io::Result<()> {
307 self.deref_mut().receive_pack(input, progress, refs, previous).await313 self.deref_mut()
314 .receive_pack(input, progress, refs, previous_response)
315 .await
308 }316 }
309 }317 }
310}318}
git-protocol/tests/fetch/mod.rs+6−6
@@ -34,7 +34,7 @@ impl fetch::DelegateBlocking for CloneDelegate { · 33 unmodified lines
34 &mut self,34 &mut self,
35 refs: &[Ref],35 refs: &[Ref],
36 arguments: &mut Arguments,36 arguments: &mut Arguments,
37 _previous_result: Option<&Response>,37 _previous_response: Option<&Response>,
38 ) -> io::Result<Action> {38 ) -> io::Result<Action> {
39 for r in refs {39 for r in refs {
40 arguments.want(r.unpack().1);40 arguments.want(r.unpack().1);
@@ -125,7 +125,7 @@ impl fetch::DelegateBlocking for LsRemoteDelegate { · 84 unmodified lines
125 &mut self,125 &mut self,
126 _refs: &[Ref],126 _refs: &[Ref],
127 _arguments: &mut Arguments,127 _arguments: &mut Arguments,
128 _previous_result: Option<&Response>,128 _previous_response: Option<&Response>,
129 ) -> io::Result<Action> {129 ) -> io::Result<Action> {
130 unreachable!("this must not be called after closing the connection in `prepare_fetch(…)`")130 unreachable!("this must not be called after closing the connection in `prepare_fetch(…)`")
131 }131 }
@@ -147,7 +147,7 @@ mod blocking_io { · 15 unmodified lines
147 mut input: impl io::BufRead,147 mut input: impl io::BufRead,
148 _progress: impl Progress,148 _progress: impl Progress,
149 _refs: &[Ref],149 _refs: &[Ref],
150 _previous: &Response,150 _previous_response: &Response,
151 ) -> io::Result<()> {151 ) -> io::Result<()> {
152 self.pack_bytes = io::copy(&mut input, &mut io::sink())? as usize;152 self.pack_bytes = io::copy(&mut input, &mut io::sink())? as usize;
153 Ok(())153 Ok(())
@@ -179,7 +179,7 @@ mod blocking_io { · 25 unmodified lines
179 _input: impl io::BufRead,179 _input: impl io::BufRead,
180 _progress: impl Progress,180 _progress: impl Progress,
181 _refs: &[Ref],181 _refs: &[Ref],
182 _previous: &Response,182 _previous_response: &Response,
183 ) -> io::Result<()> {183 ) -> io::Result<()> {
184 unreachable!("Should not be called for ls-refs");184 unreachable!("Should not be called for ls-refs");
185 }185 }
@@ -205,7 +205,7 @@ mod async_io { · 19 unmodified lines
205 mut input: impl AsyncBufRead + Unpin + 'async_trait,205 mut input: impl AsyncBufRead + Unpin + 'async_trait,
206 _progress: impl Progress,206 _progress: impl Progress,
207 _refs: &[Ref],207 _refs: &[Ref],
208 _previous: &Response,208 _previous_response: &Response,
209 ) -> io::Result<()> {209 ) -> io::Result<()> {
210 self.pack_bytes = futures_lite::io::copy(&mut input, &mut futures_lite::io::sink()).await? as usize;210 self.pack_bytes = futures_lite::io::copy(&mut input, &mut futures_lite::io::sink()).await? as usize;
211 Ok(())211 Ok(())
@@ -239,7 +239,7 @@ mod async_io { · 27 unmodified lines
239 _input: impl AsyncBufRead + Unpin + 'async_trait,239 _input: impl AsyncBufRead + Unpin + 'async_trait,
240 _progress: impl Progress,240 _progress: impl Progress,
241 _refs: &[Ref],241 _refs: &[Ref],
242 _previous: &Response,242 _previous_response: &Response,
243 ) -> io::Result<()> {243 ) -> io::Result<()> {
244 unreachable!("Should not be called for ls-refs");244 unreachable!("Should not be called for ls-refs");
245 }245 }
gitoxide-core/src/pack/receive.rs+3−3
@@ -59,7 +59,7 @@ impl<W> protocol::fetch::DelegateBlocking for CloneDelegate<W> { · 58 unmodified lines
59 &mut self,59 &mut self,
60 refs: &[Ref],60 refs: &[Ref],
61 arguments: &mut Arguments,61 arguments: &mut Arguments,
62 _previous: Option<&Response>,62 _previous_response: Option<&Response>,
63 ) -> io::Result<Action> {63 ) -> io::Result<Action> {
64 for r in refs {64 for r in refs {
65 let (path, id) = r.unpack();65 let (path, id) = r.unpack();
@@ -97,7 +97,7 @@ mod blocking_io { · 31 unmodified lines
97 input: impl BufRead,97 input: impl BufRead,
98 progress: impl Progress,98 progress: impl Progress,
99 refs: &[Ref],99 refs: &[Ref],
100 _previous: &Response,100 _previous_response: &Response,
101 ) -> io::Result<()> {101 ) -> io::Result<()> {
102 let options = pack::bundle::write::Options {102 let options = pack::bundle::write::Options {
103 thread_limit: self.ctx.thread_limit,103 thread_limit: self.ctx.thread_limit,
@@ -188,7 +188,7 @@ mod async_io { · 84 unmodified lines
188 input: impl AsyncBufRead + Unpin + 'async_trait,188 input: impl AsyncBufRead + Unpin + 'async_trait,
189 progress: impl Progress,189 progress: impl Progress,
190 refs: &[Ref],190 refs: &[Ref],
191 _previous: &Response,191 _previous_response: &Response,
192 ) -> io::Result<()> {192 ) -> io::Result<()> {
193 let options = pack::bundle::write::Options {193 let options = pack::bundle::write::Options {
194 thread_limit: self.ctx.thread_limit,194 thread_limit: self.ctx.thread_limit,
gitoxide-core/src/remote.rs+3−3
@@ -33,7 +33,7 @@ pub mod refs { · 32 unmodified lines
33 &mut self,33 &mut self,
34 _refs: &[Ref],34 _refs: &[Ref],
35 _arguments: &mut Arguments,35 _arguments: &mut Arguments,
36 _previous_result: Option<&Response>,36 _previous_response: Option<&Response>,
37 ) -> io::Result<Action> {37 ) -> io::Result<Action> {
38 unreachable!("not to be called due to Action::Close in `prepare_fetch`")38 unreachable!("not to be called due to Action::Close in `prepare_fetch`")
39 }39 }
@@ -59,7 +59,7 @@ pub mod refs { · 19 unmodified lines
59 input: impl AsyncBufRead + Unpin + 'async_trait,59 input: impl AsyncBufRead + Unpin + 'async_trait,
60 progress: impl Progress,60 progress: impl Progress,
61 refs: &[Ref],61 refs: &[Ref],
62 previous: &Response,62 previous_response: &Response,
63 ) -> io::Result<()> {63 ) -> io::Result<()> {
64 unreachable!("not called for ls-refs")64 unreachable!("not called for ls-refs")
65 }65 }
@@ -119,7 +119,7 @@ pub mod refs { · 53 unmodified lines
119 _input: impl io::BufRead,119 _input: impl io::BufRead,
120 _progress: impl Progress,120 _progress: impl Progress,
121 _refs: &[Ref],121 _refs: &[Ref],
122 _previous: &Response,122 _previous_response: &Response,
123 ) -> io::Result<()> {123 ) -> io::Result<()> {
124 unreachable!("not called for ls-refs")124 unreachable!("not called for ls-refs")
125 }125 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t