Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 640:b48b91d3fb4a
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.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 06 Jul 2005 22:25:40 -0800 |
parents | 31cebba881a0 |
children | 27f53edc02b9 |
comparison
equal
deleted
inserted
replaced
639:31cebba881a0 | 640:b48b91d3fb4a |
---|---|
756 return r | 756 return r |
757 | 757 |
758 def push(ui, repo, dest="default-push"): | 758 def push(ui, repo, dest="default-push"): |
759 """push changes to the specified destination""" | 759 """push changes to the specified destination""" |
760 dest = ui.expandpath(dest) | 760 dest = ui.expandpath(dest) |
761 | 761 ui.status('pushing to %s\n' % (dest)) |
762 if not dest.startswith("ssh://"): | 762 |
763 ui.warn("abort: can only push to ssh:// destinations currently\n") | 763 other = hg.repository(ui, dest) |
764 return 1 | 764 r = repo.push(other) |
765 | 765 return r |
766 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', dest) | |
767 if not m: | |
768 ui.warn("abort: couldn't parse destination %s\n" % dest) | |
769 return 1 | |
770 | |
771 user, host, port, path = map(m.group, (2, 3, 5, 7)) | |
772 uhost = user and ("%s@%s" % (user, host)) or host | |
773 port = port and (" -p %s") % port or "" | |
774 path = path or "" | |
775 | |
776 sport = random.randrange(30000, 60000) | |
777 cmd = "ssh %s%s -R %d:localhost:%d 'cd %s; hg pull http://localhost:%d/'" | |
778 cmd = cmd % (uhost, port, sport+1, sport, path, sport+1) | |
779 | |
780 child = os.fork() | |
781 if not child: | |
782 sys.stdout = file("/dev/null", "w") | |
783 sys.stderr = sys.stdout | |
784 hgweb.server(repo.root, "pull", "", "localhost", sport) | |
785 else: | |
786 ui.status("connecting to %s\n" % host) | |
787 r = os.system(cmd) | |
788 os.kill(child, signal.SIGTERM) | |
789 return r | |
790 | 766 |
791 def rawcommit(ui, repo, *flist, **rc): | 767 def rawcommit(ui, repo, *flist, **rc): |
792 "raw commit interface" | 768 "raw commit interface" |
793 | 769 |
794 text = rc['text'] | 770 text = rc['text'] |