hg site extension
 
(Arne Babenhauserheide)
2012-06-26: have to wrap discovery.findcommonoutgoing to make this work with

have to wrap discovery.findcommonoutgoing to make this work with paths in .hg/hgrc

diff --git a/staticsite.py b/staticsite.py
--- a/staticsite.py
+++ b/staticsite.py
@@ -710,16 +710,21 @@ wrapcmds = { # cmd: generic, target, fix
 
 ## Explicitely wrap functions to change local commands in case the remote repo is an FTP repo. See mercurial.extensions for more information.
 # Get the module which holds the functions to wrap
-#from mercurial import discovery
 # the new function: gets the original function as first argument and the originals args and kwds.
-#def findcommonoutgoing(orig, *args, **opts):
-#    capable = getattr(args[1], 'capable', lambda x: False)
-#    if capable('ftp'):
-#        return []#orig(*args, **opts)
-#    else:
-#        return orig(*args, **opts)
-# really wrap the function
-#extensions.wrapfunction(discovery, 'findcommonoutgoing', findcommonoutgoing)
+def findcommonoutgoing(orig, *args, **opts):
+    repo = args[1]
+    capable = getattr(repo, 'capable', lambda x: False)
+    if capable('ftp'):
+        class fakeoutgoing(object):
+            def __init__(self):
+                self.excluded = []
+                self.missing = []
+                self.commonheads = []
+        return fakeoutgoing()
+    else:
+        return orig(*args, **opts)
+# really wrap the functions
+extensions.wrapfunction(discovery, 'findcommonoutgoing', findcommonoutgoing)
 
 # explicitely wrap commands in case the remote repo is an FTP repo.
 def ftppush(orig, *args, **opts):
@@ -785,7 +790,8 @@ class FTPRepository(repo.repository):
         Whenever this function is hit, we abort. The traceback is useful for
         figuring out where to intercept the functionality.
         """
-        raise util.Abort('command heads unavailable for FTP repositories')
+        return []
+        #raise util.Abort('command heads unavailable for FTP repositories')
 
     def pushkey(self, namespace, key, old, new):
         return False