hgext/convert/monotone.py
author Yuya Nishihara <yuya@tcha.org>
Sat, 03 Nov 2018 17:56:17 +0900
changeset 40538 c5e964f75bf7
parent 40225 474809790256
child 41365 876494fd967d
permissions -rw-r--r--
ui: pass in file object to _writenobuf() See the subsequent patches for why. The "if" block in _writenobuf() will be removed soon.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9823
diff changeset
     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 _
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    14
from mercurial import (
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    15
    error,
36329
93943eef696f py3: use pycompat.byteskwargs in hgext/convert/
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35176
diff changeset
    16
    pycompat,
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    17
)
36607
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36394
diff changeset
    18
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
    19
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    20
from . import common
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    21
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    22
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
    23
    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
    24
        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
    25
        if revs and len(revs) > 1:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
    26
            raise error.Abort(_('monotone source does not support specifying '
25748
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
    27
                               'multiple revs'))
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    28
        common.commandline.__init__(self, ui, 'mtn')
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    29
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    30
        self.ui = ui
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    31
        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
    32
        self.automatestdio = False
25748
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
    33
        self.revs = revs
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    34
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    35
        norepo = common.NoRepo(_("%s does not look like a monotone repository")
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    36
                             % path)
7973
db3a68fd9387 convert: attempt to check repo type before checking for tool
Matt Mackall <mpm@selenic.com>
parents: 7957
diff changeset
    37
        if not os.path.exists(os.path.join(path, '_MTN')):
8052
fe2a87a3d344 convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents: 8051
diff changeset
    38
            # 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
    39
            try:
36394
4bc983568016 py3: replace file() with open()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36393
diff changeset
    40
                f = open(path, 'rb')
14179
64481eee6215 hgext: fixup a couple missed file().read() instances
Matt Mackall <mpm@selenic.com>
parents: 13792
diff changeset
    41
                header = f.read(16)
64481eee6215 hgext: fixup a couple missed file().read() instances
Matt Mackall <mpm@selenic.com>
parents: 13792
diff changeset
    42
                f.close()
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16687
diff changeset
    43
            except IOError:
8052
fe2a87a3d344 convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents: 8051
diff changeset
    44
                header = ''
fe2a87a3d344 convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents: 8051
diff changeset
    45
            if header != 'SQLite format 3\x00':
fe2a87a3d344 convert/mtn: allow monotone database files as sources
Patrick Mezard <pmezard@gmail.com>
parents: 8051
diff changeset
    46
                raise norepo
7973
db3a68fd9387 convert: attempt to check repo type before checking for tool
Matt Mackall <mpm@selenic.com>
parents: 7957
diff changeset
    47
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    48
        # regular expressions for parsing monotone output
36393
54f4328a07c2 py3: make sure regexes are bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36330
diff changeset
    49
        space    = br'\s*'
54f4328a07c2 py3: make sure regexes are bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36330
diff changeset
    50
        name     = br'\s+"((?:\\"|[^"])*)"\s*'
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    51
        value    = name
36393
54f4328a07c2 py3: make sure regexes are bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36330
diff changeset
    52
        revision = br'\s+\[(\w+)\]\s*'
54f4328a07c2 py3: make sure regexes are bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36330
diff changeset
    53
        lines    = br'(?:.|\n)+'
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    54
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    55
        self.dir_re      = re.compile(space + "dir" + name)
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    56
        self.file_re     = re.compile(space + "file" + name +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    57
                                      "content" + revision)
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    58
        self.add_file_re = re.compile(space + "add_file" + name +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    59
                                      "content" + revision)
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    60
        self.patch_re    = re.compile(space + "patch" + name +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    61
                                      "from" + revision + "to" + revision)
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    62
        self.rename_re   = re.compile(space + "rename" + name + "to" + name)
6376
b40e90341ae2 convert: record deleted files in monotone source
Patrick Mezard <pmezard@gmail.com>
parents: 6332
diff changeset
    63
        self.delete_re   = re.compile(space + "delete" + name)
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    64
        self.tag_re      = re.compile(space + "tag" + name + "revision" +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    65
                                      revision)
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    66
        self.cert_re     = re.compile(lines + space + "name" + name +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    67
                                      "value" + value)
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    68
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    69
        attr = space + "file" + lines + space + "attr" + space
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    70
        self.attr_execute_re = re.compile(attr  + '"mtn:execute"' +
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    71
                                          space + '"true"')
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    72
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    73
        # cached data
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    74
        self.manifest_rev = None
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
    75
        self.manifest = None
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    76
        self.files = None
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    77
        self.dirs  = None
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    78
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    79
        common.checktool('mtn', abort=False)
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    80
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    81
    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
    82
        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
    83
            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
    84
        else:
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    85
            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
    86
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    87
    def mtnrunsingle(self, *args, **kwargs):
