Show More
@@ -690,12 +690,12 b' def debugstate(ui, repo):' | |||||
690 |
|
690 | |||
691 | def debugdata(ui, file_, rev): |
|
691 | def debugdata(ui, file_, rev): | |
692 | """dump the contents of an data file revision""" |
|
692 | """dump the contents of an data file revision""" | |
693 |
r = hg.revlog( |
|
693 | r = hg.revlog(file, file_[:-2] + ".i", file_) | |
694 | ui.write(r.revision(r.lookup(rev))) |
|
694 | ui.write(r.revision(r.lookup(rev))) | |
695 |
|
695 | |||
696 | def debugindex(ui, file_): |
|
696 | def debugindex(ui, file_): | |
697 | """dump the contents of an index file""" |
|
697 | """dump the contents of an index file""" | |
698 |
r = hg.revlog( |
|
698 | r = hg.revlog(file, file_, "") | |
699 | ui.write(" rev offset length base linkrev" + |
|
699 | ui.write(" rev offset length base linkrev" + | |
700 | " nodeid p1 p2\n") |
|
700 | " nodeid p1 p2\n") | |
701 | for i in range(r.count()): |
|
701 | for i in range(r.count()): | |
@@ -706,7 +706,7 b' def debugindex(ui, file_):' | |||||
706 |
|
706 | |||
707 | def debugindexdot(ui, file_): |
|
707 | def debugindexdot(ui, file_): | |
708 | """dump an index DAG as a .dot file""" |
|
708 | """dump an index DAG as a .dot file""" | |
709 |
r = hg.revlog( |
|
709 | r = hg.revlog(file, file_, "") | |
710 | ui.write("digraph G {\n") |
|
710 | ui.write("digraph G {\n") | |
711 | for i in range(r.count()): |
|
711 | for i in range(r.count()): | |
712 | e = r.index[i] |
|
712 | e = r.index[i] |
@@ -13,34 +13,6 b' from repo import *' | |||||
13 | from demandload import * |
|
13 | from demandload import * | |
14 | demandload(globals(), "localrepo httprepo sshrepo") |
|
14 | demandload(globals(), "localrepo httprepo sshrepo") | |
15 |
|
15 | |||
16 | # used to avoid circular references so destructors work |
|
|||
17 | def opener(base): |
|
|||
18 | p = base |
|
|||
19 | def o(path, mode="r"): |
|
|||
20 | if p.startswith("http://"): |
|
|||
21 | f = os.path.join(p, urllib.quote(path)) |
|
|||
22 | return httprangereader.httprangereader(f) |
|
|||
23 |
|
||||
24 | f = os.path.join(p, path) |
|
|||
25 |
|
||||
26 | mode += "b" # for that other OS |
|
|||
27 |
|
||||
28 | if mode[0] != "r": |
|
|||
29 | try: |
|
|||
30 | s = os.stat(f) |
|
|||
31 | except OSError: |
|
|||
32 | d = os.path.dirname(f) |
|
|||
33 | if not os.path.isdir(d): |
|
|||
34 | os.makedirs(d) |
|
|||
35 | else: |
|
|||
36 | if s.st_nlink > 1: |
|
|||
37 | file(f + ".tmp", "wb").write(file(f, "rb").read()) |
|
|||
38 | util.rename(f+".tmp", f) |
|
|||
39 |
|
||||
40 | return file(f, mode) |
|
|||
41 |
|
||||
42 | return o |
|
|||
43 |
|
||||
44 | def repository(ui, path=None, create=0): |
|
16 | def repository(ui, path=None, create=0): | |
45 | if path: |
|
17 | if path: | |
46 | if path.startswith("http://"): |
|
18 | if path.startswith("http://"): | |
@@ -52,8 +24,8 b' def repository(ui, path=None, create=0):' | |||||
52 | ui, path.replace("hg://", "http://")) |
|
24 | ui, path.replace("hg://", "http://")) | |
53 | if path.startswith("old-http://"): |
|
25 | if path.startswith("old-http://"): | |
54 | return localrepo.localrepository( |
|
26 | return localrepo.localrepository( | |
55 | ui, opener, path.replace("old-http://", "http://")) |
|
27 | ui, util.opener, path.replace("old-http://", "http://")) | |
56 | if path.startswith("ssh://"): |
|
28 | if path.startswith("ssh://"): | |
57 | return sshrepo.sshrepository(ui, path) |
|
29 | return sshrepo.sshrepository(ui, path) | |
58 |
|
30 | |||
59 | return localrepo.localrepository(ui, opener, path, create) |
|
31 | return localrepo.localrepository(ui, util.opener, path, create) |
@@ -232,6 +232,41 b' def copytree(src, dst, copyfile):' | |||||
232 | else: |
|
232 | else: | |
233 | pass |
|
233 | pass | |
234 |
|
234 | |||
|
235 | def opener(base): | |||
|
236 | """ | |||
|
237 | return a function that opens files relative to base | |||
|
238 | ||||
|
239 | this function is used to hide the details of COW semantics and | |||
|
240 | remote file access from higher level code. | |||
|
241 | ||||
|
242 | todo: separate remote file access into a separate function | |||
|
243 | """ | |||
|
244 | p = base | |||
|
245 | def o(path, mode="r"): | |||
|
246 | if p.startswith("http://"): | |||
|
247 | f = os.path.join(p, urllib.quote(path)) | |||
|
248 | return httprangereader.httprangereader(f) | |||
|
249 | ||||
|
250 | f = os.path.join(p, path) | |||
|
251 | ||||
|
252 | mode += "b" # for that other OS | |||
|
253 | ||||
|
254 | if mode[0] != "r": | |||
|
255 | try: | |||
|
256 | s = os.stat(f) | |||
|
257 | except OSError: | |||
|
258 | d = os.path.dirname(f) | |||
|
259 | if not os.path.isdir(d): | |||
|
260 | os.makedirs(d) | |||
|
261 | else: | |||
|
262 | if s.st_nlink > 1: | |||
|
263 | file(f + ".tmp", "wb").write(file(f, "rb").read()) | |||
|
264 | rename(f+".tmp", f) | |||
|
265 | ||||
|
266 | return file(f, mode) | |||
|
267 | ||||
|
268 | return o | |||
|
269 | ||||
235 | def _makelock_file(info, pathname): |
|
270 | def _makelock_file(info, pathname): | |
236 | ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL) |
|
271 | ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL) | |
237 | os.write(ld, info) |
|
272 | os.write(ld, info) |
General Comments 0
You need to be logged in to leave comments.
Login now