211 ''' changeset_printer has some logic around buffering data |
211 ''' changeset_printer has some logic around buffering data |
212 in self.headers that we don't use |
212 in self.headers that we don't use |
213 ''' |
213 ''' |
214 pass |
214 pass |
215 |
215 |
216 def patchavailable(node, repo, successors): |
216 def patchavailable(node, repo, candidates, successive=True): |
217 if node not in repo: |
217 if node not in repo: |
218 return False, b"context is not local" |
218 return False, b"context is not local" |
219 |
219 |
220 if len(successors) == 0: |
220 if len(candidates) == 0: |
221 return False, b"no successors" |
221 if successive: |
222 elif len(successors) > 1: |
222 msg = b"no successors" |
223 return False, b"too many successors (%d)" % len(successors) |
223 else: |
224 |
224 msg = b"no predecessors" |
225 succ = successors[0] |
225 return False, msg |
226 |
226 elif len(candidates) > 1: |
227 if succ not in repo: |
227 if successive: |
228 return False, b"successor is unknown locally" |
228 msg = b"too many successors (%d)" |
229 |
229 else: |
230 # Check that both node and succ have the same parents |
230 msg = b"too many predecessors (%d)" |
|
231 return False, msg % len(candidates) |
|
232 |
|
233 cand = candidates[0] |
|
234 |
|
235 if cand not in repo: |
|
236 if successive: |
|
237 msg = b"successor is unknown locally" |
|
238 else: |
|
239 msg = b"predecessor is unknown locally" |
|
240 return False, msg |
|
241 |
|
242 # Check that both node and cand have the same parents |
231 nodep1, nodep2 = repo[node].p1(), repo[node].p2() |
243 nodep1, nodep2 = repo[node].p1(), repo[node].p2() |
232 succp1, succp2 = repo[succ].p1(), repo[succ].p2() |
244 candp1, candp2 = repo[cand].p1(), repo[cand].p2() |
233 |
245 |
234 if nodep1 != succp1 or nodep2 != succp2: |
246 if nodep1 != candp1 or nodep2 != candp2: |
235 return False, b"changesets rebased" |
247 return False, b"changesets rebased" |
236 |
248 |
237 return True, succ |
249 return True, cand |
238 |
250 |
239 def getmarkerdescriptionpatch(repo, basedesc, succdesc): |
251 def getmarkerdescriptionpatch(repo, basedesc, succdesc): |
240 # description are stored without final new line, |
252 # description are stored without final new line, |
241 # add one to avoid ugly diff |
253 # add one to avoid ugly diff |
242 basedesc += b'\n' |
254 basedesc += b'\n' |