Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/convert/common.py @ 4534:cc9b79216a76
Split convert extension into common and repository type modules
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sun, 10 Jun 2007 20:08:47 -0700 |
parents | hgext/convert/__init__.py@c3a78a49d7f0 |
children | 451e91ed535e |
comparison
equal
deleted
inserted
replaced
4533:36abb07c79d4 | 4534:cc9b79216a76 |
---|---|
1 # common code for the convert extension | |
2 | |
3 class NoRepo(Exception): pass | |
4 | |
5 class commit(object): | |
6 def __init__(self, **parts): | |
7 for x in "author date desc parents".split(): | |
8 if not x in parts: | |
9 raise util.Abort("commit missing field %s" % x) | |
10 self.__dict__.update(parts) | |
11 | |
12 class converter_source(object): | |
13 """Conversion source interface""" | |
14 | |
15 def __init__(self, ui, path): | |
16 """Initialize conversion source (or raise NoRepo("message") | |
17 exception if path is not a valid repository)""" | |
18 raise NotImplementedError() | |
19 | |
20 def getheads(self): | |
21 """Return a list of this repository's heads""" | |
22 raise NotImplementedError() | |
23 | |
24 def getfile(self, name, rev): | |
25 """Return file contents as a string""" | |
26 raise NotImplementedError() | |
27 | |
28 def getmode(self, name, rev): | |
29 """Return file mode, eg. '', 'x', or 'l'""" | |
30 raise NotImplementedError() | |
31 | |
32 def getchanges(self, version): | |
33 """Return sorted list of (filename, id) tuples for all files changed in rev. | |
34 | |
35 id just tells us which revision to return in getfile(), e.g. in | |
36 git it's an object hash.""" | |
37 raise NotImplementedError() | |
38 | |
39 def getcommit(self, version): | |
40 """Return the commit object for version""" | |
41 raise NotImplementedError() | |
42 | |
43 def gettags(self): | |
44 """Return the tags as a dictionary of name: revision""" | |
45 raise NotImplementedError() | |
46 | |
47 class converter_sink(object): | |
48 """Conversion sink (target) interface""" | |
49 | |
50 def __init__(self, ui, path): | |
51 """Initialize conversion sink (or raise NoRepo("message") | |
52 exception if path is not a valid repository)""" | |
53 raise NotImplementedError() | |
54 | |
55 def getheads(self): | |
56 """Return a list of this repository's heads""" | |
57 raise NotImplementedError() | |
58 | |
59 def mapfile(self): | |
60 """Path to a file that will contain lines | |
61 source_rev_id sink_rev_id | |
62 mapping equivalent revision identifiers for each system.""" | |
63 raise NotImplementedError() | |
64 | |
65 def putfile(self, f, e, data): | |
66 """Put file for next putcommit(). | |
67 f: path to file | |
68 e: '', 'x', or 'l' (regular file, executable, or symlink) | |
69 data: file contents""" | |
70 raise NotImplementedError() | |
71 | |
72 def delfile(self, f): | |
73 """Delete file for next putcommit(). | |
74 f: path to file""" | |
75 raise NotImplementedError() | |
76 | |
77 def putcommit(self, files, parents, commit): | |
78 """Create a revision with all changed files listed in 'files' | |
79 and having listed parents. 'commit' is a commit object containing | |
80 at a minimum the author, date, and message for this changeset. | |
81 Called after putfile() and delfile() calls. Note that the sink | |
82 repository is not told to update itself to a particular revision | |
83 (or even what that revision would be) before it receives the | |
84 file data.""" | |
85 raise NotImplementedError() | |
86 | |
87 def puttags(self, tags): | |
88 """Put tags into sink. | |
89 tags: {tagname: sink_rev_id, ...}""" | |
90 raise NotImplementedError() |