36330
1eee42aed306 py3: add a r'' prefix to prevent transformer from adding b''
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36329
diff changeset
    88
        kwargs[r'd'] = self.path
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    89
        return self.run0('automate', *args, **kwargs)
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
    90
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    91
    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
    92
        # 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
    93
        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
    94
        command = []
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    95
        for k, v in kwargs.iteritems():
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    96
            command.append("%s:%s" % (len(k), k))
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    97
            if v:
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    98
                command.append("%s:%s" % (len(v), v))
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
    99
        if command:
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   100
            command.insert(0, 'o')
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   101
            command.append('e')
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   102
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   103
        command.append('l')
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   104
        for arg in args:
40225
474809790256 py3: use '%d' for integers instead of '%s'
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39619
diff changeset
   105
            command += "%d:%s" % (len(arg), arg)
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   106
        command.append('e')
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   107
        command = ''.join(command)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   108
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   109
        self.ui.debug("mtn: sending '%s'\n" % command)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   110
        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
   111
        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
   112
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   113
        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
   114
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   115
    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
   116
        read = None
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   117
        commandnbr = ''
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   118
        while read != ':':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   119
            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
   120
            if not read:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   121
                raise error.Abort(_('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
   122
            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
   123
        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
   124
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   125
        stream = 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
   126
        if stream not in 'mewptl':
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   127
            raise error.Abort(_('bad mtn packet - bad stream type %s') % stream)
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   128
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   129
        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
   130
        if read != ':':
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   131
            raise error.Abort(_('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
   132
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   133
        read = None
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   134
        lengthstr = ''
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   135
        while read != ':':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   136
            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
   137
            if not read:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   138
                raise error.Abort(_('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
   139
            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
   140
        try:
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   141
            length = long(lengthstr[:-1])
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   142
        except TypeError:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   143
            raise error.Abort(_('bad mtn packet - bad packet size %s')
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   144
                % lengthstr)
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 = 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
   147
        if len(read) != length:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   148
            raise error.Abort(_("bad mtn packet - unable to read full packet "
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 %s of %s") % (len(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
   150
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   151
        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
   152
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   153
    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
   154
        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
   155
        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
   156
            commandnbr, stream, length, output = self.mtnstdioreadpacket()
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   157
            self.ui.debug('mtn: read packet %s:%s:%s\n' %
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   158
                (commandnbr, stream, length))
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
            if stream == 'l':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   161
                # End of command
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   162
                if output != '0':
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   163
                    raise error.Abort(_("mtn command '%s' returned %s") %
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   164
                        (command, output))
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   165
                break
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   166
            elif stream in 'ew':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   167
                # Error, warning output
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   168
                self.ui.warn(_('%s error:\n') % self.command)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   169
                self.ui.warn(output)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   170
            elif stream == 'p':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   171
                # Progress messages
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   172
                self.ui.debug('mtn: ' + output)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   173
            elif stream == 'm':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   174
                # 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
   175
                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
   176
13792
a916e8de4313 convert/mtn: Fix conversion of large files from mtn (broken in ed97955e0c04)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13779
diff changeset
   177
        return ''.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
   178
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   179
    def mtnloadmanifest(self, rev):
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   180
        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
   181
            return
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   182
        self.manifest = self.mtnrun("get_manifest_of", rev).split("\n\n")
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   183
        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
   184
        self.files = {}
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   185
        self.dirs = {}
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   186
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   187
        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
   188
            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
   189
            if m:
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   190
                attr = ""
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   191
                name = m.group(1)
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   192
                node = m.group(2)
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   193
                if self.attr_execute_re.match(e):
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   194
                    attr += "x"
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   195
                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
   196
            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
   197
            if m:
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   198
                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
   199
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   200
    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
   201
        # 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
   202
        self.mtnloadmanifest(rev)
8458
f6c99b1628d7 convert: cleanups in monotone converter
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8250
diff changeset
   203
        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
   204
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   205
    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
   206
        self.mtnloadmanifest(rev)
8458
f6c99b1628d7 convert: cleanups in monotone converter
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8250
diff changeset
   207
        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
   208
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   209
    def mtngetcerts(self, rev):
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   210
        certs = {"author":"<missing>", "date":"<missing>",
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   211
            "changelog":"<missing>", "branch":"<missing>"}
9823
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   212
        certlist = self.mtnrun("certs", rev)
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   213
        # mtn < 0.45:
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   214
        #   key "test@selenic.com"
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   215
        # mtn >= 0.45:
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   216
        #   key [ff58a7ffb771907c4ff68995eada1c4da068d328]
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   217
        certlist = re.split('\n\n      key ["\[]', certlist)
11d7bb5e0df2 convert/mtn: handle change in mtn 0.45 certs output
Patrick Mezard <pmezard@gmail.com>
parents: 8458
diff changeset
   218
        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
   219
            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
   220
            if m:
6632
aa3f61884a48 convert.monotone: fix quotes and backslashes in change descriptions.
David Reiss <davidn@gmail.com>
parents: 6376
diff changeset
   221
                name, value = m.groups()
aa3f61884a48 convert.monotone: fix quotes and backslashes in change descriptions.
David Reiss <davidn@gmail.com>
parents: 6376
diff changeset
   222
                value = value.replace(r'\"', '"')
aa3f61884a48 convert.monotone: fix quotes and backslashes in change descriptions.
David Reiss <davidn@gmail.com>
parents: 6376
diff changeset
   223
                value = value.replace(r'\\', '\\')
aa3f61884a48 convert.monotone: fix quotes and backslashes in change descriptions.
David Reiss <davidn@gmail.com>
parents: 6376
diff changeset
   224
                certs[name] = value
8101
d8229670710f convert/mtn: handle subsecond commit dates (issue1616)
Paul Aurich <paul@darkrain42.org>
parents: 8099
diff changeset
   225
        # 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
   226
        # and all times are stored in UTC
da9f3866c637 convert/mtn: mtn does not record timezones, mark dates as UTC (issue1624)
Paul Aurich <paul@darkrain42.org>
parents: 8124
diff changeset
   227
        certs["date"] = certs["date"].split('.')[0] + " UTC"
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   228
        return certs
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   229
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   230
    # 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
   231
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   232
    def getheads(self):
25748
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
   233
        if not self.revs:
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   234
            return self.mtnrun("leaves").splitlines()
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   235
        else:
25748
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
   236
            return self.revs
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   237
22300
35ab037de989 convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents: 22296
diff changeset
   238
    def getchanges(self, rev, full):
35ab037de989 convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents: 22296
diff changeset
   239
        if full:
26779
aaa33ec3c951 grammar: use does instead of do where appropriate
timeless@mozdev.org
parents: 26587
diff changeset
   240
            raise error.Abort(_("convert from monotone does not support "
aaa33ec3c951 grammar: use does instead of do where appropriate
timeless@mozdev.org
parents: 26587
diff changeset
   241
                              "--full"))
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   242
        revision = self.mtnrun("get_revision", rev).split("\n\n")
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   243
        files = {}
8123
933b874e402f convert/mtn: handle files moved in a moved directory (issue1619/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8101
diff changeset
   244
        ignoremove = {}
8099
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   245
        renameddirs = []
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   246
        copies = {}
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   247
        for e in revision:
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   248
            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
   249
            if m:
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   250
                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
   251
                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
   252
            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
   253
            if m:
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   254
                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
   255
            # 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
   256
            # 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
   257
            # 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
   258
            m = self.delete_re.match(e)
b40e90341ae2 convert: record deleted files in monotone source
Patrick Mezard <pmezard@gmail.com>
parents: 6332
diff changeset
   259
            if m:
b40e90341ae2 convert: record deleted files in monotone source
Patrick Mezard <pmezard@gmail.com>
parents: 6332
diff changeset
   260
                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
   261
            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
   262
            if m:
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   263
                toname = m.group(2)
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   264
                fromname = m.group(1)
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   265
                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
   266
                    ignoremove[toname] = 1
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   267
                    copies[toname] = fromname
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   268
                    files[toname] = rev
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   269
                    files[fromname] = rev
8099
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   270
                elif self.mtnisdir(toname, rev):
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   271
                    renameddirs.append((fromname, toname))
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   272
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   273
        # 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
   274
        # all new files
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   275
        for fromdir, todir in renameddirs:
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   276
            renamed = {}
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   277
            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
   278
                if tofile in ignoremove:
8099
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   279
                    continue
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   280
                if tofile.startswith(todir + '/'):
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   281
                    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
   282
                    # Avoid chained moves like:
d883bfbd2e60 convert/mtn: handle directory move into moved directory (issue1619/3)
Patrick Mezard <pmezard@gmail.com>
parents: 8123
diff changeset
   283
                    # 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
   284
                    # d2 => d3
d883bfbd2e60 convert/mtn: handle directory move into moved directory (issue1619/3)
Patrick Mezard <pmezard@gmail.com>
parents: 8123
diff changeset
   285
                    ignoremove[tofile] = 1
8099
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   286
            for tofile, fromfile in renamed.items():
8100
233f11b544f5 Merge with crew-stable
Patrick Mezard <pmezard@gmail.com>
parents: 8052 8099
diff changeset
   287
                self.ui.debug (_("copying file in renamed directory "
233f11b544f5 Merge with crew-stable
Patrick Mezard <pmezard@gmail.com>
parents: 8052 8099
diff changeset
   288
                                 "from '%s' to '%s'")
8099
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   289
                               % (fromfile, tofile), '\n')
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   290
                files[tofile] = rev
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   291
                copies[tofile] = fromfile
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   292
            for fromfile in renamed.values():
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   293
                files[fromfile] = rev
3cdf4872941a convert/mtn: handle new files in moved directories (issue1619)
Patrick Mezard <pmezard@gmail.com>
parents: 8050
diff changeset
   294
24395
216fa1ba9993 convert: optimize convert of files that are unmodified from p2 in merges
Mads Kiilerich <madski@unity3d.com>
parents: 24178
diff changeset
   295
        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
   296
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   297
    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
   298
        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
   299
            return None, None
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   300
        try:
11134
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10938
diff changeset
   301
            data = self.mtnrun("get_file_of", name, r=rev)
16689
f366d4c2ff34 cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents: 16688
diff changeset
   302
        except Exception:
22296
650b5b6e75ed convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents: 17426
diff changeset
   303
            return None, None
11134
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10938
diff changeset
   304
        self.mtnloadmanifest(rev)
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10938
diff changeset
   305
        node, attr = self.files.get(name, (None, ""))
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10938
diff changeset
   306
        return data, attr
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   308
    def getcommit(self, rev):
13779
c13bfa451656 convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13761
diff changeset
   309
        extra = {}
c13bfa451656 convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13761
diff changeset
   310
        certs = self.mtngetcerts(rev)
c13bfa451656 convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13761
diff changeset
   311
        if certs.get('suspend') == certs["branch"]:
24178
8ca263d9f070 convert: when converting from monotone, use the number 1 for close in extras
Mads Kiilerich <madski@unity3d.com>
parents: 22300
diff changeset
   312
            extra['close'] = 1
36607
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36394
diff changeset
   313
        dateformat = "%Y-%m-%dT%H:%M:%S"
28372
74d03766f962 convert: monotone use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
   314
        return common.commit(
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   315
            author=certs["author"],
36607
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36394
diff changeset
   316
            date=dateutil.datestr(dateutil.strdate(certs["date"], dateformat)),
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   317
            desc=certs["changelog"],
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   318
            rev=rev,
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   319
            parents=self.mtnrun("parents", rev).splitlines(),
13779
c13bfa451656 convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13761
diff changeset
   320
            branch=certs["branch"],
c13bfa451656 convert/mtn: convert suspended branches as closed branches
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13761
diff changeset
   321
            extra=extra)
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   322
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   323
    def gettags(self):
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   324
        tags = {}
6307
6840668e3bf6 cleanup monotone conversion and use commandline class
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents: 6306
diff changeset
   325
        for e in self.mtnrun("tags").split("\n\n"):
6306
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   326
            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
   327
            if m:
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   328
                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
   329
        return tags
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   330
2f9de4aaea9e initial version of monotone source for convert extension
Mikkel Fahnøe Jørgensen <mikkel@dvide.com>
parents:
diff changeset
   331
    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
   332
        # 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
   333
        # ... and we don't support that
16687
e34106fa0dc3 cleanup: "raise SomeException()" -> "raise SomeException"
Brodie Rao <brodie@sf.io>
parents: 16231
diff changeset
   334
        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
   335
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   336
    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
   337
        # 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
   338
        version = 0.0
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   339
        try:
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   340
            versionstr = self.mtnrunsingle("interface_version")
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   341
            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
   342
        except Exception:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   343
            raise error.Abort(_("unable to determine mtn automate interface "
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   344
                "version"))
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   345
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   346
        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
   347
            self.automatestdio = True
39619
2aa12d7fcb4f py3: use "%f" for floats instead of "%s"
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36607
diff changeset
   348
            self.ui.debug("mtn automate version %f - using automate stdio\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
   349
                version)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   350
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   351
            # launch the long-running automate stdio process
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   352
            self.mtnwritefp, self.mtnreadfp = self._run2('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
   353
                '-d', self.path)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   354
            # 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
   355
            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
   356
            if read != 'format-version: 2\n':
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   357
                raise error.Abort(_('mtn automate stdio header unexpected: %s')
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   358
                    % read)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   359
            while read != '\n':
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   360
                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
   361
                if not read:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   362
                    raise error.Abort(_("failed to reach end of mtn automate "
13760
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   363
                        "stdio headers"))
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   364
        else:
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   365
            self.ui.debug("mtn automate version %s - not using 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
   366
                "(automate >= 12.0 - mtn >= 0.46 is needed)\n" % version)
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   367
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   368
    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
   369
        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
   370
            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
   371
            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
   372
            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
   373
            self.mtnreadfp = None
ed97955e0c04 convert/mtn: add support for using monotone's "automate stdio" when available
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11134
diff changeset
   374