def check_heads(repo, their_heads, context): """check if the heads of a repo have been modified Used by peer for unbundling. """ heads = repo.heads() heads_hash = util.sha1(''.join(sorted(heads))).digest() if not (their_heads == ['force'] or their_heads == heads or their_heads == ['hashed', heads_hash]): # someone else committed/pushed/unbundled while we # were transferring data raise error.PushRaced('repository changed while %s - ' 'please try again' % context)
def handlechangegroup(op, inpart): """check that head of the repo did not change This is used to detect a push race when using unbundle. This replaces the "heads" argument of unbundle.""" h = inpart.read(20) heads = [] while len(h) == 20: heads.append(h) h = inpart.read(20) assert not h if heads != op.repo.heads(): raise error.PushRaced('repository changed while pushing - ' 'please try again')