Mercurial > hg
annotate hgext/convert/monotone.py @ 47890:3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
All the other caller goes through `reset_state`, so we can safely have an
explicit method on `DirstateItem` object.
This means that all the logic to preserve the previous state (from p2, merged,
etc) is now properly encapsulated within the DirstateItem. This pave the way to
using different storage for these information.
Differential Revision: https://phab.mercurial-scm.org/D11315
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 20 Aug 2021 11:27:01 +0200 |
parents | e699cebc3ae9 |
children | 6000f5b25c9b |
rev | line source |
---|---|
8250
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8127
diff
changeset
|
1 # monotone.py - monotone support for the convert extension |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8127
diff
changeset
|
2 # |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8127
diff
changeset
|
3 # Copyright 2008, 2009 Mikkel Fahnoe Jorgensen <mikkel@dvide.com> and |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8127
diff
changeset
|
4 # others |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8127
diff
changeset
|
5 # |
1b60efdb8bc5
convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents:
8127
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. |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
8 from __future__ import absolute_import |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
9 |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
10 import os |
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
11 import re |
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
12 |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28372
diff
changeset
|
13 from mercurial.i18n import _ |
43085
eef9a2d67051
py3: manually import pycompat.open into files that need it
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43077
diff
changeset
|
14 from mercurial.pycompat import open |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
15 from mercurial import ( |
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
16 error, |
36329
93943eef696f
py3: use pycompat.byteskwargs in hgext/convert/
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35176
diff
changeset
|
17 pycompat, |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
18 ) |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36394
diff
changeset
|
19 from mercurial.utils import dateutil |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
20 |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
21 from . import common |
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
22 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
23 |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
24 class monotone_source(common.converter_source, common.commandline): |
35176
671aba341d90
convert: save an indicator of the repo type for sources and sinks
Matt Harbison <matt_harbison@yahoo.com>
parents:
29205
diff
changeset
|
25 def __init__(self, ui, repotype, path=None, 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
|
26 common.converter_source.__init__(self, ui, repotype, path, revs) |
25748
baea47cafe75
convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents:
24395
diff
changeset
|
27 if revs and len(revs) > 1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
28 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
29 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
30 b'monotone source does not support specifying ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
31 b'multiple revs' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
32 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
33 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
34 common.commandline.__init__(self, ui, b'mtn') |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
35 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
36 self.ui = ui |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
37 self.path = path |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
38 self.automatestdio = False |
25748
baea47cafe75
convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents:
24395
diff
changeset
|
39 self.revs = revs |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
40 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
41 norepo = common.NoRepo( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
42 _(b"%s does not look like a monotone repository") % path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
43 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
44 if not os.path.exists(os.path.join(path, b'_MTN')): |
8052
fe2a87a3d344
convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents:
8051
diff
changeset
|
45 # Could be a monotone repository (SQLite db file) |
fe2a87a3d344
convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents:
8051
diff
changeset
|
46 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
47 f = open(path, b'rb') |
14179
64481eee6215
hgext: fixup a couple missed file().read() instances
Matt Mackall <mpm@selenic.com>
parents:
13792
diff
changeset
|
48 header = f.read(16) |
64481eee6215
hgext: fixup a couple missed file().read() instances
Matt Mackall <mpm@selenic.com>
parents:
13792
diff
changeset
|
49 f.close() |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16687
diff
changeset
|
50 except IOError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
51 header = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
52 if header != b'SQLite format 3\x00': |
8052
fe2a87a3d344
convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents:
8051
diff
changeset
|
53 raise norepo |
7973
db3a68fd9387
convert: attempt to check repo type before checking for tool
Matt Mackall <mpm@selenic.com>
parents:
7957
diff
changeset
|
54 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
55 # regular expressions for parsing monotone output |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
56 space = br'\s*' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
57 name = br'\s+"((?:\\"|[^"])*)"\s*' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
58 value = name |
36393
54f4328a07c2
py3: make sure regexes are bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36330
diff
changeset
|
59 revision = br'\s+\[(\w+)\]\s*' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
60 lines = br'(?:.|\n)+' |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
61 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 self.dir_re = re.compile(space + b"dir" + name) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
63 self.file_re = re.compile( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
64 space + b"file" + name + b"content" + revision |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
65 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
66 self.add_file_re = re.compile( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
67 space + b"add_file" + name + b"content" + revision |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
68 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
69 self.patch_re = re.compile( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
70 space + b"patch" + name + b"from" + revision + b"to" + revision |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
71 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
72 self.rename_re = re.compile(space + b"rename" + name + b"to" + name) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
73 self.delete_re = re.compile(space + b"delete" + name) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
74 self.tag_re = re.compile(space + b"tag" + name + b"revision" + revision) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
75 self.cert_re = re.compile( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
76 lines + space + b"name" + name + b"value" + value |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
77 ) |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
78 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 attr = space + b"file" + lines + space + b"attr" + space |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
80 self.attr_execute_re = re.compile( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
81 attr + b'"mtn:execute"' + space + b'"true"' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
82 ) |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
83 |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
84 # cached data |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
85 self.manifest_rev = None |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
86 self.manifest = None |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
87 self.files = None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
88 self.dirs = None |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
89 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
90 common.checktool(b'mtn', abort=False) |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
91 |
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
92 def mtnrun(self, *args, **kwargs): |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
93 if self.automatestdio: |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
94 return self.mtnrunstdio(*args, **kwargs) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
95 else: |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
96 return self.mtnrunsingle(*args, **kwargs) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
97 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
98 def mtnrunsingle(self, *args, **kwargs): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
99 kwargs['d'] = self.path |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
100 return self.run0(b'automate', *args, **kwargs) |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
101 |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
102 def mtnrunstdio(self, *args, **kwargs): |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
103 # Prepare the command in automate stdio format |
36329
93943eef696f
py3: use pycompat.byteskwargs in hgext/convert/
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35176
diff
changeset
|
104 kwargs = pycompat.byteskwargs(kwargs) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
105 command = [] |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
106 for k, v in pycompat.iteritems(kwargs): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
107 command.append(b"%d:%s" % (len(k), k)) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
108 if v: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
109 command.append(b"%d:%s" % (len(v), v)) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
110 if command: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
111 command.insert(0, b'o') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
112 command.append(b'e') |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
113 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 command.append(b'l') |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
115 for arg in args: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 command.append(b"%d:%s" % (len(arg), arg)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
117 command.append(b'e') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
118 command = b''.join(command) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
119 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
120 self.ui.debug(b"mtn: sending '%s'\n" % command) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
121 self.mtnwritefp.write(command) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
122 self.mtnwritefp.flush() |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
123 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
124 return self.mtnstdioreadcommandoutput(command) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
125 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
126 def mtnstdioreadpacket(self): |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
127 read = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
128 commandnbr = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
129 while read != b':': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
130 read = self.mtnreadfp.read(1) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
131 if not read: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
132 raise error.Abort(_(b'bad mtn packet - no end of commandnbr')) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
133 commandnbr += read |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
134 commandnbr = commandnbr[:-1] |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
135 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
136 stream = self.mtnreadfp.read(1) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 if stream not in b'mewptl': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
139 _(b'bad mtn packet - bad stream type %s') % stream |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
140 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
141 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
142 read = self.mtnreadfp.read(1) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
143 if read != b':': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
144 raise error.Abort(_(b'bad mtn packet - no divider before size')) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
145 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
146 read = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
147 lengthstr = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
148 while read != b':': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
149 read = self.mtnreadfp.read(1) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
150 if not read: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
151 raise error.Abort(_(b'bad mtn packet - no end of packet size')) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
152 lengthstr += read |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
153 try: |
41525
f3d3e09a29d1
py3: use pycompat.long in hgext/convert/monotone.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41503
diff
changeset
|
154 length = pycompat.long(lengthstr[:-1]) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
155 except TypeError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
156 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
157 _(b'bad mtn packet - bad packet size %s') % lengthstr |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
158 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
159 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
160 read = self.mtnreadfp.read(length) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
161 if len(read) != length: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
162 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
163 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
164 b"bad mtn packet - unable to read full packet " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
165 b"read %s of %s" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
166 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
167 % (len(read), length) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
168 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
169 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
170 return (commandnbr, stream, length, read) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
171 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
172 def mtnstdioreadcommandoutput(self, command): |
13792
a916e8de4313
convert/mtn: Fix conversion of large files from mtn (broken in ed97955e0c04)
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13779
diff
changeset
|
173 retval = [] |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
174 while True: |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
175 commandnbr, stream, length, output = self.mtnstdioreadpacket() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
176 self.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
177 b'mtn: read packet %s:%s:%d\n' % (commandnbr, stream, length) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
178 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
179 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
180 if stream == b'l': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
181 # End of command |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
182 if output != b'0': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
183 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
184 _(b"mtn command '%s' returned %s") % (command, output) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
185 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
186 break |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
187 elif stream in b'ew': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
188 # Error, warning output |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
189 self.ui.warn(_(b'%s error:\n') % self.command) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
190 self.ui.warn(output) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
191 elif stream == b'p': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
192 # Progress messages |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
193 self.ui.debug(b'mtn: ' + output) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
194 elif stream == b'm': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
195 # Main stream - command output |
13792
a916e8de4313
convert/mtn: Fix conversion of large files from mtn (broken in ed97955e0c04)
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13779
diff
changeset
|
196 retval.append(output) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
197 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
198 return b''.join(retval) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
199 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
200 def mtnloadmanifest(self, rev): |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
201 if self.manifest_rev == rev: |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
202 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
203 self.manifest = self.mtnrun(b"get_manifest_of", rev).split(b"\n\n") |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
204 self.manifest_rev = rev |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
205 self.files = {} |
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
206 self.dirs = {} |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
207 |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
208 for e in self.manifest: |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
209 m = self.file_re.match(e) |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
210 if m: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
211 attr = b"" |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
212 name = m.group(1) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
213 node = m.group(2) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
214 if self.attr_execute_re.match(e): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
215 attr += b"x" |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
216 self.files[name] = (node, attr) |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
217 m = self.dir_re.match(e) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
218 if m: |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
219 self.dirs[m.group(1)] = True |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
220 |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
221 def mtnisfile(self, name, rev): |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
222 # a non-file could be a directory or a deleted or renamed file |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
223 self.mtnloadmanifest(rev) |
8458
f6c99b1628d7
convert: cleanups in monotone converter
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8250
diff
changeset
|
224 return name in self.files |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
225 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
226 def mtnisdir(self, name, rev): |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
227 self.mtnloadmanifest(rev) |
8458
f6c99b1628d7
convert: cleanups in monotone converter
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8250
diff
changeset
|
228 return name in self.dirs |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
229 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
230 def mtngetcerts(self, rev): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
231 certs = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
232 b"author": b"<missing>", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
233 b"date": b"<missing>", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
234 b"changelog": b"<missing>", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
235 b"branch": b"<missing>", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
236 } |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
237 certlist = self.mtnrun(b"certs", rev) |
9823
11d7bb5e0df2
convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents:
8458
diff
changeset
|
238 # mtn < 0.45: |
11d7bb5e0df2
convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents:
8458
diff
changeset
|
239 # key "test@selenic.com" |
11d7bb5e0df2
convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents:
8458
diff
changeset
|
240 # mtn >= 0.45: |
11d7bb5e0df2
convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents:
8458
diff
changeset
|
241 # key [ff58a7ffb771907c4ff68995eada1c4da068d328] |
44020
ac3cb5e05a38
cleanup: replace contiguous spaces in regex patterns with an explicit count
Matt Harbison <matt_harbison@yahoo.com>
parents:
43506
diff
changeset
|
242 certlist = re.split(br'\n\n {6}key ["\[]', certlist) |
9823
11d7bb5e0df2
convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents:
8458
diff
changeset
|
243 for e in certlist: |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
244 m = self.cert_re.match(e) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
245 if m: |
6632
aa3f61884a48
convert.monotone: fix quotes and backslashes in change descriptions.
David Reiss <davidn@gmail.com>
parents:
6376
diff
changeset
|
246 name, value = m.groups() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
247 value = value.replace(br'\"', b'"') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 value = value.replace(br'\\', b'\\') |
6632
aa3f61884a48
convert.monotone: fix quotes and backslashes in change descriptions.
David Reiss <davidn@gmail.com>
parents:
6376
diff
changeset
|
249 certs[name] = value |
8101
d8229670710f
convert/mtn: handle subsecond commit dates (issue1616)
Paul Aurich <paul@darkrain42.org>
parents:
8099
diff
changeset
|
250 # Monotone may have subsecond dates: 2005-02-05T09:39:12.364306 |
8125
da9f3866c637
convert/mtn: mtn does not record timezones, mark dates as UTC (issue1624)
Paul Aurich <paul@darkrain42.org>
parents:
8124
diff
changeset
|
251 # and all times are stored in UTC |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 certs[b"date"] = certs[b"date"].split(b'.')[0] + b" UTC" |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
253 return certs |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
254 |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
255 # implement the converter_source interface: |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
256 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
257 def getheads(self): |
25748
baea47cafe75
convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents:
24395
diff
changeset
|
258 if not self.revs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
259 return self.mtnrun(b"leaves").splitlines() |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
260 else: |
25748
baea47cafe75
convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents:
24395
diff
changeset
|
261 return self.revs |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
262 |
22300
35ab037de989
convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents:
22296
diff
changeset
|
263 def getchanges(self, rev, full): |
35ab037de989
convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents:
22296
diff
changeset
|
264 if full: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
265 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
266 _(b"convert from monotone does not support --full") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
267 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
268 revision = self.mtnrun(b"get_revision", rev).split(b"\n\n") |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
269 files = {} |
8123
933b874e402f
convert/mtn: handle files moved in a moved directory (issue1619/2)
Patrick Mezard <pmezard@gmail.com>
parents:
8101
diff
changeset
|
270 ignoremove = {} |
8099
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
271 renameddirs = [] |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
272 copies = {} |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
273 for e in revision: |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
274 m = self.add_file_re.match(e) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
275 if m: |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
276 files[m.group(1)] = rev |
8123
933b874e402f
convert/mtn: handle files moved in a moved directory (issue1619/2)
Patrick Mezard <pmezard@gmail.com>
parents:
8101
diff
changeset
|
277 ignoremove[m.group(1)] = rev |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
278 m = self.patch_re.match(e) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
279 if m: |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
280 files[m.group(1)] = rev |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
281 # Delete/rename is handled later when the convert engine |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
282 # discovers an IOError exception from getfile, |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
283 # but only if we add the "from" file to the list of changes. |
6376
b40e90341ae2
convert: record deleted files in monotone source
Patrick Mezard <pmezard@gmail.com>
parents:
6332
diff
changeset
|
284 m = self.delete_re.match(e) |
b40e90341ae2
convert: record deleted files in monotone source
Patrick Mezard <pmezard@gmail.com>
parents:
6332
diff
changeset
|
285 if m: |
b40e90341ae2
convert: record deleted files in monotone source
Patrick Mezard <pmezard@gmail.com>
parents:
6332
diff
changeset
|
286 files[m.group(1)] = rev |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
287 m = self.rename_re.match(e) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
288 if m: |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
289 toname = m.group(2) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
290 fromname = m.group(1) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
291 if self.mtnisfile(toname, rev): |
8123
933b874e402f
convert/mtn: handle files moved in a moved directory (issue1619/2)
Patrick Mezard <pmezard@gmail.com>
parents:
8101
diff
changeset
|
292 ignoremove[toname] = 1 |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
293 copies[toname] = fromname |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
294 files[toname] = rev |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
295 files[fromname] = rev |
8099
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
296 elif self.mtnisdir(toname, rev): |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
297 renameddirs.append((fromname, toname)) |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
298 |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
299 # Directory renames can be handled only once we have recorded |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
300 # all new files |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
301 for fromdir, todir in renameddirs: |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
302 renamed = {} |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
303 for tofile in self.files: |
8123
933b874e402f
convert/mtn: handle files moved in a moved directory (issue1619/2)
Patrick Mezard <pmezard@gmail.com>
parents:
8101
diff
changeset
|
304 if tofile in ignoremove: |
8099
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
305 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
306 if tofile.startswith(todir + b'/'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
307 renamed[tofile] = fromdir + tofile[len(todir) :] |
8124
d883bfbd2e60
convert/mtn: handle directory move into moved directory (issue1619/3)
Patrick Mezard <pmezard@gmail.com>
parents:
8123
diff
changeset
|
308 # Avoid chained moves like: |
d883bfbd2e60
convert/mtn: handle directory move into moved directory (issue1619/3)
Patrick Mezard <pmezard@gmail.com>
parents:
8123
diff
changeset
|
309 # d1(/a) => d3/d1(/a) |
d883bfbd2e60
convert/mtn: handle directory move into moved directory (issue1619/3)
Patrick Mezard <pmezard@gmail.com>
parents:
8123
diff
changeset
|
310 # d2 => d3 |
d883bfbd2e60
convert/mtn: handle directory move into moved directory (issue1619/3)
Patrick Mezard <pmezard@gmail.com>
parents:
8123
diff
changeset
|
311 ignoremove[tofile] = 1 |
8099
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
312 for tofile, fromfile in renamed.items(): |
42245
d26bfbf419f9
monotone: fix a bogus _() wrapper that was caught when formatting code
Augie Fackler <augie@google.com>
parents:
41573
diff
changeset
|
313 self.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
314 b"copying file in renamed directory from '%s' to '%s'" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
315 % (fromfile, tofile), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
316 b'\n', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
317 ) |
8099
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
318 files[tofile] = rev |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
319 copies[tofile] = fromfile |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
320 for fromfile in renamed.values(): |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
321 files[fromfile] = rev |
3cdf4872941a
convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents:
8050
diff
changeset
|
322 |
24395
216fa1ba9993
convert: optimize convert of files that are unmodified from p2 in merges
Mads Kiilerich <madski@unity3d.com>
parents:
24178
diff
changeset
|
323 return (files.items(), copies, set()) |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
324 |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
325 def getfile(self, name, rev): |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
326 if not self.mtnisfile(name, rev): |
22296
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
17426
diff
changeset
|
327 return None, None |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
328 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
329 data = self.mtnrun(b"get_file_of", name, r=rev) |
16689
f366d4c2ff34
cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents:
16688
diff
changeset
|
330 except Exception: |
22296
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
17426
diff
changeset
|
331 return None, None |
11134
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10938
diff
changeset
|
332 self.mtnloadmanifest(rev) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
333 node, attr = self.files.get(name, (None, b"")) |
11134
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10938
diff
changeset
|
334 return data, attr |
6307
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
335 |
6840668e3bf6
cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
6306
diff
changeset
|
336 def getcommit(self, rev): |
13779
c13bfa451656
convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13761
diff
changeset
|
337 extra = {} |
c13bfa451656
convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13761
diff
changeset
|
338 certs = self.mtngetcerts(rev) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
339 if certs.get(b'suspend') == certs[b"branch"]: |
45092
e699cebc3ae9
convert: use bytes for value in extra dict
Manuel Jacob <me@manueljacob.de>
parents:
44020
diff
changeset
|
340 extra[b'close'] = b'1' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 dateformat = b"%Y-%m-%dT%H:%M:%S" |
28372
74d03766f962
convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents:
26779
diff
changeset
|
342 return common.commit( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
343 author=certs[b"author"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
344 date=dateutil.datestr(dateutil.strdate(certs[b"date"], dateformat)), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
345 desc=certs[b"changelog"], |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
346 rev=rev, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
347 parents=self.mtnrun(b"parents", rev).splitlines(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
348 branch=certs[b"branch"], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
349 extra=extra, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
350 ) |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
351 |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
352 def gettags(self): |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
353 tags = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
354 for e in self.mtnrun(b"tags").split(b"\n\n"): |
6306
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
355 m = self.tag_re.match(e) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
356 if m: |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
357 tags[m.group(1)] = m.group(2) |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
358 return tags |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
359 |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
360 def getchangedfiles(self, rev, i): |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
361 # This function is only needed to support --filemap |
2f9de4aaea9e
initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff
changeset
|
362 # ... and we don't support that |
16687
e34106fa0dc3
cleanup: "raise SomeException()" -> "raise SomeException"
Brodie Rao <brodie@sf.io>
parents:
16231
diff
changeset
|
363 raise NotImplementedError |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
364 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
365 def before(self): |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
366 # Check if we have a new enough version to use automate stdio |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
367 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
368 versionstr = self.mtnrunsingle(b"interface_version") |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
369 version = float(versionstr) |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
370 except Exception: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
371 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
372 _(b"unable to determine mtn automate interface version") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
373 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
374 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
375 if version >= 12.0: |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
376 self.automatestdio = True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
377 self.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
378 b"mtn automate version %f - using automate stdio\n" % version |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
379 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
380 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
381 # launch the long-running automate stdio process |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
382 self.mtnwritefp, self.mtnreadfp = self._run2( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
383 b'automate', b'stdio', b'-d', self.path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
384 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
385 # read the headers |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
386 read = self.mtnreadfp.readline() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
387 if read != b'format-version: 2\n': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
388 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
389 _(b'mtn automate stdio header unexpected: %s') % read |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
390 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
391 while read != b'\n': |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
392 read = self.mtnreadfp.readline() |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
393 if not read: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
394 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
395 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 b"failed to reach end of mtn automate " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
397 b"stdio headers" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
398 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
399 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
400 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
401 self.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
402 b"mtn automate version %s - not using automate stdio " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
403 b"(automate >= 12.0 - mtn >= 0.46 is needed)\n" % version |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42245
diff
changeset
|
404 ) |
13760
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
405 |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
406 def after(self): |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
407 if self.automatestdio: |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
408 self.mtnwritefp.close() |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
409 self.mtnwritefp = None |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
410 self.mtnreadfp.close() |
ed97955e0c04
convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11134
diff
changeset
|
411 self.mtnreadfp = None |