author | Greg Ward <greg-hg@gerg.ca> |
Thu, 07 May 2009 21:35:12 -0400 | |
changeset 8308 | 1268b895f69b |
parent 8250 | 1b60efdb8bc5 |
child 8662 | eaee3491ce11 |
permissions | -rw-r--r-- |
8250
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
1 |
# gnuarch.py - GNU Arch support for the convert extension |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
2 |
# |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
3 |
# Copyright 2008, 2009 Aleix Conchillo Flaque <aleix@member.fsf.org> |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
4 |
# and others |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
5 |
# |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
6 |
# This software may be used and distributed according to the terms of the |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
7 |
# GNU General Public License version 2, incorporated herein by reference. |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
8 |
|
6212 | 9 |
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
|
10 |
from mercurial.i18n import _ |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
11 |
from mercurial import util |
7579
a8db971dc258
convert/gnuarch: set prefered locale for str conversions
Edouard Gomez <ed.gomez@free.fr>
parents:
7578
diff
changeset
|
12 |
import os, shutil, tempfile, stat, locale |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
13 |
from email.Parser import Parser |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
14 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
15 |
class gnuarch_source(converter_source, commandline): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
16 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
17 |
class gnuarch_rev: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
18 |
def __init__(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
19 |
self.rev = rev |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
20 |
self.summary = '' |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
21 |
self.date = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
22 |
self.author = '' |
7583
77fec2d270ae
convert/gnuarch: parse continuation-of revisions in gnuarch source
Edouard Gomez <ed.gomez@free.fr>
parents:
7582
diff
changeset
|
23 |
self.continuationof = None |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
24 |
self.add_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
25 |
self.mod_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
26 |
self.del_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
27 |
self.ren_files = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
28 |
self.ren_dirs = {} |
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 |
def __init__(self, ui, path, rev=None): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
31 |
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
|
32 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
33 |
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
|
34 |
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
|
35 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
36 |
# 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
|
37 |
self.execmd = None |
6083
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
38 |
if util.find_exe('baz'): |
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
39 |
self.execmd = 'baz' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
40 |
else: |
6083
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
41 |
if util.find_exe('tla'): |
81a8667331e8
convert: detect baz before tla
Patrick Mezard <pmezard@gmail.com>
parents:
6079
diff
changeset
|
42 |
self.execmd = 'tla' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
43 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
44 |
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
|
45 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
46 |
commandline.__init__(self, ui, self.execmd) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
47 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
48 |
self.path = os.path.realpath(path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
49 |
self.tmppath = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
50 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
51 |
self.treeversion = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
52 |
self.lastrev = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
53 |
self.changes = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
54 |
self.parents = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
55 |
self.tags = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
56 |
self.modecache = {} |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
57 |
self.catlogparser = Parser() |
7579
a8db971dc258
convert/gnuarch: set prefered locale for str conversions
Edouard Gomez <ed.gomez@free.fr>
parents:
7578
diff
changeset
|
58 |
self.locale = locale.getpreferredencoding() |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
59 |
self.archives = [] |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
60 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
61 |
def before(self): |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
62 |
# Get registered archives |
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
63 |
self.archives = [i.rstrip('\n') |
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
64 |
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
|
65 |
|
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
66 |
if self.execmd == 'tla': |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
67 |
output = self.run0('tree-version', self.path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
68 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
69 |
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
|
70 |
self.treeversion = output.strip() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
71 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
72 |
# Get name of temporary directory |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
73 |
version = self.treeversion.split('/') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
74 |
self.tmppath = os.path.join(tempfile.gettempdir(), |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
75 |
'hg-%s' % version[1]) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
76 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
77 |
# Generate parents dictionary |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
78 |
self.parents[None] = [] |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
79 |
treeversion = self.treeversion |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
80 |
child = None |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
81 |
while treeversion: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
82 |
self.ui.status(_('analyzing tree version %s...\n') % treeversion) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
83 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
84 |
archive = treeversion.split('/')[0] |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
85 |
if archive not in self.archives: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
86 |
self.ui.status(_('tree analysis stopped because it points to an unregistered archive %s...\n') % archive) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
87 |
break |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
88 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
89 |
# Get the complete list of revisions for that tree version |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
90 |
output, status = self.runlines('revisions', '-r', '-f', treeversion) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
91 |
self.checkexit(status, 'failed retrieveing revisions for %s' % treeversion) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
92 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
93 |
# No new iteration unless a revision has a continuation-of header |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
94 |
treeversion = None |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
95 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
96 |
for l in output: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
97 |
rev = l.strip() |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
98 |
self.changes[rev] = self.gnuarch_rev(rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
99 |
self.parents[rev] = [] |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
100 |
|
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
101 |
# Read author, date and summary |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
102 |
catlog, status = self.run('cat-log', '-d', self.path, rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
103 |
if status: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
104 |
catlog = self.run0('cat-archive-log', rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
105 |
self._parsecatlog(catlog, rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
106 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
107 |
# Populate the parents map |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
108 |
self.parents[child].append(rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
109 |
|
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
110 |
# Keep track of the current revision as the child of the next |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
111 |
# revision scanned |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
112 |
child = rev |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
113 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
114 |
# Check if we have to follow the usual incremental history |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
115 |
# or if we have to 'jump' to a different treeversion given |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
116 |
# by the continuation-of header. |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
117 |
if self.changes[rev].continuationof: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
118 |
treeversion = '--'.join(self.changes[rev].continuationof.split('--')[:-1]) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
119 |
break |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
120 |
|
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
121 |
# If we reached a base-0 revision w/o any continuation-of |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
122 |
# header, it means the tree history ends here. |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
123 |
if rev[-6:] == 'base-0': |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
124 |
break |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
125 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
126 |
def after(self): |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
127 |
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
|
128 |
shutil.rmtree(self.tmppath, ignore_errors=True) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
129 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
130 |
def getheads(self): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
131 |
return self.parents[None] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
132 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
133 |
def getfile(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
134 |
if rev != self.lastrev: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
135 |
raise util.Abort(_('internal calling inconsistency')) |
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 |
# 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
|
138 |
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
|
139 |
raise IOError |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
140 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
141 |
data, mode = self._getfile(name, rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
142 |
self.modecache[(name, rev)] = mode |
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 |
return data |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
145 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
146 |
def getmode(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
147 |
return self.modecache[(name, rev)] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
148 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
149 |
def getchanges(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
150 |
self.modecache = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
151 |
self._update(rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
152 |
changes = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
153 |
copies = {} |
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 |
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
|
156 |
changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
157 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
158 |
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
|
159 |
changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
160 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
161 |
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
|
162 |
changes.append((f, rev)) |
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 |
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
|
165 |
to = self.changes[rev].ren_files[src] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
166 |
changes.append((src, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
167 |
changes.append((to, rev)) |
7567
0946294d1f32
convert/gnuarch: fix switched copy source and destination
Patrick Mezard <pmezard@gmail.com>
parents:
6913
diff
changeset
|
168 |
copies[to] = src |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
169 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
170 |
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
|
171 |
to = self.changes[rev].ren_dirs[src] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
172 |
chgs, cps = self._rendirchanges(src, to); |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
173 |
changes += [(f, rev) for f in chgs] |
7567
0946294d1f32
convert/gnuarch: fix switched copy source and destination
Patrick Mezard <pmezard@gmail.com>
parents:
6913
diff
changeset
|
174 |
copies.update(cps) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
175 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
176 |
self.lastrev = rev |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8151
diff
changeset
|
177 |
return sorted(set(changes)), copies |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
178 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
179 |
def getcommit(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
180 |
changes = self.changes[rev] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
181 |
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
|
182 |
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
|
183 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
184 |
def gettags(self): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
185 |
return self.tags |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
186 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
187 |
def _execute(self, cmd, *args, **kwargs): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
188 |
cmdline = [self.execmd, cmd] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
189 |
cmdline += args |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
190 |
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
|
191 |
cmdline += ['>', util.nulldev, '2>', util.nulldev] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
192 |
cmdline = util.quotecommand(' '.join(cmdline)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
193 |
self.ui.debug(cmdline, '\n') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
194 |
return os.system(cmdline) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
195 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
196 |
def _update(self, rev): |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
197 |
self.ui.debug(_('applying revision %s...\n') % rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
198 |
changeset, status = self.runlines('replay', '-d', self.tmppath, |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
199 |
rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
200 |
if status: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
201 |
# Something went wrong while merging (baz or tla |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
202 |
# issue?), get latest revision and try from there |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
203 |
shutil.rmtree(self.tmppath, ignore_errors=True) |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
204 |
self._obtainrevision(rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
205 |
else: |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
206 |
old_rev = self.parents[rev][0] |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
207 |
self.ui.debug(_('computing changeset between %s and %s...\n') |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
208 |
% (old_rev, rev)) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
209 |
self._parsechangeset(changeset, rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
210 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
211 |
def _getfile(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
212 |
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
|
213 |
if stat.S_ISLNK(mode): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
214 |
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
|
215 |
mode = mode and 'l' or '' |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
216 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
217 |
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
|
218 |
mode = (mode & 0111) and 'x' or '' |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
219 |
return data, mode |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
220 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
221 |
def _exclude(self, name): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
222 |
exclude = [ '{arch}', '.arch-ids', '.arch-inventory' ] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
223 |
for exc in exclude: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
224 |
if name.find(exc) != -1: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
225 |
return True |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
226 |
return False |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
227 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
228 |
def _readcontents(self, path): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
229 |
files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
230 |
contents = os.listdir(path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
231 |
while len(contents) > 0: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
232 |
c = contents.pop() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
233 |
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
|
234 |
# 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
|
235 |
# 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
|
236 |
if not self._exclude(p): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
237 |
if os.path.isdir(p): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
238 |
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
|
239 |
else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
240 |
files.append(c) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
241 |
return files |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
242 |
|
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
243 |
def _rendirchanges(self, src, dest): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
244 |
changes = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
245 |
copies = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
246 |
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
|
247 |
for f in files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
248 |
s = os.path.join(src, f) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
249 |
d = os.path.join(dest, f) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
250 |
changes.append(s) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
251 |
changes.append(d) |
7567
0946294d1f32
convert/gnuarch: fix switched copy source and destination
Patrick Mezard <pmezard@gmail.com>
parents:
6913
diff
changeset
|
252 |
copies[d] = s |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
253 |
return changes, copies |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
254 |
|
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
255 |
def _obtainrevision(self, rev): |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
self.checkexit(output) |
6913
580d5e6bfc1f
move % out of translatable strings
Martin Geisler <mg@daimi.au.dk>
parents:
6762
diff
changeset
|
259 |
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
|
260 |
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
|
261 |
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
|
262 |
|
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
263 |
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
|
264 |
if path.startswith('./'): |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
265 |
return path[2:] |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
266 |
return path |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
267 |
|
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
268 |
def _parsecatlog(self, data, rev): |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
269 |
try: |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
270 |
catlog = self.catlogparser.parsestr(data) |
7592
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
271 |
|
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
272 |
# Commit date |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
273 |
self.changes[rev].date = util.datestr( |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
274 |
util.strdate(catlog['Standard-date'], |
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
275 |
'%Y-%m-%d %H:%M:%S')) |
7592
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
276 |
|
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
277 |
# Commit author |
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
278 |
self.changes[rev].author = self.recode(catlog['Creator']) |
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
279 |
|
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
280 |
# Commit description |
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
281 |
self.changes[rev].summary = '\n\n'.join((catlog['Summary'], |
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
282 |
catlog.get_payload())) |
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
283 |
self.changes[rev].summary = self.recode(self.changes[rev].summary) |
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
284 |
|
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
285 |
# Commit revision origin when dealing with a branch or tag |
7583
77fec2d270ae
convert/gnuarch: parse continuation-of revisions in gnuarch source
Edouard Gomez <ed.gomez@free.fr>
parents:
7582
diff
changeset
|
286 |
if catlog.has_key('Continuation-of'): |
7592
75ad51257c82
convert/gnuarch: recode cat-log parts to utf-8 to be hg.description friendly
Edouard Gomez <ed.gomez@free.fr>
parents:
7591
diff
changeset
|
287 |
self.changes[rev].continuationof = self.recode(catlog['Continuation-of']) |
7875
553aa0cbeab6
cleanup: drop unused assignments
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7603
diff
changeset
|
288 |
except Exception: |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
289 |
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
|
290 |
|
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
291 |
def _parsechangeset(self, data, rev): |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
292 |
for l in data: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
293 |
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
|
294 |
# Added file (ignore added directory) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
295 |
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
|
296 |
file = self._stripbasepath(l[1:].strip()) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
297 |
if not self._exclude(file): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
298 |
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
|
299 |
# 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
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
# 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
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
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
|
309 |
# 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
|
310 |
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
# 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
|
315 |
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
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
# 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
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
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
|
328 |
# 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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
# Renamed directory |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
334 |
elif l.startswith('/>'): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
335 |
dirs = l[2:].strip().split(' ') |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
336 |
if len(dirs) == 1: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
337 |
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
|
338 |
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
|
339 |
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
|
340 |
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
|
341 |
self.changes[rev].ren_dirs[src] = dst |