diff tests/test-bundle2.t @ 21184:28d76afa1568 stable

bundle2: fix raising errors during heads checking If the heads on the server differ from the ones reported seen by the client at bundle time, we raise a PushRaced exception. However, the part raising the exception was broken. To fix it, we move the PushRaced class in the error module so it can be accessible everywhere without an import cycle. A test is also added to prevent regression.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 21 Apr 2014 18:59:09 -0700
parents 4345274adc4b
children 5b3717e1a3ea
line wrap: on
line diff
--- a/tests/test-bundle2.t	Mon Apr 21 16:02:03 2014 -0700
+++ b/tests/test-bundle2.t	Mon Apr 21 18:59:09 2014 -0700
@@ -15,6 +15,7 @@
   > from mercurial import scmutil
   > from mercurial import discovery
   > from mercurial import changegroup
+  > from mercurial import error
   > cmdtable = {}
   > command = cmdutil.command(cmdtable)
   > 
@@ -59,6 +60,7 @@
   >           ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
   >           ('', 'parts', False, 'include some arbitrary parts to the bundle'),
   >           ('', 'reply', False, 'produce a reply bundle'),
+  >           ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
   >           ('r', 'rev', [], 'includes those changeset in the bundle'),],
   >          '[OUTPUTFILE]')
   > def cmdbundle2(ui, repo, path=None, **opts):
@@ -75,6 +77,10 @@
   >         capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
   >         bundler.addpart(bundle2.bundlepart('b2x:replycaps', data=capsstring))
   > 
+  >     if opts['pushrace']:
+  >         dummynode = '01234567890123456789'
+  >         bundler.addpart(bundle2.bundlepart('b2x:check:heads', data=dummynode))
+  > 
   >     revs = opts['rev']
   >     if 'rev' in opts:
   >         revs = scmutil.revrange(repo, opts['rev'])
@@ -132,6 +138,8 @@
   >             tr.close()
   >         except KeyError, exc:
   >             raise util.Abort('missing support for %s' % exc)
+  >         except error.PushRaced, exc:
+  >             raise util.Abort('push race')
   >     finally:
   >         if tr is not None:
   >             tr.release()
@@ -601,6 +609,15 @@
   remote: replying to ping request (id 6)
   0 unread bytes
 
+Test push race detection
+
+  $ hg bundle2 --pushrace ../part-race.hg2
+
+  $ hg unbundle2 < ../part-race.hg2
+  0 unread bytes
+  abort: push race
+  [255]
+
 Support for changegroup
 ===================================