Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 638:35f7adfefa69
Add a scheme for handling remote locking
This adds an object that remembers to unlock the remote repo on
destruction and lock/unlock functions for the ssh protocol. The remote
repository should also unlock itself when the connection goes down.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 06 Jul 2005 22:23:27 -0800 |
parents | 85e2209d401c |
children | 31cebba881a0 |
comparison
equal
deleted
inserted
replaced
637:31e090c34d3b | 638:35f7adfefa69 |
---|---|
878 def respond(v): | 878 def respond(v): |
879 fout.write("%d\n" % len(v)) | 879 fout.write("%d\n" % len(v)) |
880 fout.write(v) | 880 fout.write(v) |
881 fout.flush() | 881 fout.flush() |
882 | 882 |
883 lock = None | |
884 | |
883 while 1: | 885 while 1: |
884 cmd = fin.readline()[:-1] | 886 cmd = fin.readline()[:-1] |
885 if cmd == '': | 887 if cmd == '': |
886 return | 888 return |
887 if cmd == "heads": | 889 if cmd == "heads": |
888 h = repo.heads() | 890 h = repo.heads() |
889 respond(" ".join(map(hg.hex, h)) + "\n") | 891 respond(" ".join(map(hg.hex, h)) + "\n") |
892 if cmd == "lock": | |
893 lock = repo.lock() | |
894 respond("") | |
895 if cmd == "unlock": | |
896 if lock: lock.release() | |
897 lock = None | |
898 respond("") | |
890 elif cmd == "branches": | 899 elif cmd == "branches": |
891 arg, nodes = getarg() | 900 arg, nodes = getarg() |
892 nodes = map(hg.bin, nodes.split(" ")) | 901 nodes = map(hg.bin, nodes.split(" ")) |
893 r = [] | 902 r = [] |
894 for b in repo.branches(nodes): | 903 for b in repo.branches(nodes): |