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
8181
8282 /// A method called repeatedly to negotiate the objects to receive in [`receive_pack(…)`][Delegate::receive_pack()].
8383 ///
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`
8585 /// will be set to `Some`.
8686 ///
87− /// ### If `previous` is `None`…
87+ /// ### If `previous_response` is `None`…
8888 ///
8989 /// Given a list of `arguments` to populate with wants, want-refs, shallows, filters and other contextual information to be
9090 /// sent to the server. This method is called once.
@@ -97,17 +97,21 @@ pub trait DelegateBlocking { · 6 unmodified lines
9797 /// Return `Action::Close` if you know that there are no `haves` on your end to allow the server to send all of its objects
9898 /// as is the case during initial clones.
9999 ///
100− /// ### If `previous` is `Some`…
100+ /// ### If `previous_response` is `Some`…
101101 ///
102102 /// 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 maintain
103+ /// the `previous_response` response of the server to see which objects they acknowledged to have. You have to maintain
104104 /// enough state to be able to walk down from your tips on each call, if they are not in common, and keep setting `have`
105105 /// for those which are in common if that helps teaching the server about our state and to acknowledge their existence on _their_ end.
106106 /// This method is called until the other side signals they are ready to send a pack.
107107 /// Return `Action::Close` if you want to give up before finding a common base. This can happen if the remote repository
108108 /// 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>)
110− -> io::Result<Action>;
109+ fn negotiate(
110+ &mut self,
111+ refs: &[Ref],
112+ arguments: &mut Arguments,
113+ previous_response: Option<&Response>,
114+ ) -> io::Result<Action>;
111115
112116 /// Return true if the server should be informed that the operation is completed and no further commands will be issued
113117 /// at the end of the fetch operation.
@@ -151,9 +155,9 @@ impl<T: DelegateBlocking> DelegateBlocking for Box<T> { · 37 unmodified lines
151155 &mut self,
152156 refs: &[Ref],
153157 arguments: &mut Arguments,
154− previous: Option<&Response>,
158+ previous_response: Option<&Response>,
155159 ) -> io::Result<Action> {
156− self.deref_mut().negotiate(refs, arguments, previous)
160+ self.deref_mut().negotiate(refs, arguments, previous_response)
157161 }
158162 }
159163
@@ -185,9 +189,9 @@ impl<T: DelegateBlocking> DelegateBlocking for &mut T { · 25 unmodified lines
185189 &mut self,
186190 refs: &[Ref],
187191 arguments: &mut Arguments,
188− previous: Option<&Response>,
192+ previous_response: Option<&Response>,
189193 ) -> io::Result<Action> {
190− self.deref_mut().negotiate(refs, arguments, previous)
194+ self.deref_mut().negotiate(refs, arguments, previous_response)
191195 }
192196 }
193197
@@ -212,14 +216,14 @@ mod blocking_io { · 18 unmodified lines
212216 ///
213217 /// Use `progress` to emit your own progress messages when decoding the pack.
214218 ///
215− /// `refs` of the remote side are provided for convenience, along with the parsed `previous` response in case you want
219+ /// `refs` of the remote side are provided for convenience, along with the parsed `previous_response` response in case you want
216220 /// to check additional acks.
217221 fn receive_pack(
218222 &mut self,
219223 input: impl io::BufRead,
220224 progress: impl Progress,
221225 refs: &[Ref],
222− previous: &Response,
226+ previous_response: &Response,
223227 ) -> io::Result<()>;
224228 }
225229
@@ -229,9 +233,9 @@ mod blocking_io { · 3 unmodified lines
229233 input: impl BufRead,
230234 progress: impl Progress,
231235 refs: &[Ref],
232− previous: &Response,
236+ previous_response: &Response,
233237 ) -> io::Result<()> {
234− self.deref_mut().receive_pack(input, progress, refs, previous)
238+ self.deref_mut().receive_pack(input, progress, refs, previous_response)
235239 }
236240 }
237241
@@ -241,9 +245,9 @@ mod blocking_io { · 3 unmodified lines
241245 input: impl BufRead,
242246 progress: impl Progress,
243247 refs: &[Ref],
244− previous: &Response,
248+ previous_response: &Response,
245249 ) -> io::Result<()> {
246− self.deref_mut().receive_pack(input, progress, refs, previous)
250+ self.deref_mut().receive_pack(input, progress, refs, previous_response)
247251 }
248252 }
249253 }
@@ -272,14 +276,14 @@ mod async_io { · 22 unmodified lines
272276 ///
273277 /// Use `progress` to emit your own progress messages when decoding the pack.
274278 ///
275− /// `refs` of the remote side are provided for convenience, along with the parsed `previous` response in case you want
279+ /// `refs` of the remote side are provided for convenience, along with the parsed `previous_response` response in case you want
276280 /// to check additional acks.
277281 async fn receive_pack(
278282 &mut self,
279283 input: impl AsyncBufRead + Unpin + 'async_trait,
280284 progress: impl Progress,
281285 refs: &[Ref],
282− previous: &Response,
286+ previous_response: &Response,
283287 ) -> io::Result<()>;
284288 }
285289 #[async_trait(?Send)]
@@ -289,9 +293,11 @@ mod async_io { · 3 unmodified lines
289293 input: impl AsyncBufRead + Unpin + 'async_trait,
290294 progress: impl Progress,
291295 refs: &[Ref],
292− previous: &Response,
296+ previous_response: &Response,
293297 ) -> io::Result<()> {
294− self.deref_mut().receive_pack(input, progress, refs, previous).await
298+ self.deref_mut()
299+ .receive_pack(input, progress, refs, previous_response)
300+ .await
295301 }
296302 }
297303
@@ -302,9 +308,11 @@ mod async_io { · 4 unmodified lines
302308 input: impl AsyncBufRead + Unpin + 'async_trait,
303309 progress: impl Progress,
304310 refs: &[Ref],
305− previous: &Response,
311+ previous_response: &Response,
306312 ) -> io::Result<()> {
307− self.deref_mut().receive_pack(input, progress, refs, previous).await
313+ self.deref_mut()
314+ .receive_pack(input, progress, refs, previous_response)
315+ .await
308316 }
309317 }
310318 }
git-protocol/tests/fetch/mod.rs+6−6
@@ -34,7 +34,7 @@ impl fetch::DelegateBlocking for CloneDelegate { · 33 unmodified lines
3434 &mut self,
3535 refs: &[Ref],
3636 arguments: &mut Arguments,
37− _previous_result: Option<&Response>,
37+ _previous_response: Option<&Response>,
3838 ) -> io::Result<Action> {
3939 for r in refs {
4040 arguments.want(r.unpack().1);
@@ -125,7 +125,7 @@ impl fetch::DelegateBlocking for LsRemoteDelegate { · 84 unmodified lines
125125 &mut self,
126126 _refs: &[Ref],
127127 _arguments: &mut Arguments,
128− _previous_result: Option<&Response>,
128+ _previous_response: Option<&Response>,
129129 ) -> io::Result<Action> {
130130 unreachable!("this must not be called after closing the connection in `prepare_fetch(…)`")
131131 }
@@ -147,7 +147,7 @@ mod blocking_io { · 15 unmodified lines
147147 mut input: impl io::BufRead,
148148 _progress: impl Progress,
149149 _refs: &[Ref],
150− _previous: &Response,
150+ _previous_response: &Response,
151151 ) -> io::Result<()> {
152152 self.pack_bytes = io::copy(&mut input, &mut io::sink())? as usize;
153153 Ok(())
@@ -179,7 +179,7 @@ mod blocking_io { · 25 unmodified lines
179179 _input: impl io::BufRead,
180180 _progress: impl Progress,
181181 _refs: &[Ref],
182− _previous: &Response,
182+ _previous_response: &Response,
183183 ) -> io::Result<()> {
184184 unreachable!("Should not be called for ls-refs");
185185 }
@@ -205,7 +205,7 @@ mod async_io { · 19 unmodified lines
205205 mut input: impl AsyncBufRead + Unpin + 'async_trait,
206206 _progress: impl Progress,
207207 _refs: &[Ref],
208− _previous: &Response,
208+ _previous_response: &Response,
209209 ) -> io::Result<()> {
210210 self.pack_bytes = futures_lite::io::copy(&mut input, &mut futures_lite::io::sink()).await? as usize;
211211 Ok(())
@@ -239,7 +239,7 @@ mod async_io { · 27 unmodified lines
239239 _input: impl AsyncBufRead + Unpin + 'async_trait,
240240 _progress: impl Progress,
241241 _refs: &[Ref],
242− _previous: &Response,
242+ _previous_response: &Response,
243243 ) -> io::Result<()> {
244244 unreachable!("Should not be called for ls-refs");
245245 }
gitoxide-core/src/pack/receive.rs+3−3
@@ -59,7 +59,7 @@ impl<W> protocol::fetch::DelegateBlocking for CloneDelegate<W> { · 58 unmodified lines
5959 &mut self,
6060 refs: &[Ref],
6161 arguments: &mut Arguments,
62− _previous: Option<&Response>,
62+ _previous_response: Option<&Response>,
6363 ) -> io::Result<Action> {
6464 for r in refs {
6565 let (path, id) = r.unpack();
@@ -97,7 +97,7 @@ mod blocking_io { · 31 unmodified lines
9797 input: impl BufRead,
9898 progress: impl Progress,
9999 refs: &[Ref],
100− _previous: &Response,
100+ _previous_response: &Response,
101101 ) -> io::Result<()> {
102102 let options = pack::bundle::write::Options {
103103 thread_limit: self.ctx.thread_limit,
@@ -188,7 +188,7 @@ mod async_io { · 84 unmodified lines
188188 input: impl AsyncBufRead + Unpin + 'async_trait,
189189 progress: impl Progress,
190190 refs: &[Ref],
191− _previous: &Response,
191+ _previous_response: &Response,
192192 ) -> io::Result<()> {
193193 let options = pack::bundle::write::Options {
194194 thread_limit: self.ctx.thread_limit,
gitoxide-core/src/remote.rs+3−3
@@ -33,7 +33,7 @@ pub mod refs { · 32 unmodified lines
3333 &mut self,
3434 _refs: &[Ref],
3535 _arguments: &mut Arguments,
36− _previous_result: Option<&Response>,
36+ _previous_response: Option<&Response>,
3737 ) -> io::Result<Action> {
3838 unreachable!("not to be called due to Action::Close in `prepare_fetch`")
3939 }
@@ -59,7 +59,7 @@ pub mod refs { · 19 unmodified lines
5959 input: impl AsyncBufRead + Unpin + 'async_trait,
6060 progress: impl Progress,
6161 refs: &[Ref],
62− previous: &Response,
62+ previous_response: &Response,
6363 ) -> io::Result<()> {
6464 unreachable!("not called for ls-refs")
6565 }
@@ -119,7 +119,7 @@ pub mod refs { · 53 unmodified lines
119119 _input: impl io::BufRead,
120120 _progress: impl Progress,
121121 _refs: &[Ref],
122− _previous: &Response,
122+ _previous_response: &Response,
123123 ) -> io::Result<()> {
124124 unreachable!("not called for ls-refs")
125125 }

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