annotate mercurial/hg.py @ 1089:142b5d5ec9cc

Break apart hg.py - move the various parts of hg.py into their own files - create node.py to store node manipulation functions
author mpm@selenic.com
date Sat, 27 Aug 2005 14:21:25 -0700
parents 05dc7aba22eb
children 1bca39b85615
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
1 # hg.py - repository classes for mercurial
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
2 #
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
3 # Copyright 2005 Matt Mackall <mpm@selenic.com>
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
4 #
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
5 # This software may be used and distributed according to the terms
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
6 # of the GNU General Public License, incorporated herein by reference.
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
7
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
8 import os
419
28511fc21073 [PATCH] file seperator handling for the other 'OS'
mpm@selenic.com
parents: 418
diff changeset
9 import util
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
10 from node import *
262
3db700146536 implement demand loading hack
mpm@selenic.com
parents: 256
diff changeset
11 from revlog import *
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
12 from repo import *
262
3db700146536 implement demand loading hack
mpm@selenic.com
parents: 256
diff changeset
13 from demandload import *
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
14 demandload(globals(), "localrepo httprepo sshrepo")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
15
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
16 # used to avoid circular references so destructors work
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
17 def opener(base):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
18 p = base
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
19 def o(path, mode="r"):
686
d7d68d27ebe5 Reapply startswith() changes that got lost with stale edit
Matt Mackall <mpm@selenic.com>
parents: 681
diff changeset
20 if p.startswith("http://"):
15
6daf7757e92b Fix network pull of repo files with "%" in their base64 encoding.
mpm@selenic.com
parents: 10
diff changeset
21 f = os.path.join(p, urllib.quote(path))
372
4b0f562c61f4 Move httprangereader into its own file
mpm@selenic.com
parents: 363
diff changeset
22 return httprangereader.httprangereader(f)
15
6daf7757e92b Fix network pull of repo files with "%" in their base64 encoding.
mpm@selenic.com
parents: 10
diff changeset
23
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
24 f = os.path.join(p, path)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
25
292
09364bcebdf0 Make most file opening binary
mpm@selenic.com
parents: 291
diff changeset
26 mode += "b" # for that other OS
09364bcebdf0 Make most file opening binary
mpm@selenic.com
parents: 291
diff changeset
27
09364bcebdf0 Make most file opening binary
mpm@selenic.com
parents: 291
diff changeset
28 if mode[0] != "r":
110
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
29 try:
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
30 s = os.stat(f)
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
31 except OSError:
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
32 d = os.path.dirname(f)
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
33 if not os.path.isdir(d):
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
34 os.makedirs(d)
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
35 else:
c37c7f784ee3 Move hg from storing files in data with base64 encoding to full
mpm@selenic.com
parents: 109
diff changeset
36 if s.st_nlink > 1:
417
f2d1f5fd0179 [PATCH] file type fixes for the other 'OS'
mpm@selenic.com
parents: 416
diff changeset
37 file(f + ".tmp", "wb").write(file(f, "rb").read())
421
43b8da7420a9 [PATCH] rename under the other OS
mpm@selenic.com
parents: 420
diff changeset
38 util.rename(f+".tmp", f)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
39
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
40 return file(f, mode)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
41
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
42 return o
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
43
60
e32fdbd97839 Add hg:// protocol
mpm@selenic.com
parents: 56
diff changeset
44 def repository(ui, path=None, create=0):
623
314867960a4a Change remote repository to httprepository
Matt Mackall <mpm@selenic.com>
parents: 622
diff changeset
45 if path:
314867960a4a Change remote repository to httprepository
Matt Mackall <mpm@selenic.com>
parents: 622
diff changeset
46 if path.startswith("http://"):
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
47 return httprepo.httprepository(ui, path)
923
c7a3b88505cd Add basic https support for pull
mpm@selenic.com
parents: 919
diff changeset
48 if path.startswith("https://"):
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
49 return httprepo.httpsrepository(ui, path)
623
314867960a4a Change remote repository to httprepository
Matt Mackall <mpm@selenic.com>
parents: 622
diff changeset
50 if path.startswith("hg://"):
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
51 return httprepo.httprepository(
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
52 ui, path.replace("hg://", "http://"))
623
314867960a4a Change remote repository to httprepository
Matt Mackall <mpm@selenic.com>
parents: 622
diff changeset
53 if path.startswith("old-http://"):
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
54 return localrepo.localrepository(
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
55 ui, opener, path.replace("old-http://", "http://"))
624
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 623
diff changeset
56 if path.startswith("ssh://"):
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
57 return sshrepo.sshrepository(ui, path)
60
e32fdbd97839 Add hg:// protocol
mpm@selenic.com
parents: 56
diff changeset
58
1089
142b5d5ec9cc Break apart hg.py
mpm@selenic.com
parents: 1072
diff changeset
59 return localrepo.localrepository(ui, opener, path, create)