Mercurial > hg
annotate hgext/convert/gnuarch.py @ 51684:20e2a20674dc
convert: drop a duplicate implementation of `dateutil.makedate()`
I noticed this because the signature generated by pytype recently changed to be
less specific. When the method was introduced back in 337d728e644f,
`util.makedate()` didn't take an optional timestamp arg. But now it does, and
the methods are the same (except the `dateutil` version validates that the
timestamp isn't a negative value). I left the old method in place in case
anyone has custom convert code that monkey patches it.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 11 Jul 2024 14:46:00 -0400 |
parents | 642e31cb55f0 |
children | f4733654f144 |
rev | line source |
---|---|
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 |
10263 | 7 # GNU General Public License version 2 or any later version. |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
8 |
28366
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
9 import os |
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
10 import shutil |
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
11 import stat |
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
12 import tempfile |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28366
diff
changeset
|
13 |
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28366
diff
changeset
|
14 from mercurial.i18n import _ |
28366
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
15 from mercurial import ( |
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
16 encoding, |
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
17 error, |
43382
cf3bf3b03445
py3: use mail.parsebytes() in gnuarch catlog parser
Denis Laxalde <denis@laxalde.org>
parents:
43275
diff
changeset
|
18 mail, |
39826
c31ce080eb75
py3: convert arguments, cwd and env to native strings when spawning subprocess
Matt Harbison <matt_harbison@yahoo.com>
parents:
37120
diff
changeset
|
19 pycompat, |
39833
28626957395a
convert: fix a file descriptor leak
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
20 util, |
28366
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
21 ) |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
22 from mercurial.utils import ( |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
23 dateutil, |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
24 procutil, |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
25 ) |
28366
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
26 from . import common |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
27 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
28 |
28366
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
29 class gnuarch_source(common.converter_source, common.commandline): |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
30 class gnuarch_rev: |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
31 def __init__(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
32 self.rev = rev |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
33 self.summary = b'' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
34 self.date = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
35 self.author = b'' |
7583
77fec2d270ae
convert/gnuarch: parse continuation-of revisions in gnuarch source
Edouard Gomez <ed.gomez@free.fr>
parents:
7582
diff
changeset
|
36 self.continuationof = None |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
37 self.add_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
38 self.mod_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
39 self.del_files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
40 self.ren_files = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
41 self.ren_dirs = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
42 |
35176
671aba341d90
convert: save an indicator of the repo type for sources and sinks
Matt Harbison <matt_harbison@yahoo.com>
parents:
29205
diff
changeset
|
43 def __init__(self, ui, repotype, path, revs=None): |
671aba341d90
convert: save an indicator of the repo type for sources and sinks
Matt Harbison <matt_harbison@yahoo.com>
parents:
29205
diff
changeset
|
44 super(gnuarch_source, self).__init__(ui, repotype, path, revs=revs) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
45 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
46 if not os.path.exists(os.path.join(path, b'{arch}')): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
47 raise common.NoRepo( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
48 _(b"%s does not look like a GNU Arch repository") % path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
49 ) |
6035
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 # 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
|
52 self.execmd = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
53 if procutil.findexe(b'baz'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
54 self.execmd = b'baz' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
55 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
56 if procutil.findexe(b'tla'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
57 self.execmd = b'tla' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
58 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
59 raise error.Abort(_(b'cannot find a GNU Arch tool')) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
60 |
28366
4e08b91a483f
convert: gnuarch use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
61 common.commandline.__init__(self, ui, self.execmd) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
62 |
15381
c519cd8f0169
backout dbdb777502dc (issue3077) (issue3071)
Matt Mackall <mpm@selenic.com>
parents:
15355
diff
changeset
|
63 self.path = os.path.realpath(path) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
64 self.tmppath = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
65 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
66 self.treeversion = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
67 self.lastrev = None |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
68 self.changes = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
69 self.parents = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
70 self.tags = {} |
11987
3145951e50fe
convert: use encoding.encoding instead of locale.getpreferredencoding()
Brodie Rao <brodie@bitheap.org>
parents:
11986
diff
changeset
|
71 self.encoding = encoding.encoding |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
72 self.archives = [] |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
73 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
74 def before(self): |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
75 # Get registered archives |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
76 self.archives = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
77 i.rstrip(b'\n') for i in self.runlines0(b'archives', b'-n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
78 ] |
7584
28563e94c471
convert/gnuarch: retrieve known archive names list
Edouard Gomez <ed.gomez@free.fr>
parents:
7583
diff
changeset
|
79 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
80 if self.execmd == b'tla': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
81 output = self.run0(b'tree-version', self.path) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
82 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
83 output = self.run0(b'tree-version', b'-d', self.path) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
84 self.treeversion = output.strip() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
85 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
86 # Get name of temporary directory |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
87 version = self.treeversion.split(b'/') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
88 self.tmppath = os.path.join( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
89 pycompat.fsencode(tempfile.gettempdir()), b'hg-%s' % version[1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
90 ) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
91 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
92 # Generate parents dictionary |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
93 self.parents[None] = [] |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
94 treeversion = self.treeversion |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
95 child = None |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
96 while treeversion: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
97 self.ui.status(_(b'analyzing tree version %s...\n') % treeversion) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
98 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
99 archive = treeversion.split(b'/')[0] |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
100 if archive not in self.archives: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
101 self.ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
102 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
103 b'tree analysis stopped because it points to ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
104 b'an unregistered archive %s...\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
105 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
106 % archive |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
107 ) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
108 break |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
109 |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
110 # Get the complete list of revisions for that tree version |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
111 output, status = self.runlines( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
112 b'revisions', b'-r', b'-f', treeversion |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
113 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
114 self.checkexit( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
115 status, b'failed retrieving revisions for %s' % treeversion |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
116 ) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
117 |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
118 # 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
|
119 treeversion = None |
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 for l in output: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
122 rev = l.strip() |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
123 self.changes[rev] = self.gnuarch_rev(rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
124 self.parents[rev] = [] |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
125 |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
126 # Read author, date and summary |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
127 catlog, status = self.run(b'cat-log', b'-d', self.path, rev) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
128 if status: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
129 catlog = self.run0(b'cat-archive-log', rev) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
130 self._parsecatlog(catlog, rev) |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
131 |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
132 # Populate the parents map |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
133 self.parents[child].append(rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
134 |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
135 # 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
|
136 # revision scanned |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
137 child = rev |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
138 |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
139 # 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
|
140 # 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
|
141 # by the continuation-of header. |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
142 if self.changes[rev].continuationof: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
143 treeversion = b'--'.join( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
144 self.changes[rev].continuationof.split(b'--')[:-1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
145 ) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
146 break |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
147 |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
148 # 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
|
149 # header, it means the tree history ends here. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
150 if rev[-6:] == b'base-0': |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
151 break |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
152 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
153 def after(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
154 self.ui.debug(b'cleaning up %s\n' % self.tmppath) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
155 shutil.rmtree(self.tmppath, ignore_errors=True) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
156 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
157 def getheads(self): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
158 return self.parents[None] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
159 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
160 def getfile(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
161 if rev != self.lastrev: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
162 raise error.Abort(_(b'internal calling inconsistency')) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
163 |
12344
b6173aee4a47
Use lexists() instead of exists() where appropriate
Patrick Mezard <pmezard@gmail.com>
parents:
11987
diff
changeset
|
164 if not os.path.lexists(os.path.join(self.tmppath, name)): |
22296
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
17424
diff
changeset
|
165 return None, None |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
166 |
11134
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10938
diff
changeset
|
167 return self._getfile(name, rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
168 |
22300
35ab037de989
convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents:
22296
diff
changeset
|
169 def getchanges(self, rev, full): |
35ab037de989
convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents:
22296
diff
changeset
|
170 if full: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
171 raise error.Abort(_(b"convert from arch does not support --full")) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
172 self._update(rev) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
173 changes = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
174 copies = {} |
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 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
|
177 changes.append((f, rev)) |
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 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
|
180 changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
181 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
182 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
|
183 changes.append((f, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
184 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
185 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
|
186 to = self.changes[rev].ren_files[src] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
187 changes.append((src, rev)) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
188 changes.append((to, rev)) |
7567
0946294d1f32
convert/gnuarch: fix switched copy source and destination
Patrick Mezard <pmezard@gmail.com>
parents:
6913
diff
changeset
|
189 copies[to] = src |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
190 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
191 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
|
192 to = self.changes[rev].ren_dirs[src] |
10394
4612cded5176
fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
193 chgs, cps = self._rendirchanges(src, to) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
194 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
|
195 copies.update(cps) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
196 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
197 self.lastrev = rev |
24395
216fa1ba9993
convert: optimize convert of files that are unmodified from p2 in merges
Mads Kiilerich <madski@unity3d.com>
parents:
24306
diff
changeset
|
198 return sorted(set(changes)), copies, set() |
6035
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 getcommit(self, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
201 changes = self.changes[rev] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
202 return common.commit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
203 author=changes.author, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
204 date=changes.date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
205 desc=changes.summary, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
206 parents=self.parents[rev], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
207 rev=rev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
208 ) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
209 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
210 def gettags(self): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
211 return self.tags |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
212 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
213 def _execute(self, cmd, *args, **kwargs): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
214 cmdline = [self.execmd, cmd] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
215 cmdline += args |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
216 cmdline = [procutil.shellquote(arg) for arg in cmdline] |
43275
8c0fe77f47c5
convert: convert os.devnull to bytes before trying to join it with other bytes
Ian Moody <moz-ian@perix.co.uk>
parents:
43077
diff
changeset
|
217 bdevnull = pycompat.bytestr(os.devnull) |
8c0fe77f47c5
convert: convert os.devnull to bytes before trying to join it with other bytes
Ian Moody <moz-ian@perix.co.uk>
parents:
43077
diff
changeset
|
218 cmdline += [b'>', bdevnull, b'2>', bdevnull] |
44867
8e8fd938ca07
cleanup: eliminate procutil.quotecommand()
Manuel Jacob <me@manueljacob.de>
parents:
43506
diff
changeset
|
219 cmdline = b' '.join(cmdline) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 self.ui.debug(cmdline, b'\n') |
39826
c31ce080eb75
py3: convert arguments, cwd and env to native strings when spawning subprocess
Matt Harbison <matt_harbison@yahoo.com>
parents:
37120
diff
changeset
|
221 return os.system(pycompat.rapply(procutil.tonativestr, cmdline)) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
222 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
223 def _update(self, rev): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
224 self.ui.debug(b'applying revision %s...\n' % rev) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
225 changeset, status = self.runlines(b'replay', b'-d', self.tmppath, rev) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
226 if status: |
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
227 # 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
|
228 # 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
|
229 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
|
230 self._obtainrevision(rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
231 else: |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
232 old_rev = self.parents[rev][0] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
233 self.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
234 b'computing changeset between %s and %s...\n' % (old_rev, rev) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
235 ) |
7585
075b7ef0f84d
convert/gnuarch: follow continuation-of revisions
Edouard Gomez <ed.gomez@free.fr>
parents:
7584
diff
changeset
|
236 self._parsechangeset(changeset, rev) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
237 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
238 def _getfile(self, name, rev): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
239 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
|
240 if stat.S_ISLNK(mode): |
39904
5fe0b880200e
py3: convert os.readlink() path to native strings on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
39833
diff
changeset
|
241 data = util.readlink(os.path.join(self.tmppath, name)) |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22300
diff
changeset
|
242 if mode: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
243 mode = b'l' |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
22300
diff
changeset
|
244 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
245 mode = b'' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
246 else: |
39833
28626957395a
convert: fix a file descriptor leak
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
247 data = util.readfile(os.path.join(self.tmppath, name)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 mode = (mode & 0o111) and b'x' or b'' |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
249 return data, mode |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
250 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
251 def _exclude(self, name): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 exclude = [b'{arch}', b'.arch-ids', b'.arch-inventory'] |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
253 for exc in exclude: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
254 if name.find(exc) != -1: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
255 return True |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
256 return False |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
257 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
258 def _readcontents(self, path): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
259 files = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
260 contents = os.listdir(path) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
261 while len(contents) > 0: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
262 c = contents.pop() |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
263 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
|
264 # 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
|
265 # 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
|
266 if not self._exclude(p): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
267 if os.path.isdir(p): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
268 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
|
269 else: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
270 files.append(c) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
271 return files |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
272 |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
273 def _rendirchanges(self, src, dest): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
274 changes = [] |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
275 copies = {} |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
276 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
|
277 for f in files: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
278 s = os.path.join(src, f) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
279 d = os.path.join(dest, f) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
280 changes.append(s) |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
281 changes.append(d) |
7567
0946294d1f32
convert/gnuarch: fix switched copy source and destination
Patrick Mezard <pmezard@gmail.com>
parents:
6913
diff
changeset
|
282 copies[d] = s |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
283 return changes, copies |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
284 |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
285 def _obtainrevision(self, rev): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
286 self.ui.debug(b'obtaining revision %s...\n' % rev) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
287 output = self._execute(b'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
|
288 self.checkexit(output) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
289 self.ui.debug(b'analyzing 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
|
290 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
|
291 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
|
292 |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
293 def _stripbasepath(self, path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
294 if path.startswith(b'./'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
295 return path[2:] |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
296 return path |
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
297 |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
298 def _parsecatlog(self, data, rev): |
7578
7971650bdc73
convert/gnuarch: fix cat-log parsing
Edouard Gomez <ed.gomez@free.fr>
parents:
7577
diff
changeset
|
299 try: |
43382
cf3bf3b03445
py3: use mail.parsebytes() in gnuarch catlog parser
Denis Laxalde <denis@laxalde.org>
parents:
43275
diff
changeset
|
300 catlog = mail.parsebytes(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
|
301 |
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
|
302 # Commit date |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
35633
diff
changeset
|
303 self.changes[rev].date = dateutil.datestr( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43384
diff
changeset
|
304 dateutil.strdate(catlog['Standard-date'], b'%Y-%m-%d %H:%M:%S') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
305 ) |
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
|
306 |
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
|
307 # Commit author |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43384
diff
changeset
|
308 self.changes[rev].author = self.recode(catlog['Creator']) |
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
|
309 |
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
|
310 # Commit description |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
311 self.changes[rev].summary = b'\n\n'.join( |
43384
1edf620a37a3
py3: encode strings before setting rev summary in gnuarch converter
Denis Laxalde <denis@laxalde.org>
parents:
43383
diff
changeset
|
312 ( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43384
diff
changeset
|
313 self.recode(catlog['Summary']), |
43384
1edf620a37a3
py3: encode strings before setting rev summary in gnuarch converter
Denis Laxalde <denis@laxalde.org>
parents:
43383
diff
changeset
|
314 self.recode(catlog.get_payload()), |
1edf620a37a3
py3: encode strings before setting rev summary in gnuarch converter
Denis Laxalde <denis@laxalde.org>
parents:
43383
diff
changeset
|
315 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
316 ) |
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
|
317 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
|
318 |
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
|
319 # Commit revision origin when dealing with a branch or tag |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43384
diff
changeset
|
320 if 'Continuation-of' in catlog: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
321 self.changes[rev].continuationof = self.recode( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43384
diff
changeset
|
322 catlog['Continuation-of'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43072
diff
changeset
|
323 ) |
7875
553aa0cbeab6
cleanup: drop unused assignments
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7603
diff
changeset
|
324 except Exception: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
325 raise error.Abort(_(b'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
|
326 |
6049
348132c112cf
convert: improve gnu arch source performance and other fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6044
diff
changeset
|
327 def _parsechangeset(self, data, rev): |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
328 for l in data: |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
329 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
|
330 # Added file (ignore added directory) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
331 if l.startswith(b'A') and not l.startswith(b'A/'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
332 file = self._stripbasepath(l[1:].strip()) |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
333 if not self._exclude(file): |
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
334 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
|
335 # Deleted file (ignore deleted directory) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
336 elif l.startswith(b'D') and not l.startswith(b'D/'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
337 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
|
338 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
|
339 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
|
340 # Modified binary file |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 elif l.startswith(b'Mb'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 # Modified link |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
346 elif l.startswith(b'M->'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 # Modified file |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
351 elif l.startswith(b'M'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
352 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
|
353 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
|
354 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
|
355 # Renamed file (or link) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
356 elif l.startswith(b'=>'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
357 files = l[2:].strip().split(b' ') |
6055
a3d8b1f8721d
convert: support binary files, link to files (viceversa) in gnu arch
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6049
diff
changeset
|
358 if len(files) == 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
359 files = l[2:].strip().split(b'\t') |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 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
|
364 # Conversion from file to link or from link to file (modified) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
365 elif l.startswith(b'ch'): |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
366 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
|
367 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
|
368 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
|
369 # Renamed directory |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
370 elif l.startswith(b'/>'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
371 dirs = l[2:].strip().split(b' ') |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
diff
changeset
|
372 if len(dirs) == 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
373 dirs = l[2:].strip().split(b'\t') |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
374 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
|
375 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
|
376 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
|
377 self.changes[rev].ren_dirs[src] = dst |