author | Edouard Gomez <ed.gomez@free.fr> |
Sun, 04 Jan 2009 02:36:48 +0100 | |
changeset 7584 | 28563e94c471 |
parent 7583 | 77fec2d270ae |
child 7585 | 075b7ef0f84d |
permissions | -rw-r--r-- |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
1 |
# GNU Arch support for the convert extension |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
2 |
|
6212 | 3 |
from common import NoRepo, commandline, commit, converter_source |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
4 |
from mercurial.i18n import _ |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
5 |
from mercurial import util |
7579
a8db971dc258
convert/gnuarch: set prefered locale for str conversions
Edouard Gomez <ed.gomez@free.fr>
parents:
7578
diff
changeset
|
6 |
import os, shutil, tempfile, stat, locale |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
7 |
from email.Parser import Parser |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
8 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
9 |
class gnuarch_source(converter_source, commandline): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
10 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
11 |
class gnuarch_rev: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
12 |
def __init__(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
13 |
self.rev = rev |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
14 |
self.summary = '' |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
15 |
self.date = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
16 |
self.author = '' |
7583
77fec2d270ae
convert/gnuarch: parse continuation-of revisions in gnuarch source
Edouard Gomez <ed.gomez@free.fr>
parents:
7582
diff
changeset
|
17 |
self.continuationof = None |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
18 |
self.add_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
19 |
self.mod_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
20 |
self.del_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
21 |
self.ren_files = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
22 |
self.ren_dirs = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
23 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
24 |
def __init__(self, ui, path, rev=None): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
25 |
super(gnuarch_source, self).__init__(ui, path, rev=rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
26 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
27 |
if not os.path.exists(os.path.join(path, '{arch}')): |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
28 |
raise NoRepo(_("%s does not look like a GNU Arch repo") % path) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
29 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
30 |
# Could use checktool, but we want to check for baz or tla. |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
31 |
self.execmd = None |
6083
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
32 |
if util.find_exe('baz'): |
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
33 |
self.execmd = 'baz' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
34 |
else: |
6083
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
35 |
if util.find_exe('tla'): |
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
36 |
self.execmd = 'tla' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
37 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
38 |
raise util.Abort(_('cannot find a GNU Arch tool')) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
39 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
40 |
commandline.__init__(self, ui, self.execmd) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
41 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
42 |
self.path = os.path.realpath(path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
43 |
self.tmppath = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
44 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
45 |
self.treeversion = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
46 |
self.lastrev = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
47 |
self.changes = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
48 |
self.parents = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
49 |
self.tags = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
50 |
self.modecache = {} |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
51 |
self.catlogparser = Parser() |
7579
a8db971dc258
convert/gnuarch: set prefered locale for str conversions
Edouard Gomez <ed.gomez@free.fr>
parents:
7578
diff
changeset
|
52 |
self.locale = locale.getpreferredencoding() |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
53 |
self.archives = [] |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
54 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
55 |
def before(self): |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
56 |
# Get registered archives |
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
57 |
self.archives = [i.rstrip('\n') |
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
58 |
for i in self.runlines0('archives', '-n')] |
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
59 |
|
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
60 |
if self.execmd == 'tla': |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
61 |
output = self.run0('tree-version', self.path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
62 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
63 |
output = self.run0('tree-version', '-d', self.path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
64 |
self.treeversion = output.strip() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
65 |
|
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
66 |
self.ui.status(_('analyzing tree version %s...\n') % self.treeversion) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
67 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
68 |
# Get name of temporary directory |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
69 |
version = self.treeversion.split('/') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
70 |
self.tmppath = os.path.join(tempfile.gettempdir(), |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
71 |
'hg-%s' % version[1]) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
72 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
73 |
# Generate parents dictionary |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
74 |
child = [] |
7582
3b2383c90034
convert/gnuarch: use fully qualified revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7581
diff
changeset
|
75 |
output, status = self.runlines('revisions', '-f', self.treeversion) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
76 |
self.checkexit(status, 'archive registered?') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
77 |
for l in output: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
78 |
rev = l.strip() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
79 |
self.changes[rev] = self.gnuarch_rev(rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
80 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
81 |
# Read author, date and summary |
7580
8c5afb3cdb67
convert/gnuarch: robustify cat-log retrieval
Edouard Gomez <ed.gomez@free.fr>
parents:
7579
diff
changeset
|
82 |
catlog, status = self.run('cat-log', '-d', self.path, rev) |
8c5afb3cdb67
convert/gnuarch: robustify cat-log retrieval
Edouard Gomez <ed.gomez@free.fr>
parents:
7579
diff
changeset
|
83 |
if status: |
8c5afb3cdb67
convert/gnuarch: robustify cat-log retrieval
Edouard Gomez <ed.gomez@free.fr>
parents:
7579
diff
changeset
|
84 |
catlog = self.run0('cat-archive-log', rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
85 |
self._parsecatlog(catlog, rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
86 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
87 |
self.parents[rev] = child |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
88 |
child = [rev] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
89 |
if rev == self.rev: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
90 |
break |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
91 |
self.parents[None] = child |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
92 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
93 |
def after(self): |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
94 |
self.ui.debug(_('cleaning up %s\n') % self.tmppath) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
95 |
shutil.rmtree(self.tmppath, ignore_errors=True) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
96 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
97 |
def getheads(self): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
98 |
return self.parents[None] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
99 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
100 |
def getfile(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
101 |
if rev != self.lastrev: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
102 |
raise util.Abort(_('internal calling inconsistency')) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
103 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
104 |
# Raise IOError if necessary (i.e. deleted files). |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
105 |
if not os.path.exists(os.path.join(self.tmppath, name)): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
106 |
raise IOError |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
107 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
108 |
data, mode = self._getfile(name, rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
109 |
self.modecache[(name, rev)] = mode |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
110 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
111 |
return data |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
112 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
113 |
def getmode(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
114 |
return self.modecache[(name, rev)] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
115 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
116 |
def getchanges(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
117 |
self.modecache = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
118 |
self._update(rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
119 |
changes = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
120 |
copies = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
121 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
122 |
for f in self.changes[rev].add_files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
123 |
changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
124 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
125 |
for f in self.changes[rev].mod_files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
126 |
changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
127 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
128 |
for f in self.changes[rev].del_files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
129 |
changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
130 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
131 |
for src in self.changes[rev].ren_files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
132 |
to = self.changes[rev].ren_files[src] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
133 |
changes.append((src, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
134 |
changes.append((to, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
135 |
copies[src] = to |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
136 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
137 |
for src in self.changes[rev].ren_dirs: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
138 |
to = self.changes[rev].ren_dirs[src] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
139 |
chgs, cps = self._rendirchanges(src, to); |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
140 |
changes += [(f, rev) for f in chgs] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
141 |
for c in cps: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
142 |
copies[c] = cps[c] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
143 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
144 |
self.lastrev = rev |
6762 | 145 |
return util.sort(changes), copies |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
146 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
147 |
def getcommit(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
148 |
changes = self.changes[rev] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
149 |
return commit(author = changes.author, date = changes.date, |
7581
3742981341c1
convert/gnuarch: keep track of original revision in extra headers
Edouard Gomez <ed.gomez@free.fr>
parents:
7580
diff
changeset
|
150 |
desc = changes.summary, parents = self.parents[rev], rev=rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
151 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
152 |
def gettags(self): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
153 |
return self.tags |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
154 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
155 |
def _execute(self, cmd, *args, **kwargs): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
156 |
cmdline = [self.execmd, cmd] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
157 |
cmdline += args |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
158 |
cmdline = [util.shellquote(arg) for arg in cmdline] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
159 |
cmdline += ['>', util.nulldev, '2>', util.nulldev] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
160 |
cmdline = util.quotecommand(' '.join(cmdline)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
161 |
self.ui.debug(cmdline, '\n') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
162 |
return os.system(cmdline) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
163 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
164 |
def _update(self, rev): |
7582
3b2383c90034
convert/gnuarch: use fully qualified revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7581
diff
changeset
|
165 |
if rev[-6:] == 'base-0': |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
166 |
# Initialise 'base-0' revision |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
167 |
self._obtainrevision(rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
168 |
else: |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
169 |
self.ui.debug(_('applying revision %s...\n') % rev) |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
170 |
changeset, status = self.runlines('replay', '-d', self.tmppath, |
7582
3b2383c90034
convert/gnuarch: use fully qualified revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7581
diff
changeset
|
171 |
rev) |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
172 |
if status: |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
173 |
# Something went wrong while merging (baz or tla |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
174 |
# issue?), get latest revision and try from there |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
175 |
shutil.rmtree(self.tmppath, ignore_errors=True) |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
176 |
self._obtainrevision(rev) |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
177 |
else: |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
178 |
old_rev = self.parents[rev][0] |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
179 |
self.ui.debug(_('computing changeset between %s and %s...\n') |
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
180 |
% (old_rev, rev)) |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
181 |
self._parsechangeset(changeset, rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
182 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
183 |
def _getfile(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
184 |
mode = os.lstat(os.path.join(self.tmppath, name)).st_mode |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
185 |
if stat.S_ISLNK(mode): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
186 |
data = os.readlink(os.path.join(self.tmppath, name)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
187 |
mode = mode and 'l' or '' |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
188 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
189 |
data = open(os.path.join(self.tmppath, name), 'rb').read() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
190 |
mode = (mode & 0111) and 'x' or '' |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
191 |
return data, mode |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
192 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
193 |
def _exclude(self, name): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
194 |
exclude = [ '{arch}', '.arch-ids', '.arch-inventory' ] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
195 |
for exc in exclude: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
196 |
if name.find(exc) != -1: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
197 |
return True |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
198 |
return False |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
199 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
200 |
def _readcontents(self, path): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
201 |
files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
202 |
contents = os.listdir(path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
203 |
while len(contents) > 0: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
204 |
c = contents.pop() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
205 |
p = os.path.join(path, c) |
6044
9360a58a09e6
convert: do not skip some lines in gnu arch summaries
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6037
diff
changeset
|
206 |
# os.walk could be used, but here we avoid internal GNU |
9360a58a09e6
convert: do not skip some lines in gnu arch summaries
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6037
diff
changeset
|
207 |
# Arch files and directories, thus saving a lot time. |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
208 |
if not self._exclude(p): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
209 |
if os.path.isdir(p): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
210 |
contents += [os.path.join(c, f) for f in os.listdir(p)] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
211 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
212 |
files.append(c) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
213 |
return files |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
214 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
215 |
def _rendirchanges(self, src, dest): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
216 |
changes = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
217 |
copies = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
218 |
files = self._readcontents(os.path.join(self.tmppath, dest)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
219 |
for f in files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
220 |
s = os.path.join(src, f) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
221 |
d = os.path.join(dest, f) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
222 |
changes.append(s) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
223 |
changes.append(d) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
224 |
copies[s] = d |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
225 |
return changes, copies |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
226 |
|
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
227 |
def _obtainrevision(self, rev): |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
228 |
self.ui.debug(_('obtaining revision %s...\n') % rev) |
7582
3b2383c90034
convert/gnuarch: use fully qualified revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7581
diff
changeset
|
229 |
output = self._execute('get', rev, self.tmppath) |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
230 |
self.checkexit(output) |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
231 |
self.ui.debug(_('analysing revision %s...\n') % rev) |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
232 |
files = self._readcontents(self.tmppath) |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
233 |
self.changes[rev].add_files += files |
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
234 |
|
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
235 |
def _stripbasepath(self, path): |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
236 |
if path.startswith('./'): |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
237 |
return path[2:] |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
238 |
return path |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
239 |
|
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
240 |
def _parsecatlog(self, data, rev): |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
241 |
try: |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
242 |
catlog = self.catlogparser.parsestr(data) |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
243 |
self.changes[rev].date = util.datestr( |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
244 |
util.strdate(catlog['Standard-date'], |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
245 |
'%Y-%m-%d %H:%M:%S')) |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
246 |
self.changes[rev].author = catlog['Creator'] |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
247 |
self.changes[rev].summary = catlog['Summary'] |
7583
77fec2d270ae
convert/gnuarch: parse continuation-of revisions in gnuarch source
Edouard Gomez <ed.gomez@free.fr>
parents:
7582
diff
changeset
|
248 |
if catlog.has_key('Continuation-of'): |
77fec2d270ae
convert/gnuarch: parse continuation-of revisions in gnuarch source
Edouard Gomez <ed.gomez@free.fr>
parents:
7582
diff
changeset
|
249 |
self.changes[rev].continuationof = catlog['Continuation-of'] |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
250 |
except Exception, err: |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
251 |
raise util.Abort(_('could not parse cat-log of %s') % rev) |
6037
dd3267698d84
convert: add full description for gnu arch revisions
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6035
diff
changeset
|
252 |
|
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
253 |
def _parsechangeset(self, data, rev): |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
254 |
for l in data: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
255 |
l = l.strip() |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
256 |
# Added file (ignore added directory) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
257 |
if l.startswith('A') and not l.startswith('A/'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
258 |
file = self._stripbasepath(l[1:].strip()) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
259 |
if not self._exclude(file): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
260 |
self.changes[rev].add_files.append(file) |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
261 |
# Deleted file (ignore deleted directory) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
262 |
elif l.startswith('D') and not l.startswith('D/'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
263 |
file = self._stripbasepath(l[1:].strip()) |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
264 |
if not self._exclude(file): |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
265 |
self.changes[rev].del_files.append(file) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
266 |
# Modified binary file |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
267 |
elif l.startswith('Mb'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
268 |
file = self._stripbasepath(l[2:].strip()) |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
269 |
if not self._exclude(file): |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
270 |
self.changes[rev].mod_files.append(file) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
271 |
# Modified link |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
272 |
elif l.startswith('M->'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
273 |
file = self._stripbasepath(l[3:].strip()) |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
274 |
if not self._exclude(file): |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
275 |
self.changes[rev].mod_files.append(file) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
276 |
# Modified file |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
277 |
elif l.startswith('M'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
278 |
file = self._stripbasepath(l[1:].strip()) |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
279 |
if not self._exclude(file): |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
280 |
self.changes[rev].mod_files.append(file) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
281 |
# Renamed file (or link) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
282 |
elif l.startswith('=>'): |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
283 |
files = l[2:].strip().split(' ') |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
284 |
if len(files) == 1: |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
285 |
files = l[2:].strip().split('\t') |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
286 |
src = self._stripbasepath(files[0]) |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
287 |
dst = self._stripbasepath(files[1]) |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
288 |
if not self._exclude(src) and not self._exclude(dst): |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
289 |
self.changes[rev].ren_files[src] = dst |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
290 |
# Conversion from file to link or from link to file (modified) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
291 |
elif l.startswith('ch'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
292 |
file = self._stripbasepath(l[2:].strip()) |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
293 |
if not self._exclude(file): |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
294 |
self.changes[rev].mod_files.append(file) |
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
295 |
# Renamed directory |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
296 |
elif l.startswith('/>'): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
297 |
dirs = l[2:].strip().split(' ') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
298 |
if len(dirs) == 1: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
299 |
dirs = l[2:].strip().split('\t') |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
300 |
src = self._stripbasepath(dirs[0]) |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
301 |
dst = self._stripbasepath(dirs[1]) |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
302 |
if not self._exclude(src) and not self._exclude(dst): |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
303 |
self.changes[rev].ren_dirs[src] = dst |