hgext/convert/cvsps.py
author Greg Ward <greg-hg@gerg.ca>
Wed, 18 Mar 2009 09:15:38 -0400
changeset 7862 02981000012e
parent 7601 49355875c805
child 7950 9bbcfa898cd3
permissions -rw-r--r--
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     1
#
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     2
# Mercurial built-in replacement for cvsps.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     3
#
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     4
# Copyright 2008, Frank Kingswood <frank@kingswood-consulting.co.uk>
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     5
#
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     6
# This software may be used and distributed according to the terms
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     7
# of the GNU General Public License, incorporated herein by reference.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     8
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
     9
import os
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    10
import re
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    11
import cPickle as pickle
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    12
from mercurial import util
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    13
from mercurial.i18n import _
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    14
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    15
def listsort(list, key):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    16
    "helper to sort by key in Python 2.3"
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    17
    try:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    18
        list.sort(key=key)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    19
    except TypeError:
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
    20
        list.sort(lambda l, r: cmp(key(l), key(r)))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    21
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    22
class logentry(object):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    23
    '''Class logentry has the following attributes:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    24
        .author    - author name as CVS knows it
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    25
        .branch    - name of branch this revision is on
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    26
        .branches  - revision tuple of branches starting at this revision
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    27
        .comment   - commit message
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    28
        .date      - the commit date as a (time, tz) tuple
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    29
        .dead      - true if file revision is dead
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    30
        .file      - Name of file
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    31
        .lines     - a tuple (+lines, -lines) or None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    32
        .parent    - Previous revision of this entry
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    33
        .rcs       - name of file as returned from CVS
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    34
        .revision  - revision number as tuple
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    35
        .tags      - list of tags on the file
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
    36
        .synthetic - is this a synthetic "file ... added on ..." revision?
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    37
    '''
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    38
    def __init__(self, **entries):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    39
        self.__dict__.update(entries)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    40
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    41
class logerror(Exception):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    42
    pass
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    43
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    44
def getrepopath(cvspath):
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    45
    """Return the repository path from a CVS path.
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    46
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    47
    >>> getrepopath('/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    48
    '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    49
    >>> getrepopath('c:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    50
    'c:/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    51
    >>> getrepopath(':pserver:10/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    52
    '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    53
    >>> getrepopath(':pserver:10c:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    54
    '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    55
    >>> getrepopath(':pserver:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    56
    '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    57
    >>> getrepopath(':pserver:c:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    58
    'c:/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    59
    >>> getrepopath(':pserver:truc@foo.bar:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    60
    '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    61
    >>> getrepopath(':pserver:truc@foo.bar:c:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    62
    'c:/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    63
    """
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    64
    # According to CVS manual, CVS paths are expressed like:
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    65
    # [:method:][[user][:password]@]hostname[:[port]]/path/to/repository
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    66
    #
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    67
    # Unfortunately, Windows absolute paths start with a drive letter
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    68
    # like 'c:' making it harder to parse. Here we assume that drive
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    69
    # letters are only one character long and any CVS component before
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    70
    # the repository path is at least 2 characters long, and use this
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    71
    # to disambiguate.
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    72
    parts = cvspath.split(':')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    73
    if len(parts) == 1:
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    74
        return parts[0]
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    75
    # Here there is an ambiguous case if we have a port number
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    76
    # immediately followed by a Windows driver letter. We assume this
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    77
    # never happens and decide it must be CVS path component,
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    78
    # therefore ignoring it.
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    79
    if len(parts[-2]) > 1:
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    80
        return parts[-1].lstrip('0123456789')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    81
    return parts[-2] + ':' + parts[-1]
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
    82
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    83
def createlog(ui, directory=None, root="", rlog=True, cache=None):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    84
    '''Collect the CVS rlog'''
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    85
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    86
    # Because we store many duplicate commit log messages, reusing strings
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    87
    # saves a lot of memory and pickle storage space.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    88
    _scache = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    89
    def scache(s):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    90
        "return a shared version of a string"
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    91
        return _scache.setdefault(s, s)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    92
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    93
    ui.status(_('collecting CVS rlog\n'))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    94
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    95
    log = []      # list of logentry objects containing the CVS state
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    96
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    97
    # patterns to match in CVS (r)log output, by state of use
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    98
    re_00 = re.compile('RCS file: (.+)$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
    99
    re_01 = re.compile('cvs \\[r?log aborted\\]: (.+)$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   100
    re_02 = re.compile('cvs (r?log|server): (.+)\n$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   101
    re_03 = re.compile("(Cannot access.+CVSROOT)|(can't create temporary directory.+)$")
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   102
    re_10 = re.compile('Working file: (.+)$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   103
    re_20 = re.compile('symbolic names:')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   104
    re_30 = re.compile('\t(.+): ([\\d.]+)$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   105
    re_31 = re.compile('----------------------------$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   106
    re_32 = re.compile('=============================================================================$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   107
    re_50 = re.compile('revision ([\\d.]+)(\s+locked by:\s+.+;)?$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   108
    re_60 = re.compile(r'date:\s+(.+);\s+author:\s+(.+);\s+state:\s+(.+?);(\s+lines:\s+(\+\d+)?\s+(-\d+)?;)?')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   109
    re_70 = re.compile('branches: (.+);$')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   110
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   111
    file_added_re = re.compile(r'file [^/]+ was (initially )?added on branch')
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   112
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   113
    prefix = ''   # leading path to strip of what we get from CVS
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   114
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   115
    if directory is None:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   116
        # Current working directory
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   117
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   118
        # Get the real directory in the repository
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   119
        try:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   120
            prefix = file(os.path.join('CVS','Repository')).read().strip()
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   121
            if prefix == ".":
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   122
                prefix = ""
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   123
            directory = prefix
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   124
        except IOError:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   125
            raise logerror('Not a CVS sandbox')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   126
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
   127
        if prefix and not prefix.endswith(os.sep):
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
   128
            prefix += os.sep
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   129
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   130
        # Use the Root file in the sandbox, if it exists
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   131
        try:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   132
            root = file(os.path.join('CVS','Root')).read().strip()
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   133
        except IOError:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   134
            pass
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   135
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   136
    if not root:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   137
        root = os.environ.get('CVSROOT', '')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   138
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   139
    # read log cache if one exists
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   140
    oldlog = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   141
    date = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   142
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   143
    if cache:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   144
        cachedir = os.path.expanduser('~/.hg.cvsps')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   145
        if not os.path.exists(cachedir):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   146
            os.mkdir(cachedir)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   147
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   148
        # The cvsps cache pickle needs a uniquified name, based on the
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   149
        # repository location. The address may have all sort of nasties
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   150
        # in it, slashes, colons and such. So here we take just the
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   151
        # alphanumerics, concatenated in a way that does not mix up the
6696
49c0be9eb8c4 cvsps: fix a final whitespace nit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6688
diff changeset
   152
        # various components, so that
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   153
        #    :pserver:user@server:/path
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   154
        # and
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   155
        #    /pserver/user/server/path
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   156
        # are mapped to different cache file names.
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   157
        cachefile = root.split(":") + [directory, "cache"]
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   158
        cachefile = ['-'.join(re.findall(r'\w+', s)) for s in cachefile if s]
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   159
        cachefile = os.path.join(cachedir,
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   160
                                 '.'.join([s for s in cachefile if s]))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   161
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   162
    if cache == 'update':
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   163
        try:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   164
            ui.note(_('reading cvs log cache %s\n') % cachefile)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   165
            oldlog = pickle.load(file(cachefile))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   166
            ui.note(_('cache has %d log entries\n') % len(oldlog))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   167
        except Exception, e:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   168
            ui.note(_('error reading cache: %r\n') % e)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   169
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   170
        if oldlog:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   171
            date = oldlog[-1].date    # last commit date as a (time,tz) tuple
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   172
            date = util.datestr(date, '%Y/%m/%d %H:%M:%S %1%2')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   173
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   174
    # build the CVS commandline
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   175
    cmd = ['cvs', '-q']
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   176
    if root:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   177
        cmd.append('-d%s' % root)
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
   178
        p = util.normpath(getrepopath(root))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   179
        if not p.endswith('/'):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   180
            p += '/'
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
   181
        prefix = p + util.normpath(prefix)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   182
    cmd.append(['log', 'rlog'][rlog])
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   183
    if date:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   184
        # no space between option and date string
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   185
        cmd.append('-d>%s' % date)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   186
    cmd.append(directory)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   187
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   188
    # state machine begins here
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   189
    tags = {}     # dictionary of revisions on current file with their tags
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   190
    state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   191
    store = False # set when a new record can be appended
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   192
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   193
    cmd = [util.shellquote(arg) for arg in cmd]
6956
12472a240398 i18n: mark strings for translation in convert extension
Martin Geisler <mg@daimi.au.dk>
parents: 6762
diff changeset
   194
    ui.note(_("running %s\n") % (' '.join(cmd)))
12472a240398 i18n: mark strings for translation in convert extension
Martin Geisler <mg@daimi.au.dk>
parents: 6762
diff changeset
   195
    ui.debug(_("prefix=%r directory=%r root=%r\n") % (prefix, directory, root))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   196
7593
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   197
    pfp = util.popen(' '.join(cmd))
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   198
    peek = pfp.readline()
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   199
    while True:
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   200
        line = peek
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   201
        if line == '':
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   202
            break
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   203
        peek = pfp.readline()
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   204
        if line.endswith('\n'):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   205
            line = line[:-1]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   206
        #ui.debug('state=%d line=%r\n' % (state, line))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   207
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   208
        if state == 0:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   209
            # initial state, consume input until we see 'RCS file'
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   210
            match = re_00.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   211
            if match:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   212
                rcs = match.group(1)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   213
                tags = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   214
                if rlog:
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
   215
                    filename = util.normpath(rcs[:-2])
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   216
                    if filename.startswith(prefix):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   217
                        filename = filename[len(prefix):]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   218
                    if filename.startswith('/'):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   219
                        filename = filename[1:]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   220
                    if filename.startswith('Attic/'):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   221
                        filename = filename[6:]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   222
                    else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   223
                        filename = filename.replace('/Attic/', '/')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   224
                    state = 2
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   225
                    continue
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   226
                state = 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   227
                continue
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   228
            match = re_01.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   229
            if match:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   230
                raise Exception(match.group(1))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   231
            match = re_02.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   232
            if match:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   233
                raise Exception(match.group(2))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   234
            if re_03.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   235
                raise Exception(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   236
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   237
        elif state == 1:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   238
            # expect 'Working file' (only when using log instead of rlog)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   239
            match = re_10.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   240
            assert match, _('RCS file must be followed by working file')
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
   241
            filename = util.normpath(match.group(1))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   242
            state = 2
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   243
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   244
        elif state == 2:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   245
            # expect 'symbolic names'
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   246
            if re_20.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   247
                state = 3
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   248
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   249
        elif state == 3:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   250
            # read the symbolic names and store as tags
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   251
            match = re_30.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   252
            if match:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   253
                rev = [int(x) for x in match.group(2).split('.')]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   254
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   255
                # Convert magic branch number to an odd-numbered one
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   256
                revn = len(rev)
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   257
                if revn > 3 and (revn % 2) == 0 and rev[-2] == 0:
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   258
                    rev = rev[:-2] + rev[-1:]
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   259
                rev = tuple(rev)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   260
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   261
                if rev not in tags:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   262
                    tags[rev] = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   263
                tags[rev].append(match.group(1))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   264
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   265
            elif re_31.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   266
                state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   267
            elif re_32.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   268
                state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   269
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   270
        elif state == 4:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   271
            # expecting '------' separator before first revision
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   272
            if re_31.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   273
                state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   274
            else:
7599
7bf7c073375e lowercase ui.debug and assert output
Martin Geisler <mg@daimi.au.dk>
parents: 7573
diff changeset
   275
                assert not re_32.match(line), _('must have at least some revisions')
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   276
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   277
        elif state == 5:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   278
            # expecting revision number and possibly (ignored) lock indication
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   279
            # we create the logentry here from values stored in states 0 to 4,
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   280
            # as this state is re-entered for subsequent revisions of a file.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   281
            match = re_50.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   282
            assert match, _('expected revision number')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   283
            e = logentry(rcs=scache(rcs), file=scache(filename),
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   284
                    revision=tuple([int(x) for x in match.group(1).split('.')]),
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   285
                    branches=[], parent=None,
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   286
                    synthetic=False)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   287
            state = 6
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   288
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   289
        elif state == 6:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   290
            # expecting date, author, state, lines changed
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   291
            match = re_60.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   292
            assert match, _('revision must be followed by date line')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   293
            d = match.group(1)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   294
            if d[2] == '/':
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   295
                # Y2K
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   296
                d = '19' + d
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   297
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   298
            if len(d.split()) != 3:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   299
                # cvs log dates always in GMT
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   300
                d = d + ' UTC'
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   301
            e.date = util.parsedate(d, ['%y/%m/%d %H:%M:%S', '%Y/%m/%d %H:%M:%S', '%Y-%m-%d %H:%M:%S'])
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   302
            e.author = scache(match.group(2))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   303
            e.dead = match.group(3).lower() == 'dead'
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   304
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   305
            if match.group(5):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   306
                if match.group(6):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   307
                    e.lines = (int(match.group(5)), int(match.group(6)))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   308
                else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   309
                    e.lines = (int(match.group(5)), 0)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   310
            elif match.group(6):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   311
                e.lines = (0, int(match.group(6)))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   312
            else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   313
                e.lines = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   314
            e.comment = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   315
            state = 7
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   316
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   317
        elif state == 7:
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   318
            # read the revision numbers of branches that start at this revision
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   319
            # or store the commit log message otherwise
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   320
            m = re_70.match(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   321
            if m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   322
                e.branches = [tuple([int(y) for y in x.strip().split('.')])
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   323
                                for x in m.group(1).split(';')]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   324
                state = 8
7593
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
   325
            elif re_31.match(line) and re_50.match(peek):
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   326
                state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   327
                store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   328
            elif re_32.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   329
                state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   330
                store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   331
            else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   332
                e.comment.append(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   333
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   334
        elif state == 8:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   335
            # store commit log message
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   336
            if re_31.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   337
                state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   338
                store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   339
            elif re_32.match(line):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   340
                state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   341
                store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   342
            else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   343
                e.comment.append(line)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   344
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   345
        # When a file is added on a branch B1, CVS creates a synthetic
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   346
        # dead trunk revision 1.1 so that the branch has a root.
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   347
        # Likewise, if you merge such a file to a later branch B2 (one
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   348
        # that already existed when the file was added on B1), CVS
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   349
        # creates a synthetic dead revision 1.1.x.1 on B2.  Don't drop
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   350
        # these revisions now, but mark them synthetic so
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   351
        # createchangeset() can take care of them.
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   352
        if (store and
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   353
              e.dead and
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   354
              e.revision[-1] == 1 and      # 1.1 or 1.1.x.1
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   355
              len(e.comment) == 1 and
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   356
              file_added_re.match(e.comment[0])):
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   357
            ui.debug(_('found synthetic rev in %s: %r\n')
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   358
                     % (e.rcs, e.comment[0]))
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   359
            e.synthetic = True
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   360
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   361
        if store:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   362
            # clean up the results and save in the log.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   363
            store = False
6762
f67d1468ac50 util: add sort helper
Matt Mackall <mpm@selenic.com>
parents: 6699
diff changeset
   364
            e.tags = util.sort([scache(x) for x in tags.get(e.revision, [])])
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   365
            e.comment = scache('\n'.join(e.comment))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   366
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   367
            revn = len(e.revision)
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   368
            if revn > 3 and (revn % 2) == 0:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   369
                e.branch = tags.get(e.revision[:-1], [None])[0]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   370
            else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   371
                e.branch = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   372
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   373
            log.append(e)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   374
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   375
            if len(log) % 100 == 0:
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   376
                ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80)+'\n')
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   377
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   378
    listsort(log, key=lambda x:(x.rcs, x.revision))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   379
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   380
    # find parent revisions of individual files
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   381
    versions = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   382
    for e in log:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   383
        branch = e.revision[:-1]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   384
        p = versions.get((e.rcs, branch), None)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   385
        if p is None:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   386
            p = e.revision[:-2]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   387
        e.parent = p
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   388
        versions[(e.rcs, branch)] = e.revision
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   389
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   390
    # update the log cache
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   391
    if cache:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   392
        if log:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   393
            # join up the old and new logs
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   394
            listsort(log, key=lambda x:x.date)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   395
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   396
            if oldlog and oldlog[-1].date >= log[0].date:
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   397
                raise logerror('Log cache overlaps with new log entries,'
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   398
                               ' re-run without cache.')
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   399
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   400
            log = oldlog + log
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   401
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   402
            # write the new cachefile
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   403
            ui.note(_('writing cvs log cache %s\n') % cachefile)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   404
            pickle.dump(log, file(cachefile, 'w'))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   405
        else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   406
            log = oldlog
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   407
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   408
    ui.status(_('%d log entries\n') % len(log))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   409
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   410
    return log
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   411
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   412
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   413
class changeset(object):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   414
    '''Class changeset has the following attributes:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   415
        .author    - author name as CVS knows it
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   416
        .branch    - name of branch this changeset is on, or None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   417
        .comment   - commit message
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   418
        .date      - the commit date as a (time,tz) tuple
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   419
        .entries   - list of logentry objects in this changeset
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   420
        .parents   - list of one or two parent changesets
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   421
        .tags      - list of tags on this changeset
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   422
        .synthetic - from synthetic revision "file ... added on branch ..."
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   423
    '''
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   424
    def __init__(self, **entries):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   425
        self.__dict__.update(entries)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   426
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   427
def createchangeset(ui, log, fuzz=60, mergefrom=None, mergeto=None):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   428
    '''Convert log into changesets.'''
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   429
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   430
    ui.status(_('creating changesets\n'))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   431
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   432
    # Merge changesets
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   433
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   434
    listsort(log, key=lambda x:(x.comment, x.author, x.branch, x.date))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   435
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   436
    changesets = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   437
    files = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   438
    c = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   439
    for i, e in enumerate(log):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   440
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   441
        # Check if log entry belongs to the current changeset or not.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   442
        if not (c and
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   443
                  e.comment == c.comment and
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   444
                  e.author == c.author and
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   445
                  e.branch == c.branch and
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   446
                  ((c.date[0] + c.date[1]) <=
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   447
                   (e.date[0] + e.date[1]) <=
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   448
                   (c.date[0] + c.date[1]) + fuzz) and
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   449
                  e.file not in files):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   450
            c = changeset(comment=e.comment, author=e.author,
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   451
                          branch=e.branch, date=e.date, entries=[])
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   452
            changesets.append(c)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   453
            files = {}
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   454
            if len(changesets) % 100 == 0:
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   455
                t = '%d %s' % (len(changesets), repr(e.comment)[1:-1])
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   456
                ui.status(util.ellipsis(t, 80) + '\n')
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   457
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   458
        c.entries.append(e)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   459
        files[e.file] = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   460
        c.date = e.date       # changeset date is date of latest commit in it
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   461
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   462
    # Mark synthetic changesets
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   463
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   464
    for c in changesets:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   465
        # Synthetic revisions always get their own changeset, because
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   466
        # the log message includes the filename.  E.g. if you add file3
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   467
        # and file4 on a branch, you get four log entries and three
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   468
        # changesets:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   469
        #   "File file3 was added on branch ..." (synthetic, 1 entry)
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   470
        #   "File file4 was added on branch ..." (synthetic, 1 entry)
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   471
        #   "Add file3 and file4 to fix ..."     (real, 2 entries)
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   472
        # Hence the check for 1 entry here.
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   473
        c.synthetic = (len(c.entries) == 1 and c.entries[0].synthetic)
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   474
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   475
    # Sort files in each changeset
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   476
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   477
    for c in changesets:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   478
        def pathcompare(l, r):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   479
            'Mimic cvsps sorting order'
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   480
            l = l.split('/')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   481
            r = r.split('/')
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   482
            nl = len(l)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   483
            nr = len(r)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   484
            n = min(nl, nr)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   485
            for i in range(n):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   486
                if i + 1 == nl and nl < nr:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   487
                    return -1
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   488
                elif i + 1 == nr and nl > nr:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   489
                    return +1
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   490
                elif l[i] < r[i]:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   491
                    return -1
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   492
                elif l[i] > r[i]:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   493
                    return +1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   494
            return 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   495
        def entitycompare(l, r):
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   496
            return pathcompare(l.file, r.file)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   497
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   498
        c.entries.sort(entitycompare)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   499
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   500
    # Sort changesets by date
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   501
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   502
    def cscmp(l, r):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   503
        d = sum(l.date) - sum(r.date)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   504
        if d:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   505
            return d
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   506
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   507
        # detect vendor branches and initial commits on a branch
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   508
        le = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   509
        for e in l.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   510
            le[e.rcs] = e.revision
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   511
        re = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   512
        for e in r.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   513
            re[e.rcs] = e.revision
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   514
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   515
        d = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   516
        for e in l.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   517
            if re.get(e.rcs, None) == e.parent:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   518
                assert not d
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   519
                d = 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   520
                break
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   521
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   522
        for e in r.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   523
            if le.get(e.rcs, None) == e.parent:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   524
                assert not d
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   525
                d = -1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   526
                break
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   527
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   528
        return d
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   529
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   530
    changesets.sort(cscmp)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   531
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   532
    # Collect tags
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   533
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   534
    globaltags = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   535
    for c in changesets:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   536
        tags = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   537
        for e in c.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   538
            for tag in e.tags:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   539
                # remember which is the latest changeset to have this tag
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   540
                globaltags[tag] = c
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   541
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   542
    for c in changesets:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   543
        tags = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   544
        for e in c.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   545
            for tag in e.tags:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   546
                tags[tag] = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   547
        # remember tags only if this is the latest changeset to have it
6762
f67d1468ac50 util: add sort helper
Matt Mackall <mpm@selenic.com>
parents: 6699
diff changeset
   548
        c.tags = util.sort([tag for tag in tags if globaltags[tag] is c])
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   549
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   550
    # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   551
    # by inserting dummy changesets with two parents, and handle
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   552
    # {{mergefrombranch BRANCHNAME}} by setting two parents.
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   553
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   554
    if mergeto is None:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   555
        mergeto = r'{{mergetobranch ([-\w]+)}}'
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   556
    if mergeto:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   557
        mergeto = re.compile(mergeto)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   558
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   559
    if mergefrom is None:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   560
        mergefrom = r'{{mergefrombranch ([-\w]+)}}'
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   561
    if mergefrom:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   562
        mergefrom = re.compile(mergefrom)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   563
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   564
    versions = {}    # changeset index where we saw any particular file version
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   565
    branches = {}    # changeset index where we saw a branch
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   566
    n = len(changesets)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   567
    i = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   568
    while i<n:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   569
        c = changesets[i]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   570
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   571
        for f in c.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   572
            versions[(f.rcs, f.revision)] = i
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   573
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   574
        p = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   575
        if c.branch in branches:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   576
            p = branches[c.branch]
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   577
        else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   578
            for f in c.entries:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   579
                p = max(p, versions.get((f.rcs, f.parent), None))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   580
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   581
        c.parents = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   582
        if p is not None:
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   583
            p = changesets[p]
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   584
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   585
            # Ensure no changeset has a synthetic changeset as a parent.
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   586
            while p.synthetic:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   587
                assert len(p.parents) <= 1, \
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   588
                       _('synthetic changeset cannot have multiple parents')
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   589
                if p.parents:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   590
                    p = p.parents[0]
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   591
                else:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   592
                    p = None
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   593
                    break
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   594
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   595
            if p is not None:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   596
                c.parents.append(p)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   597
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   598
        if mergefrom:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   599
            m = mergefrom.search(c.comment)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   600
            if m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   601
                m = m.group(1)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   602
                if m == 'HEAD':
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   603
                    m = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   604
                if m in branches and c.branch != m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   605
                    c.parents.append(changesets[branches[m]])
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   606
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   607
        if mergeto:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   608
            m = mergeto.search(c.comment)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   609
            if m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   610
                try:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   611
                    m = m.group(1)
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   612
                    if m == 'HEAD':
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   613
                        m = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   614
                except:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   615
                    m = None   # if no group found then merge to HEAD
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   616
                if m in branches and c.branch != m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   617
                    # insert empty changeset for merge
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   618
                    cc = changeset(author=c.author, branch=m, date=c.date,
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   619
                            comment='convert-repo: CVS merge from branch %s' % c.branch,
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   620
                            entries=[], tags=[], parents=[changesets[branches[m]], c])
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   621
                    changesets.insert(i + 1, cc)
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   622
                    branches[m] = i + 1
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   623
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   624
                    # adjust our loop counters now we have inserted a new entry
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   625
                    n += 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   626
                    i += 2
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   627
                    continue
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   628
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   629
        branches[c.branch] = i
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   630
        i += 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   631
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   632
    # Drop synthetic changesets (safe now that we have ensured no other
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   633
    # changesets can have them as parents).
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   634
    i = 0
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   635
    while i < len(changesets):
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   636
        if changesets[i].synthetic:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   637
            del changesets[i]
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   638
        else:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   639
            i += 1
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
   640
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   641
    # Number changesets
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   642
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   643
    for i, c in enumerate(changesets):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
   644
        c.id = i + 1
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   645
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   646
    ui.status(_('%d changeset entries\n') % len(changesets))
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   647
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
   648
    return changesets
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   649
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   650
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   651
def debugcvsps(ui, *args, **opts):
7573
8bea01a65391 cvsps: kill some more trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7502
diff changeset
   652
    '''Read CVS rlog for current directory or named path in repository, and
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   653
    convert the log to changesets based on matching commit log entries and dates.'''
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   654
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   655
    if opts["new_cache"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   656
        cache = "write"
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   657
    elif opts["update_cache"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   658
        cache = "update"
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   659
    else:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   660
        cache = None
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   661
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   662
    revisions = opts["revisions"]
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   663
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   664
    try:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   665
        if args:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   666
            log = []
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   667
            for d in args:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   668
                log += createlog(ui, d, root=opts["root"], cache=cache)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   669
        else:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   670
            log = createlog(ui, root=opts["root"], cache=cache)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   671
    except logerror, e:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   672
        ui.write("%r\n"%e)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   673
        return
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   674
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   675
    changesets = createchangeset(ui, log, opts["fuzz"])
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   676
    del log
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   677
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   678
    # Print changesets (optionally filtered)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   679
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   680
    off = len(revisions)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   681
    branches = {}    # latest version number in each branch
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   682
    ancestors = {}   # parent branch
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   683
    for cs in changesets:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   684
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   685
        if opts["ancestors"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   686
            if cs.branch not in branches and cs.parents and cs.parents[0].id:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   687
                ancestors[cs.branch] = changesets[cs.parents[0].id-1].branch, cs.parents[0].id
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   688
            branches[cs.branch] = cs.id
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   689
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   690
        # limit by branches
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   691
        if opts["branches"] and (cs.branch or 'HEAD') not in opts["branches"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   692
            continue
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   693
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   694
        if not off:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   695
            # Note: trailing spaces on several lines here are needed to have
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   696
            #       bug-for-bug compatibility with cvsps.
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   697
            ui.write('---------------------\n')
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   698
            ui.write('PatchSet %d \n' % cs.id)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   699
            ui.write('Date: %s\n' % util.datestr(cs.date, '%Y/%m/%d %H:%M:%S %1%2'))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   700
            ui.write('Author: %s\n' % cs.author)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   701
            ui.write('Branch: %s\n' % (cs.branch or 'HEAD'))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   702
            ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags)>1],
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   703
                                  ','.join(cs.tags) or '(none)'))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   704
            if opts["parents"] and cs.parents:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   705
                if len(cs.parents)>1:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   706
                    ui.write('Parents: %s\n' % (','.join([str(p.id) for p in cs.parents])))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   707
                else:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   708
                    ui.write('Parent: %d\n' % cs.parents[0].id)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   709
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   710
            if opts["ancestors"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   711
                b = cs.branch
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   712
                r = []
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   713
                while b:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   714
                    b, c = ancestors[b]
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   715
                    r.append('%s:%d:%d' % (b or "HEAD", c, branches[b]))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   716
                if r:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   717
                    ui.write('Ancestors: %s\n' % (','.join(r)))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   718
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   719
            ui.write('Log:\n')
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   720
            ui.write('%s\n\n' % cs.comment)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   721
            ui.write('Members: \n')
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   722
            for f in cs.entries:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   723
                fn = f.file
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   724
                if fn.startswith(opts["prefix"]):
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   725
                    fn = fn[len(opts["prefix"]):]
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   726
                ui.write('\t%s:%s->%s%s \n' % (fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL',
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   727
                                          '.'.join([str(x) for x in f.revision]), ['', '(DEAD)'][f.dead]))
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   728
            ui.write('\n')
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   729
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   730
        # have we seen the start tag?
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   731
        if revisions and off:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   732
            if revisions[0] == str(cs.id) or \
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   733
                revisions[0] in cs.tags:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   734
                off = False
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   735
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   736
        # see if we reached the end tag
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   737
        if len(revisions)>1 and not off:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   738
            if revisions[1] == str(cs.id) or \
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   739
                revisions[1] in cs.tags:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
   740
                break