[PATCH 2 of 5 RFC] peer: introduce canpush and improve error message
Sune Foldager
cryo at cyanite.org
Tue Jun 26 16:41:23 CDT 2012
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1314970417 -7200
# Node ID 715fbb275c68fa3d744ac43b622e6a9bae60ee3a
# Parent 12592d7092a77fc66a315863a4cda4881f5f5082
peer: introduce canpush and improve error message
diff -r 12592d7092a7 -r 715fbb275c68 mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py Thu Sep 01 17:41:24 2011 +0200
+++ b/mercurial/bundlerepo.py Fri Sep 02 15:33:37 2011 +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 12592d7092a7 -r 715fbb275c68 mercurial/localrepo.py
--- a/mercurial/localrepo.py Thu Sep 01 17:41:24 2011 +0200
+++ b/mercurial/localrepo.py Fri Sep 02 15:33:37 2011 +0200
@@ -50,6 +50,9 @@
def cancopy(self):
return self._repo.cancopy() # so bundlerepo can override
+ def canpush(self):
+ return True
+
def url(self):
return self._repo.url()
@@ -1777,6 +1780,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 12592d7092a7 -r 715fbb275c68 mercurial/peer.py
--- a/mercurial/peer.py Thu Sep 01 17:41:24 2011 +0200
+++ b/mercurial/peer.py Fri Sep 02 15:33:37 2011 +0200
@@ -42,5 +42,8 @@
def cancopy(self):
return False
+ def canpush(self):
+ return True
+
def close(self):
pass
diff -r 12592d7092a7 -r 715fbb275c68 mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py Thu Sep 01 17:41:24 2011 +0200
+++ b/mercurial/statichttprepo.py Fri Sep 02 15:33:37 2011 +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 12592d7092a7 -r 715fbb275c68 tests/test-static-http.t
--- a/tests/test-static-http.t Thu Sep 01 17:41:24 2011 +0200
+++ b/tests/test-static-http.t Fri Sep 02 15:33:37 2011 +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
More information about the Mercurial-devel
mailing list