Mercurial > hg
changeset 17193:1d710fe5ee0e
peer: introduce canpush and improve error message
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Fri, 13 Jul 2012 21:52:28 +0200 |
parents | 1ac628cd7113 |
children | 32a6a33b9a35 |
files | mercurial/bundlerepo.py mercurial/localrepo.py mercurial/peer.py mercurial/statichttprepo.py tests/test-static-http.t |
diffstat | 5 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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:
--- 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
--- 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):
--- 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