Pierre-Yves David avatar Pierre-Yves David committed 2e46cae

push obsolescence marker before anything else

Comments (0)

Files changed (1)

hgext/pushexperiment.py

 - Add a new wire protocol command to exchange obsolescence marker. Sending the
   raw file as a binary instead of using pushkey hack.
 - Add a "push done" notification
+- Push obsolescence marker before anything else (This work arround the lack global transaction)
 
 """
 
     if not (obsolete._enabled and repo.obsstore):
         return
     if remote.capable('_push_experiment_pushobsmarkers_0'):
-        try:
-            obsfp = repo.sopener('obsstore')
-        except IOError as e:
-            if e.errno != errno.ENOENT:
-                raise
-            return
+        return # already pushed before changeset
         remote.push_experiment_pushobsmarkers_0(obsfp)
         return
     return orig(repo, remote)
     return wireproto.pushres(0)
 
 
-def notifiedpush(orig, repo, remote, *args, **kwargs):
+def augmented_push(orig, repo, remote, *args, **kwargs):
     """push wrapped that call the wire protocol command"""
+    if (obsolete._enabled and repo.obsstore
+        and remote.capable('_push_experiment_pushobsmarkers_0')):
+        # push marker early to limit damage of pushing too early.
+        try:
+            obsfp = repo.sopener('obsstore')
+        except IOError as e:
+            if e.errno != errno.ENOENT:
+                raise
+        else:
+            remote.push_experiment_pushobsmarkers_0(obsfp)
     ret = orig(repo, remote, *args, **kwargs)
     if remote.capable('_push_experiment_notifypushend_0'):
         remote.push_experiment_notifypushend_0()
     wireproto.commands['push_experiment_notifypushend_0'] = (srv_notifypushend, '')
     extensions.wrapfunction(wireproto, 'capabilities', capabilities)
     extensions.wrapfunction(obsolete, 'syncpush', syncpush)
-    extensions.wrapfunction(localrepo.localrepository, 'push', notifiedpush)
+    extensions.wrapfunction(localrepo.localrepository, 'push', augmented_push)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.