comparison hgsubversion/svnwrap/svn_ctypes_wrapper.py @ 337:46e69be8e2c8

Reorganize to have a more conventional module structure. This means that hgsubversion now uses absolute imports instead of relative ones, which makes the tests more reliable.
author Augie Fackler <durin42@gmail.com>
date Wed, 13 May 2009 21:39:39 -0500
parents svnwrap/svn_ctypes_wrapper.py@e37f9d3fd5e7
children cfdd4ec5230a
comparison
equal deleted inserted replaced
336:c0b943cef0c3 337:46e69be8e2c8
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 def HEAD(self):
43 raise NotImplementedError
44 HEAD = property(HEAD)
45
46 def START(self):
47 return 0
48 START = property(START)
49
50 def branches(self):
51 """Get the branches defined in this repo assuming a standard layout.
52 """
53 raise NotImplementedError
54 branches = property(branches)
55
56 def tags(self):
57 """Get the current tags in this repo assuming a standard layout.
58
59 This returns a dictionary of tag: (source path, source rev)
60 """
61 raise NotImplementedError
62 tags = property(tags)
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 """