# HG changeset patch # User Sune Foldager # Date 1342209148 -7200 # Node ID 1d710fe5ee0e99a724311724dda32289b0733c61 # Parent 1ac628cd7113e993bb54ebe1893a4f0d81fc6405 peer: introduce canpush and improve error message diff -r 1ac628cd7113 -r 1d710fe5ee0e mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Fri Jul 13 21:47:06 2012 +0200 +++ b/mercurial/bundlerepo.py Fri Jul 13 21:52:28 2012 +0200 @@ -167,6 +167,10 @@ def _file(self, f): self._repo.file(f) +class bundlepeer(localrepo.localpeer): + def canpush(self): + return False + class bundlerepository(localrepo.localrepository): def __init__(self, ui, path, bundlename): self._tempparent = None @@ -272,6 +276,9 @@ def cancopy(self): return False + def peer(self): + return bundlepeer(self) + def getcwd(self): return os.getcwd() # always outside the repo diff -r 1ac628cd7113 -r 1d710fe5ee0e mercurial/localrepo.py --- a/mercurial/localrepo.py Fri Jul 13 21:47:06 2012 +0200 +++ b/mercurial/localrepo.py Fri Jul 13 21:52:28 2012 +0200 @@ -49,6 +49,9 @@ def cancopy(self): return self._repo.cancopy() # so bundlerepo can override + def canpush(self): + return True + def url(self): return self._repo.url() @@ -1804,6 +1807,8 @@ # unbundle assumes local user cannot lock remote repo (new ssh # servers, http servers). + if not remote.canpush(): + raise util.Abort(_("destination does not support push")) # get local lock as we might write phase data locallock = self.lock() try: diff -r 1ac628cd7113 -r 1d710fe5ee0e mercurial/peer.py --- a/mercurial/peer.py Fri Jul 13 21:47:06 2012 +0200 +++ b/mercurial/peer.py Fri Jul 13 21:52:28 2012 +0200 @@ -45,5 +45,8 @@ def cancopy(self): return False + def canpush(self): + return True + def close(self): pass diff -r 1ac628cd7113 -r 1d710fe5ee0e mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py Fri Jul 13 21:47:06 2012 +0200 +++ b/mercurial/statichttprepo.py Fri Jul 13 21:52:28 2012 +0200 @@ -79,6 +79,8 @@ class statichttppeer(localrepo.localpeer): def local(self): return None + def canpush(self): + return False class statichttprepository(localrepo.localrepository): def __init__(self, ui, path): diff -r 1ac628cd7113 -r 1d710fe5ee0e tests/test-static-http.t --- a/tests/test-static-http.t Fri Jul 13 21:47:06 2012 +0200 +++ b/tests/test-static-http.t Fri Jul 13 21:52:28 2012 +0200 @@ -91,7 +91,7 @@ $ hg commit -m"test" $ hg push pushing to static-http://localhost:$HGPORT/remote - abort: cannot lock static-http repository + abort: destination does not support push [255] trying clone -r