Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sshrepo.py @ 2673:109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
all repository classes now have url() method that returns url of repo.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 25 Jul 2006 13:50:32 -0700 |
parents | ffb895f16925 |
children | 386f04d6ecb3 |
comparison
equal
deleted
inserted
replaced
2671:82864a2eb709 | 2673:109a22f5434a |
---|---|
11 from demandload import * | 11 from demandload import * |
12 demandload(globals(), "hg os re stat util") | 12 demandload(globals(), "hg os re stat util") |
13 | 13 |
14 class sshrepository(remoterepository): | 14 class sshrepository(remoterepository): |
15 def __init__(self, ui, path, create=0): | 15 def __init__(self, ui, path, create=0): |
16 self.url = path | 16 self._url = path |
17 self.ui = ui | 17 self.ui = ui |
18 | 18 |
19 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', path) | 19 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', path) |
20 if not m: | 20 if not m: |
21 raise hg.RepoError(_("couldn't parse location %s") % path) | 21 raise hg.RepoError(_("couldn't parse location %s") % path) |
45 res = os.system(cmd) | 45 res = os.system(cmd) |
46 if res != 0: | 46 if res != 0: |
47 raise hg.RepoError(_("could not create remote repo")) | 47 raise hg.RepoError(_("could not create remote repo")) |
48 | 48 |
49 self.validate_repo(ui, sshcmd, args, remotecmd) | 49 self.validate_repo(ui, sshcmd, args, remotecmd) |
50 | |
51 def url(self): | |
52 return self._url | |
50 | 53 |
51 def validate_repo(self, ui, sshcmd, args, remotecmd): | 54 def validate_repo(self, ui, sshcmd, args, remotecmd): |
52 cmd = '%s %s "%s -R %s serve --stdio"' | 55 cmd = '%s %s "%s -R %s serve --stdio"' |
53 cmd = cmd % (sshcmd, args, remotecmd, self.path) | 56 cmd = cmd % (sshcmd, args, remotecmd, self.path) |
54 | 57 |
178 r = self.pipei.read(l) | 181 r = self.pipei.read(l) |
179 if not r: | 182 if not r: |
180 return 1 | 183 return 1 |
181 return int(r) | 184 return int(r) |
182 | 185 |
183 def addchangegroup(self, cg, source): | 186 def addchangegroup(self, cg, source, url): |
184 d = self.call("addchangegroup") | 187 d = self.call("addchangegroup") |
185 if d: | 188 if d: |
186 raise hg.RepoError(_("push refused: %s") % d) | 189 raise hg.RepoError(_("push refused: %s") % d) |
187 while 1: | 190 while 1: |
188 d = cg.read(4096) | 191 d = cg.read(4096) |