1 """Utility class and function to get information about the CVS repository
2 based on checked-out files.
8 def get_repository_list(paths
):
11 if os
.path
.isfile(name
):
12 dir = os
.path
.dirname(name
)
15 rootfile
= os
.path
.join(name
, "CVS", "Root")
16 root
= open(rootfile
).readline().strip()
17 if not d
.has_key(root
):
18 d
[root
] = RepositoryInfo(dir), [name
]
20 d
[root
][1].append(name
)
25 """Record holding information about the repository we want to talk to."""
29 # type is '', ':ext', or ':pserver:'
32 def __init__(self
, dir=None):
35 dir = os
.path
.join(dir, "CVS")
36 root
= open(os
.path
.join(dir, "Root")).readline().strip()
37 if root
.startswith(":pserver:"):
38 self
.type = ":pserver:"
39 root
= root
[len(":pserver:"):]
41 if root
.startswith(":ext:"):
42 root
= root
[len(":ext:"):]
44 self
.repository
= root
46 host
, path
= root
.split(":", 1)
47 self
.cvsroot_path
= path
49 self
.cvsroot_path
= root
50 fn
= os
.path
.join(dir, "Tag")
51 if os
.path
.isfile(fn
):
52 self
.branch
= open(fn
).readline().strip()[1:]
54 def get_cvsroot(self
):
55 return self
.type + self
.repository
57 _repository_dir_cache
= {}
59 def get_repository_file(self
, path
):
60 filename
= os
.path
.abspath(path
)
61 if os
.path
.isdir(path
):
65 dir = os
.path
.dirname(path
)
68 repodir
= self
._repository
_dir
_cache
[dir]
70 repofn
= os
.path
.join(dir, "CVS", "Repository")
71 repodir
= open(repofn
).readline().strip()
72 repodir
= os
.path
.join(self
.cvsroot_path
, repodir
)
73 self
._repository
_dir
_cache
[dir] = repodir
75 fn
= os
.path
.join(repodir
, os
.path
.basename(path
))
78 return fn
[len(self
.cvsroot_path
)+1:]
81 return "<RepositoryInfo for %s>" % `self
.get_cvsroot()`