# HG changeset patch # User Matt Mackall # Date 1120717540 28800 # Node ID b48b91d3fb4ad6ba1e48ae9c7ae6d59972718b5a # Parent 31cebba881a0bfcd5c2430066eb4f122bd2f187e Switch push over to the new scheme Now push works transparently with any repo with lock and addchangegroup. Currently this is local repos and ssh. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -758,35 +758,11 @@ def pull(ui, repo, source="default", **o def push(ui, repo, dest="default-push"): """push changes to the specified destination""" dest = ui.expandpath(dest) - - if not dest.startswith("ssh://"): - ui.warn("abort: can only push to ssh:// destinations currently\n") - return 1 - - m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', dest) - if not m: - ui.warn("abort: couldn't parse destination %s\n" % dest) - return 1 - - user, host, port, path = map(m.group, (2, 3, 5, 7)) - uhost = user and ("%s@%s" % (user, host)) or host - port = port and (" -p %s") % port or "" - path = path or "" + ui.status('pushing to %s\n' % (dest)) - sport = random.randrange(30000, 60000) - cmd = "ssh %s%s -R %d:localhost:%d 'cd %s; hg pull http://localhost:%d/'" - cmd = cmd % (uhost, port, sport+1, sport, path, sport+1) - - child = os.fork() - if not child: - sys.stdout = file("/dev/null", "w") - sys.stderr = sys.stdout - hgweb.server(repo.root, "pull", "", "localhost", sport) - else: - ui.status("connecting to %s\n" % host) - r = os.system(cmd) - os.kill(child, signal.SIGTERM) - return r + other = hg.repository(ui, dest) + r = repo.push(other) + return r def rawcommit(ui, repo, *flist, **rc): "raw commit interface"