Mercurial > hg
comparison mercurial/wireproto.py @ 12703:40bb5853fc4b
wireproto: introduce pusherr() to deal with "unsynced changes" error
The behaviour between http and ssh still differ:
- the "unsynced changes" is seen as a remote output in the http cases
- but it is correctly seen as a push error for ssh
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Mon, 11 Oct 2010 12:45:36 -0500 |
parents | f747c085b789 |
children | 6c375e07d673 |
comparison
equal
deleted
inserted
replaced
12702:f747c085b789 | 12703:40bb5853fc4b |
---|---|
140 | 140 |
141 class pushres(object): | 141 class pushres(object): |
142 def __init__(self, res): | 142 def __init__(self, res): |
143 self.res = res | 143 self.res = res |
144 | 144 |
145 class pusherr(object): | |
146 def __init__(self, res): | |
147 self.res = res | |
148 | |
145 def dispatch(repo, proto, command): | 149 def dispatch(repo, proto, command): |
146 func, spec = commands[command] | 150 func, spec = commands[command] |
147 args = proto.getargs(spec) | 151 args = proto.getargs(spec) |
148 return func(repo, proto, *args) | 152 return func(repo, proto, *args) |
149 | 153 |
283 | 287 |
284 proto.redirect() | 288 proto.redirect() |
285 | 289 |
286 # fail early if possible | 290 # fail early if possible |
287 if not check_heads(): | 291 if not check_heads(): |
288 return 'unsynced changes' | 292 return pusherr('unsynced changes') |
289 | 293 |
290 # write bundle data to temporary file because it can be big | 294 # write bundle data to temporary file because it can be big |
291 fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') | 295 fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') |
292 fp = os.fdopen(fd, 'wb+') | 296 fp = os.fdopen(fd, 'wb+') |
293 r = 0 | 297 r = 0 |
296 lock = repo.lock() | 300 lock = repo.lock() |
297 try: | 301 try: |
298 if not check_heads(): | 302 if not check_heads(): |
299 # someone else committed/pushed/unbundled while we | 303 # someone else committed/pushed/unbundled while we |
300 # were transferring data | 304 # were transferring data |
301 return 'unsynced changes' | 305 return pusherr('unsynced changes') |
302 | 306 |
303 # push can proceed | 307 # push can proceed |
304 fp.seek(0) | 308 fp.seek(0) |
305 gen = changegroupmod.readbundle(fp, None) | 309 gen = changegroupmod.readbundle(fp, None) |
306 | 310 |