Show More
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | import os, re, sys, signal |
|
9 | 9 | import fancyopts, ui, hg |
|
10 | 10 | from demandload import * |
|
11 | demandload(globals(), "mdiff time hgweb traceback") | |
|
11 | demandload(globals(), "mdiff time hgweb traceback random signal") | |
|
12 | 12 | |
|
13 | 13 | class UnknownCommand(Exception): pass |
|
14 | 14 | |
@@ -412,6 +412,41 b' def pull(ui, repo, source):' | |||
|
412 | 412 | cg = repo.getchangegroup(other) |
|
413 | 413 | repo.addchangegroup(cg) |
|
414 | 414 | |
|
415 | def push(ui, repo, dest): | |
|
416 | """push changes to the specified destination""" | |
|
417 | paths = {} | |
|
418 | for name, path in ui.configitems("paths"): | |
|
419 | paths[name] = path | |
|
420 | ||
|
421 | if dest in paths: dest = paths[dest] | |
|
422 | ||
|
423 | if not dest.startswith("ssh://"): | |
|
424 | ui.warn("abort: can only push to ssh:// destinations currently\n") | |
|
425 | return 1 | |
|
426 | ||
|
427 | m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', dest) | |
|
428 | if not m: | |
|
429 | ui.warn("abort: couldn't parse destination %s\n" % dest) | |
|
430 | return 1 | |
|
431 | ||
|
432 | user, host, port, path = map(m.group, (2, 3, 5, 7)) | |
|
433 | host = user and ("%s@%s" % (user, host)) or host | |
|
434 | port = port and (" -p %s") % port or "" | |
|
435 | path = path or "" | |
|
436 | ||
|
437 | sport = random.randrange(30000, 60000) | |
|
438 | cmd = "ssh %s%s -R %d:localhost:%d 'cd %s; hg pull http://localhost:%d/'" | |
|
439 | cmd = cmd % (host, port, sport+1, sport, path, sport+1) | |
|
440 | ||
|
441 | child = os.fork() | |
|
442 | if not child: | |
|
443 | sys.stdout = file("/dev/null", "w") | |
|
444 | sys.stderr = sys.stdout | |
|
445 | hgweb.server(repo.root, "pull", "", "localhost", sport) | |
|
446 | else: | |
|
447 | r = os.system(cmd) | |
|
448 | os.kill(child, signal.SIGTERM) | |
|
449 | ||
|
415 | 450 | def rawcommit(ui, repo, files, **rc): |
|
416 | 451 | "raw commit interface" |
|
417 | 452 | |
@@ -549,6 +584,7 b' table = {' | |||
|
549 | 584 | ('q', 'quiet', "", 'silence diff')], |
|
550 | 585 | "hg import [options] patches"), |
|
551 | 586 | "pull|merge": (pull, [], 'hg pull [source]'), |
|
587 | "push": (push, [], 'hg push <destination>'), | |
|
552 | 588 | "rawcommit": (rawcommit, |
|
553 | 589 | [('p', 'parent', [], 'parent'), |
|
554 | 590 | ('d', 'date', "", 'data'), |
General Comments 0
You need to be logged in to leave comments.
Login now