Mercurial > hgsubversion
comparison svnwrap/svn_ctypes_wrapper.py @ 0:f2636cfed115
Initial import of hgsubversion into a public repository.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 30 Sep 2008 11:42:52 -0500 |
parents | |
children | e37f9d3fd5e7 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f2636cfed115 |
---|---|
1 """Right now this is a dummy module, but it should wrap the ctypes API and | |
2 allow running this more easily without the SWIG bindings. | |
3 """ | |
4 from csvn import repos | |
5 | |
6 class Revision(object): | |
7 """Wrapper for a Subversion revision. | |
8 """ | |
9 def __init__(self, revnum, author, message, date, paths, strip_path=''): | |
10 self.revnum, self.author, self.message = revnum, author, message | |
11 # TODO parse this into a datetime | |
12 self.date = date | |
13 self.paths = {} | |
14 for p in paths: | |
15 self.paths[p[len(strip_path):]] = paths[p] | |
16 | |
17 def __str__(self): | |
18 return 'r%d by %s' % (self.revnum, self.author) | |
19 | |
20 | |
21 class SubversionRepo(object): | |
22 """Wrapper for a Subversion repository. | |
23 | |
24 This uses the SWIG Python bindings, and will only work on svn >= 1.4. | |
25 It takes a required param, the URL. | |
26 """ | |
27 def __init__(self, url=''): | |
28 self.svn_url = url | |
29 | |
30 self.init_ra_and_client() | |
31 self.uuid = ra.get_uuid(self.ra, self.pool) | |
32 repo_root = ra.get_repos_root(self.ra, self.pool) | |
33 # *will* have a leading '/', would not if we used get_repos_root2 | |
34 self.subdir = url[len(repo_root):] | |
35 if not self.subdir or self.subdir[-1] != '/': | |
36 self.subdir += '/' | |
37 | |
38 def init_ra_and_client(self): | |
39 # TODO(augie) need to figure out a way to do auth | |
40 self.repo = repos.RemoteRepository(self.svn_url) | |
41 | |
42 @property | |
43 def HEAD(self): | |
44 raise NotImplementedError | |
45 | |
46 @property | |
47 def START(self): | |
48 return 0 | |
49 | |
50 @property | |
51 def branches(self): | |
52 """Get the branches defined in this repo assuming a standard layout. | |
53 """ | |
54 raise NotImplementedError | |
55 | |
56 @property | |
57 def tags(self): | |
58 """Get the current tags in this repo assuming a standard layout. | |
59 | |
60 This returns a dictionary of tag: (source path, source rev) | |
61 """ | |
62 raise NotImplementedError | |
63 | |
64 def _get_copy_source(self, path, cached_head=None): | |
65 """Get copy revision for the given path, assuming it was meant to be | |
66 a copy of the entire tree. | |
67 """ | |
68 raise NotImplementedError | |
69 | |
70 def list_dir(self, dir, revision=None): | |
71 """List the contents of a server-side directory. | |
72 | |
73 Returns a dict-like object with one dict key per directory entry. | |
74 | |
75 Args: | |
76 dir: the directory to list, no leading slash | |
77 rev: the revision at which to list the directory, defaults to HEAD | |
78 """ | |
79 raise NotImplementedError | |
80 | |
81 def revisions(self, start=None, chunk_size=1000): | |
82 """Load the history of this repo. | |
83 | |
84 This is LAZY. It returns a generator, and fetches a small number | |
85 of revisions at a time. | |
86 | |
87 The reason this is lazy is so that you can use the same repo object | |
88 to perform RA calls to get deltas. | |
89 """ | |
90 # NB: you'd think this would work, but you'd be wrong. I'm pretty | |
91 # convinced there must be some kind of svn bug here. | |
92 #return self.fetch_history_at_paths(['tags', 'trunk', 'branches'], | |
93 # start=start) | |
94 # this does the same thing, but at the repo root + filtering. It's | |
95 # kind of tough cookies, sadly. | |
96 raise NotImplementedError | |
97 | |
98 | |
99 def fetch_history_at_paths(self, paths, start=None, stop=None, | |
100 chunk_size=1000): | |
101 raise NotImplementedError | |
102 | |
103 def get_replay(self, revision, editor, oldest_rev_i_have=0): | |
104 raise NotImplementedError | |
105 | |
106 def get_unified_diff(self, path, revision, deleted=True, ignore_type=False): | |
107 raise NotImplementedError | |
108 | |
109 def get_file(self, path, revision): | |
110 raise NotImplementedError | |
111 | |
112 def proplist(self, path, revision, recurse=False): | |
113 raise NotImplementedError | |
114 | |
115 def fetch_all_files_to_dir(self, path, revision, checkout_path): | |
116 raise NotImplementedError | |
117 | |
118 class SubversionRepoCanNotReplay(Exception): | |
119 """Exception raised when the svn server is too old to have replay. | |
120 """ |