Mercurial > hg
changeset 21060:0bea9db7543b
bundle2: add a "check:heads" handler
This part is intended to hold the same role as the `heads` argument of the
unbundle function. The client fill it with the known heads at bundle time and
the server will abort if its heads changed.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 11 Apr 2014 06:43:01 -0700 |
parents | d7e233df48e6 |
children | 62d35f251c60 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Sun Apr 13 16:36:51 2014 -0400 +++ b/mercurial/bundle2.py Fri Apr 11 06:43:01 2014 -0700 @@ -657,3 +657,17 @@ ret = int(p['return']) op.records.add('changegroup', {'return': ret}, int(p['in-reply-to'])) +@parthandler('check:heads') +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 exchange.PushRaced()