annotate hgext/convert/cvsps.py @ 29490:b4d117cee636

policy: add cffi policy for PyPy This adds cffi policy in the case where we don't want to use C modules, but instead we're happy to rely on cffi (bundled with pypy)
author Maciej Fijalkowski <fijall@gmail.com>
date Tue, 07 Jun 2016 15:35:58 +0200
parents b501579147f1
children 6f9fcd29e290
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
1 # 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
2 #
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
3 # 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
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8209
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9467
diff changeset
6 # GNU General Public License version 2 or any later version.
28369
71176606fa0a convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents: 26593
diff changeset
7 from __future__ import absolute_import
6687
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
28369
71176606fa0a convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents: 26593
diff changeset
11
29205
a0939666b836 py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents: 28369
diff changeset
12 from mercurial.i18n import _
28369
71176606fa0a convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents: 26593
diff changeset
13 from mercurial import (
71176606fa0a convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents: 26593
diff changeset
14 hook,
71176606fa0a convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents: 26593
diff changeset
15 util,
71176606fa0a convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents: 26593
diff changeset
16 )
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
17
29324
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29205
diff changeset
18 pickle = util.pickle
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29205
diff changeset
19
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
20 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
21 '''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
22 .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
23 .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
24 .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
25 .comment - commit message
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
26 .commitid - CVS commitid or None
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
27 .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
28 .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
29 .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
30 .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
31 .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
32 .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
33 .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
34 .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
35 .synthetic - is this a synthetic "file ... added on ..." revision?
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
36 .mergepoint - the branch that has been merged from (if present in
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
37 rlog output) or None
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
38 .branchpoints - the branches that start at the current entry or empty
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
39 '''
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
40 def __init__(self, **entries):
10701
35893dcfd40c cvsps: fix traceback involving 'synthetic'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10695
diff changeset
41 self.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
42 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
43
8080
19229b0b292d cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents: 8079
diff changeset
44 def __repr__(self):
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
45 items = ("%s=%r"%(k, self.__dict__[k]) for k in sorted(self.__dict__))
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
46 return "%s(%s)"%(type(self).__name__, ", ".join(items))
8080
19229b0b292d cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents: 8079
diff changeset
47
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
48 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
49 pass
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
50
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
51 def getrepopath(cvspath):
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
52 """Return the repository path from a CVS path.
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
53
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
54 >>> getrepopath('/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
55 '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
56 >>> getrepopath('c:/foo/bar')
19145
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
57 '/foo/bar'
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
58 >>> getrepopath(':pserver:10/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
59 '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
60 >>> getrepopath(':pserver:10c:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
61 '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
62 >>> getrepopath(':pserver:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
63 '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
64 >>> getrepopath(':pserver:c:/foo/bar')
19145
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
65 '/foo/bar'
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
66 >>> getrepopath(':pserver:truc@foo.bar:/foo/bar')
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
67 '/foo/bar'
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
68 >>> getrepopath(':pserver:truc@foo.bar:c:/foo/bar')
19145
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
69 '/foo/bar'
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
70 >>> getrepopath('user@server/path/to/repository')
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
71 '/path/to/repository'
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
72 """
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
73 # 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
74 # [:method:][[user][:password]@]hostname[:[port]]/path/to/repository
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
75 #
19145
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
76 # CVSpath is splitted into parts and then position of the first occurrence
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
77 # of the '/' char after the '@' is located. The solution is the rest of the
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
78 # string after that '/' sign including it
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
79
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
80 parts = cvspath.split(':')
19145
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
81 atposition = parts[-1].find('@')
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
82 start = 0
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
83
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
84 if atposition != -1:
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
85 start = atposition
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
86
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
87 repopath = parts[-1][parts[-1].find('/', start):]
0a12e5f3a979 convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents: 18718
diff changeset
88 return repopath
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
89
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
90 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
91 '''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
92
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
93 # 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
94 # 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
95 _scache = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
96 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
97 "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
98 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
99
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
100 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
101
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
102 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
103
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
104 # 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
105 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
106 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
107 re_02 = re.compile('cvs (r?log|server): (.+)\n$')
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
108 re_03 = re.compile("(Cannot access.+CVSROOT)|"
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
109 "(can't create temporary directory.+)$")
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
110 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
111 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
112 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
113 re_31 = re.compile('----------------------------$')
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
114 re_32 = re.compile('======================================='
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
115 '======================================$')
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
116 re_50 = re.compile('revision ([\\d.]+)(\s+locked by:\s+.+;)?$')
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
117 re_60 = re.compile(r'date:\s+(.+);\s+author:\s+(.+);\s+state:\s+(.+?);'
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
118 r'(\s+lines:\s+(\+\d+)?\s+(-\d+)?;)?'
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
119 r'(\s+commitid:\s+([^;]+);)?'
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
120 r'(.*mergepoint:\s+([^;]+);)?')
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
121 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
122
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
123 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
124
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
125 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
126
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
127 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
128 # 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
129
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
130 # 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
131 try:
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 8890
diff changeset
132 prefix = open(os.path.join('CVS','Repository')).read().strip()
10695
b4b16e90712f convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents: 10282
diff changeset
133 directory = prefix
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
134 if prefix == ".":
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
135 prefix = ""
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
136 except IOError:
10939
9f6731b03906 convert: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents: 10701
diff changeset
137 raise logerror(_('not a CVS sandbox'))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
138
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
139 if prefix and not prefix.endswith(os.sep):
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
140 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
141
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
142 # 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
143 try:
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 8890
diff changeset
144 root = open(os.path.join('CVS','Root')).read().strip()
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
145 except IOError:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
146 pass
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 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
149 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
150
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
151 # 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
152 oldlog = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
153 date = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
154
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
155 if cache:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
156 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
157 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
158 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
159
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
160 # 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
161 # 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
162 # in it, slashes, colons and such. So here we take just the
17424
e7cfe3587ea4 fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents: 16688
diff changeset
163 # alphanumeric characters, concatenated in a way that does not
e7cfe3587ea4 fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents: 16688
diff changeset
164 # mix up the 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
165 # :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
166 # and
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
167 # /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
168 # are mapped to different cache file names.
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
169 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
170 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
171 cachefile = os.path.join(cachedir,
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
172 '.'.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
173
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
174 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
175 try:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
176 ui.note(_('reading cvs log cache %s\n') % cachefile)
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 8890
diff changeset
177 oldlog = pickle.load(open(cachefile))
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
178 for e in oldlog:
18286
762f12b8ebae cvsps: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 18265
diff changeset
179 if not (util.safehasattr(e, 'branchpoints') and
762f12b8ebae cvsps: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 18265
diff changeset
180 util.safehasattr(e, 'commitid') and
762f12b8ebae cvsps: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 18265
diff changeset
181 util.safehasattr(e, 'mergepoint')):
762f12b8ebae cvsps: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 18265
diff changeset
182 ui.status(_('ignoring old cache\n'))
762f12b8ebae cvsps: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 18265
diff changeset
183 oldlog = []
762f12b8ebae cvsps: fix indentation
Idan Kamara <idankk86@gmail.com>
parents: 18265
diff changeset
184 break
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
185
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
186 ui.note(_('cache has %d log entries\n') % len(oldlog))
25660
328739ea70c3 global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24305
diff changeset
187 except Exception as e:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
188 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
189
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
190 if oldlog:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
191 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
192 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
193
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
194 # 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
195 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
196 if root:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
197 cmd.append('-d%s' % root)
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
198 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
199 if not p.endswith('/'):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
200 p += '/'
10695
b4b16e90712f convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents: 10282
diff changeset
201 if prefix:
b4b16e90712f convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents: 10282
diff changeset
202 # looks like normpath replaces "" by "."
b4b16e90712f convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents: 10282
diff changeset
203 prefix = p + util.normpath(prefix)
b4b16e90712f convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents: 10282
diff changeset
204 else:
b4b16e90712f convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents: 10282
diff changeset
205 prefix = p
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
206 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
207 if date:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
208 # 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
209 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
210 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
211
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
212 # 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
213 tags = {} # dictionary of revisions on current file with their tags
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
214 branchmap = {} # mapping between branch names and revision numbers
26593
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
215 rcsmap = {}
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
216 state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
217 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
218
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
219 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
220 ui.note(_("running %s\n") % (' '.join(cmd)))
9467
4c041f1ee1b4 do not attempt to translate ui.debug output
Martin Geisler <mg@lazybytes.net>
parents: 9032
diff changeset
221 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
222
7593
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
223 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
224 peek = pfp.readline()
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
225 while True:
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
226 line = peek
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
227 if line == '':
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
228 break
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
229 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
230 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
231 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
232 #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
233
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
234 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
235 # 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
236 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
237 if match:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
238 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
239 tags = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
240 if rlog:
7097
d4218edd55bd convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 6956
diff changeset
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
249 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
250 state = 2
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
251 continue
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
252 state = 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
253 continue
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
254 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
255 if match:
11122
2114e44b08f6 clean up remaining generic exceptions
Matt Mackall <mpm@selenic.com>
parents: 10950
diff changeset
256 raise logerror(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
257 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
258 if match:
11122
2114e44b08f6 clean up remaining generic exceptions
Matt Mackall <mpm@selenic.com>
parents: 10950
diff changeset
259 raise logerror(match.group(2))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
260 if re_03.match(line):
11122
2114e44b08f6 clean up remaining generic exceptions
Matt Mackall <mpm@selenic.com>
parents: 10950
diff changeset
261 raise logerror(line)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
262
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
263 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
264 # 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
265 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
266 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
267 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
268 state = 2
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 == 2:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
271 # 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
272 if re_20.match(line):
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
273 branchmap = {}
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
274 state = 3
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
275
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
276 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
277 # 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
278 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
279 if match:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
280 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
281
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
282 # 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
283 revn = len(rev)
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
284 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
285 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
286 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
287
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
288 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
289 tags[rev] = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
290 tags[rev].append(match.group(1))
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
291 branchmap[match.group(1)] = match.group(2)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
292
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
293 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
294 state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
295 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
296 state = 0
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 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
299 # 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
300 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
301 state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
302 else:
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
303 assert not re_32.match(line), _('must have at least '
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
304 '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
305
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
306 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
307 # 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
308 # 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
309 # 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
310 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
311 assert match, _('expected revision number')
18265
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
312 e = logentry(rcs=scache(rcs),
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
313 file=scache(filename),
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
314 revision=tuple([int(x) for x in
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
315 match.group(1).split('.')]),
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
316 branches=[],
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
317 parent=None,
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
318 commitid=None,
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
319 mergepoint=None,
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
320 branchpoints=set())
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
321
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
322 state = 6
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
323
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
324 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
325 # 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
326 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
327 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
328 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
329 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
330 # Y2K
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
331 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
332
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
333 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
334 # cvs log dates always in GMT
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
335 d = d + ' UTC'
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
336 e.date = util.parsedate(d, ['%y/%m/%d %H:%M:%S',
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
337 '%Y/%m/%d %H:%M:%S',
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
338 '%Y-%m-%d %H:%M:%S'])
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
339 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
340 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
341
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
342 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
343 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
344 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
345 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
346 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
347 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
348 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
349 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
350 e.lines = None
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
351
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
352 if match.group(7): # cvs 1.12 commitid
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
353 e.commitid = match.group(8)
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
354
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
355 if match.group(9): # cvsnt mergepoint
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
356 myrev = match.group(10).split('.')
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
357 if len(myrev) == 2: # head
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
358 e.mergepoint = 'HEAD'
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
359 else:
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
360 myrev = '.'.join(myrev[:-2] + ['0', myrev[-2]])
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
361 branches = [b for b in branchmap if branchmap[b] == myrev]
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 15790
diff changeset
362 assert len(branches) == 1, ('unknown branch: %s'
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 15790
diff changeset
363 % e.mergepoint)
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
364 e.mergepoint = branches[0]
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
365
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
366 e.comment = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
367 state = 7
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
368
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
369 elif state == 7:
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
370 # 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
371 # 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
372 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
373 if m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
374 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
375 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
376 state = 8
7593
9811cc670c51 cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents: 7573
diff changeset
377 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
378 state = 5
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
379 store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
380 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
381 state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
382 store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
383 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
384 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
385
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
386 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
387 # 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
388 if re_31.match(line):
15205
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
389 cpeek = peek
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
390 if cpeek.endswith('\n'):
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
391 cpeek = cpeek[:-1]
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
392 if re_50.match(cpeek):
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
393 state = 5
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
394 store = True
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
395 else:
4e5b7d130e76 convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents: 14945
diff changeset
396 e.comment.append(line)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
397 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
398 state = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
399 store = True
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
400 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
401 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
402
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
403 # 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
404 # 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
405 # 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
406 # 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
407 # 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
408 # 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
409 # 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
410 if (store and
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
411 e.dead and
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
412 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
413 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
414 file_added_re.match(e.comment[0])):
9467
4c041f1ee1b4 do not attempt to translate ui.debug output
Martin Geisler <mg@lazybytes.net>
parents: 9032
diff changeset
415 ui.debug('found synthetic revision in %s: %r\n'
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
416 % (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
417 e.synthetic = True
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
418
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
419 if store:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
420 # 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
421 store = False
8209
a1a5a57efe90 replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents: 8171
diff changeset
422 e.tags = sorted([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
423 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
424
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
425 revn = len(e.revision)
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
426 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
427 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
428 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
429 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
430
8756
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
431 # find the branches starting from this revision
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
432 branchpoints = set()
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
433 for branch, revision in branchmap.iteritems():
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
434 revparts = tuple([int(i) for i in revision.split('.')])
10950
278d45703ac2 cvs: skip bad tags
Brandon Parsons <parsonsb@rsn.hp.com>
parents: 10939
diff changeset
435 if len(revparts) < 2: # bad tags
278d45703ac2 cvs: skip bad tags
Brandon Parsons <parsonsb@rsn.hp.com>
parents: 10939
diff changeset
436 continue
8756
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
437 if revparts[-2] == 0 and revparts[-1] % 2 == 0:
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
438 # normal branch
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
439 if revparts[:-2] == e.revision:
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
440 branchpoints.add(branch)
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
441 elif revparts == (1, 1, 1): # vendor branch
8756
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
442 if revparts in e.branches:
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
443 branchpoints.add(branch)
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
444 e.branchpoints = branchpoints
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
445
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
446 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
447
26593
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
448 rcsmap[e.rcs.replace('/Attic/', '/')] = e.rcs
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
449
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
450 if len(log) % 100 == 0:
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
451 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
452
9032
1fa80c5428b8 compat: use 'key' argument instead of 'cmp' when sorting a list
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
453 log.sort(key=lambda x: (x.rcs, x.revision))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
454
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
455 # 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
456 versions = {}
26593
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
457 for e in sorted(oldlog, key=lambda x: (x.rcs, x.revision)):
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
458 rcs = e.rcs.replace('/Attic/', '/')
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
459 if rcs in rcsmap:
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
460 e.rcs = rcsmap[rcs]
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
461 branch = e.revision[:-1]
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
462 versions[(e.rcs, branch)] = e.revision
c60dfcc0abf2 cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents: 25660
diff changeset
463
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
464 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
465 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
466 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
467 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
468 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
469 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
470 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
471
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
472 # 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
473 if cache:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
474 if log:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
475 # join up the old and new logs
9032
1fa80c5428b8 compat: use 'key' argument instead of 'cmp' when sorting a list
Alejandro Santos <alejolp@alejolp.com>
parents: 9031
diff changeset
476 log.sort(key=lambda x: x.date)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
477
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
478 if oldlog and oldlog[-1].date >= log[0].date:
10939
9f6731b03906 convert: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents: 10701
diff changeset
479 raise logerror(_('log cache overlaps with new log entries,'
9f6731b03906 convert: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents: 10701
diff changeset
480 ' 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
481
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
482 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
483
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
484 # 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
485 ui.note(_('writing cvs log cache %s\n') % cachefile)
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 8890
diff changeset
486 pickle.dump(log, open(cachefile, 'w'))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
487 else:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
488 log = oldlog
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
489
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
490 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
491
10095
69ce7a10e593 convert: implement two hooks in builtin cvsps
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 9467
diff changeset
492 hook.hook(ui, None, "cvslog", True, log=log)
69ce7a10e593 convert: implement two hooks in builtin cvsps
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 9467
diff changeset
493
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
494 return log
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
495
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
496
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
497 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
498 '''Class changeset has the following attributes:
8079
fb162c47000b cvsps: update docstring for changeset class.
Greg Ward <greg-hg@gerg.ca>
parents: 8028
diff changeset
499 .id - integer identifying this changeset (list index)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
500 .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
501 .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
502 .comment - commit message
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
503 .commitid - CVS commitid or None
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
504 .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
505 .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
506 .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
507 .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
508 .synthetic - from synthetic revision "file ... added on branch ..."
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
509 .mergepoint- the branch that has been merged from or None
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
510 .branchpoints- the branches that start at the current entry or empty
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
511 '''
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
512 def __init__(self, **entries):
19505
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
513 self.id = None
10701
35893dcfd40c cvsps: fix traceback involving 'synthetic'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10695
diff changeset
514 self.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
515 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
516
8080
19229b0b292d cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents: 8079
diff changeset
517 def __repr__(self):
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
518 items = ("%s=%r"%(k, self.__dict__[k]) for k in sorted(self.__dict__))
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
519 return "%s(%s)"%(type(self).__name__, ", ".join(items))
8080
19229b0b292d cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents: 8079
diff changeset
520
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
521 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
522 '''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
523
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
524 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
525
18718
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
526 # try to order commitids by date
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
527 mindate = {}
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
528 for e in log:
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
529 if e.commitid:
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
530 mindate[e.commitid] = min(e.date, mindate.get(e.commitid))
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
531
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
532 # Merge changesets
18718
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
533 log.sort(key=lambda x: (mindate.get(x.commitid), x.commitid, x.comment,
c8c3887a24c1 convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents: 18375
diff changeset
534 x.author, x.branch, x.date, x.branchpoints))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
535
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
536 changesets = []
8456
e9e2a2c9b294 convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8225
diff changeset
537 files = set()
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
538 c = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
539 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
540
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
541 # Check if log entry belongs to the current changeset or not.
8756
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
542
17424
e7cfe3587ea4 fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents: 16688
diff changeset
543 # Since CVS is file-centric, two different file revisions with
8756
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
544 # different branchpoints should be treated as belonging to two
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
545 # different changesets (and the ordering is important and not
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
546 # honoured by cvsps at this point).
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
547 #
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
548 # Consider the following case:
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
549 # foo 1.1 branchpoints: [MYBRANCH]
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
550 # bar 1.1 branchpoints: [MYBRANCH, MYBRANCH2]
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
551 #
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
552 # Here foo is part only of MYBRANCH, but not MYBRANCH2, e.g. a
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
553 # later version of foo may be in MYBRANCH2, so foo should be the
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
554 # first changeset and bar the next and MYBRANCH and MYBRANCH2
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
555 # should both start off of the bar changeset. No provisions are
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
556 # made to ensure that this is, in fact, what happens.
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
557 if not (c and e.branchpoints == c.branchpoints and
18265
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
558 (# cvs commitids
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
559 (e.commitid is not None and e.commitid == c.commitid) or
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
560 (# no commitids, use fuzzy commit detection
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
561 (e.commitid is None or c.commitid is None) and
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
562 e.comment == c.comment and
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
563 e.author == c.author and
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
564 e.branch == c.branch and
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
565 ((c.date[0] + c.date[1]) <=
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
566 (e.date[0] + e.date[1]) <=
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
567 (c.date[0] + c.date[1]) + fuzz) and
246f290e162a convert: fix most test-check-code-hg violations in cvsps code
Bryan O'Sullivan <bos@serpentine.com>
parents: 18261
diff changeset
568 e.file not in files))):
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
569 c = changeset(comment=e.comment, author=e.author,
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
570 branch=e.branch, date=e.date,
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
571 entries=[], mergepoint=e.mergepoint,
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
572 branchpoints=e.branchpoints, commitid=e.commitid)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
573 changesets.append(c)
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
574
8456
e9e2a2c9b294 convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8225
diff changeset
575 files = set()
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
576 if len(changesets) % 100 == 0:
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
577 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
578 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
579
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
580 c.entries.append(e)
8456
e9e2a2c9b294 convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8225
diff changeset
581 files.add(e.file)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
582 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
583
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
584 # Mark synthetic changesets
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
585
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
586 for c in changesets:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
587 # 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
588 # 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
589 # 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
590 # changesets:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
591 # "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
592 # "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
593 # "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
594 # Hence the check for 1 entry here.
10701
35893dcfd40c cvsps: fix traceback involving 'synthetic'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10695
diff changeset
595 c.synthetic = len(c.entries) == 1 and c.entries[0].synthetic
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
596
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
597 # 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
598
15790
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
599 def entitycompare(l, r):
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
600 'Mimic cvsps sorting order'
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
601 l = l.file.split('/')
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
602 r = r.file.split('/')
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
603 nl = len(l)
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
604 nr = len(r)
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
605 n = min(nl, nr)
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
606 for i in range(n):
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
607 if i + 1 == nl and nl < nr:
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
608 return -1
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
609 elif i + 1 == nr and nl > nr:
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
610 return +1
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
611 elif l[i] < r[i]:
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
612 return -1
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
613 elif l[i] > r[i]:
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
614 return +1
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
615 return 0
52f816b40674 cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents: 15205
diff changeset
616
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
617 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
618 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
619
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
620 # 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
621
19505
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
622 odd = set()
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
623 def cscmp(l, r, odd=odd):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
624 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
625 if d:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
626 return d
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
627
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
628 # 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
629 le = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
630 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
631 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
632 re = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
633 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
634 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
635
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
636 d = 0
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
637 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
638 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
639 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
640 d = 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
641 break
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 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
644 if le.get(e.rcs, None) == e.parent:
19505
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
645 if d:
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
646 odd.add((l, r))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
647 d = -1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
648 break
22267
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
649 # By this point, the changesets are sufficiently compared that
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
650 # we don't really care about ordering. However, this leaves
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
651 # some race conditions in the tests, so we compare on the
24305
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
652 # number of files modified, the files contained in each
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
653 # changeset, and the branchpoints in the change to ensure test
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
654 # output remains stable.
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
655
22267
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
656 # recommended replacement for cmp from
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
657 # https://docs.python.org/3.0/whatsnew/3.0.html
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
658 c = lambda x, y: (x > y) - (x < y)
24305
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
659 # Sort bigger changes first.
22267
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
660 if not d:
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
661 d = c(len(l.entries), len(r.entries))
24305
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
662 # Try sorting by filename in the change.
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
663 if not d:
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
664 d = c([e.file for e in l.entries], [e.file for e in r.entries])
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
665 # Try and put changes without a branch point before ones with
867c3649be5d cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents: 22267
diff changeset
666 # a branch point.
22267
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
667 if not d:
90cf454edd70 cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents: 22202
diff changeset
668 d = c(len(l.branchpoints), len(r.branchpoints))
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
669 return d
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
670
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
671 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
672
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
673 # Collect tags
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
674
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
675 globaltags = {}
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
676 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
677 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
678 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
679 # 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
680 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
681
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
682 for c in changesets:
8456
e9e2a2c9b294 convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8225
diff changeset
683 tags = set()
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
684 for e in c.entries:
8483
221786b9ce34 convert/cvsps: use set.update for bulk update
Martin Geisler <mg@lazybytes.net>
parents: 8456
diff changeset
685 tags.update(e.tags)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
686 # remember tags only if this is the latest changeset to have it
8456
e9e2a2c9b294 convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8225
diff changeset
687 c.tags = sorted(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
688
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
689 # 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
690 # 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
691 # {{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
692
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
693 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
694 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
695 if mergeto:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
696 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
697
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
698 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
699 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
700 if mergefrom:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
701 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
702
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
703 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
704 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
705 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
706 i = 0
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
707 while i < n:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
708 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
709
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
710 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
711 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
712
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
713 p = None
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
714 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
715 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
716 else:
8756
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
717 # first changeset on a new branch
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
718 # the parent is a changeset with the branch in its
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
719 # branchpoints such that it is the latest possible
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
720 # commit without any intervening, unrelated commits.
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
721
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
722 for candidate in xrange(i):
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
723 if c.branch not in changesets[candidate].branchpoints:
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
724 if p is not None:
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
725 break
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
726 continue
6019e6517f95 convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents: 8661
diff changeset
727 p = candidate
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
728
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
729 c.parents = []
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
730 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
731 p = changesets[p]
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
732
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
733 # 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
734 while p.synthetic:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
735 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
736 _('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
737 if p.parents:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
738 p = p.parents[0]
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
739 else:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
740 p = None
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
741 break
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
742
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
743 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
744 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
745
7956
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
746 if c.mergepoint:
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
747 if c.mergepoint == 'HEAD':
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
748 c.mergepoint = None
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
749 c.parents.append(changesets[branches[c.mergepoint]])
3e7611a83230 convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents: 7950
diff changeset
750
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
751 if mergefrom:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
752 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
753 if m:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
754 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
755 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
756 m = None
8171
4e5bd9b97bb3 cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents: 8080
diff changeset
757 try:
4e5bd9b97bb3 cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents: 8080
diff changeset
758 candidate = changesets[branches[m]]
4e5bd9b97bb3 cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents: 8080
diff changeset
759 except KeyError:
4e5bd9b97bb3 cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents: 8080
diff changeset
760 ui.warn(_("warning: CVS commit message references "
4e5bd9b97bb3 cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents: 8080
diff changeset
761 "non-existent branch %r:\n%s\n")
4e5bd9b97bb3 cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents: 8080
diff changeset
762 % (m, c.comment))
7950
9bbcfa898cd3 issue1578: fix crash: do not use synthetic changesets as merge parents.
Greg Ward <greg-hg@gerg.ca>
parents: 7862
diff changeset
763 if m in branches and c.branch != m and not candidate.synthetic:
9bbcfa898cd3 issue1578: fix crash: do not use synthetic changesets as merge parents.
Greg Ward <greg-hg@gerg.ca>
parents: 7862
diff changeset
764 c.parents.append(candidate)
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
765
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
766 if mergeto:
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
767 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
768 if m:
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
769 if m.groups():
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
770 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
771 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
772 m = None
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
773 else:
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
774 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
775 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
776 # insert empty changeset for merge
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
777 cc = changeset(
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
778 author=c.author, branch=m, date=c.date,
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
779 comment='convert-repo: CVS merge from branch %s'
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
780 % c.branch,
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
781 entries=[], tags=[],
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
782 parents=[changesets[branches[m]], c])
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
783 changesets.insert(i + 1, cc)
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
784 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
785
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
786 # 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
787 n += 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
788 i += 2
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
789 continue
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
790
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
791 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
792 i += 1
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
793
7862
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
794 # 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
795 # 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
796 i = 0
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
797 while i < len(changesets):
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
798 if changesets[i].synthetic:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
799 del changesets[i]
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
800 else:
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
801 i += 1
02981000012e cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents: 7601
diff changeset
802
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
803 # Number changesets
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
804
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
805 for i, c in enumerate(changesets):
6688
5cd7a8433cd4 cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents: 6687
diff changeset
806 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
807
19505
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
808 if odd:
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
809 for l, r in odd:
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
810 if l.id is not None and r.id is not None:
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
811 ui.warn(_('changeset %d is both before and after %d\n')
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
812 % (l.id, r.id))
7b815e38022a convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 19145
diff changeset
813
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
814 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
815
10095
69ce7a10e593 convert: implement two hooks in builtin cvsps
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 9467
diff changeset
816 hook.hook(ui, None, "cvschangesets", True, changesets=changesets)
69ce7a10e593 convert: implement two hooks in builtin cvsps
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 9467
diff changeset
817
6687
f8ef39206f6a convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff changeset
818 return changesets
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
819
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
820
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
821 def debugcvsps(ui, *args, **opts):
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
822 '''Read CVS rlog for current directory or named path in
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
823 repository, and convert the log to changesets based on matching
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
824 commit log entries and dates.
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
825 '''
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
826 if opts["new_cache"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
827 cache = "write"
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
828 elif opts["update_cache"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
829 cache = "update"
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
830 else:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
831 cache = None
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
832
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
833 revisions = opts["revisions"]
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
834
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
835 try:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
836 if args:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
837 log = []
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
838 for d in args:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
839 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
840 else:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
841 log = createlog(ui, root=opts["root"], cache=cache)
25660
328739ea70c3 global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 24305
diff changeset
842 except logerror as e:
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
843 ui.write("%r\n"%e)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
844 return
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
845
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
846 changesets = createchangeset(ui, log, opts["fuzz"])
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
847 del log
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
848
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
849 # Print changesets (optionally filtered)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
850
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
851 off = len(revisions)
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
852 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
853 ancestors = {} # parent branch
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
854 for cs in changesets:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
855
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
856 if opts["ancestors"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
857 if cs.branch not in branches and cs.parents and cs.parents[0].id:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
858 ancestors[cs.branch] = (changesets[cs.parents[0].id - 1].branch,
8661
883f14fcd1df convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents: 8483
diff changeset
859 cs.parents[0].id)
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
860 branches[cs.branch] = cs.id
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
861
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
862 # limit by branches
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
863 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
864 continue
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
865
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
866 if not off:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
867 # 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
868 # bug-for-bug compatibility with cvsps.
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
869 ui.write('---------------------\n')
17956
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
870 ui.write(('PatchSet %d \n' % cs.id))
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
871 ui.write(('Date: %s\n' % util.datestr(cs.date,
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
872 '%Y/%m/%d %H:%M:%S %1%2')))
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
873 ui.write(('Author: %s\n' % cs.author))
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
874 ui.write(('Branch: %s\n' % (cs.branch or 'HEAD')))
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
875 ui.write(('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1],
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
876 ','.join(cs.tags) or '(none)')))
18261
1b7b5975793f cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 17956
diff changeset
877 if cs.branchpoints:
18375
cfbd33020066 convert: report cvsps branchpoints sorted
Mads Kiilerich <mads@kiilerich.com>
parents: 18286
diff changeset
878 ui.write(('Branchpoints: %s \n') %
cfbd33020066 convert: report cvsps branchpoints sorted
Mads Kiilerich <mads@kiilerich.com>
parents: 18286
diff changeset
879 ', '.join(sorted(cs.branchpoints)))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
880 if opts["parents"] and cs.parents:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
881 if len(cs.parents) > 1:
17956
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
882 ui.write(('Parents: %s\n' %
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
883 (','.join([str(p.id) for p in cs.parents]))))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
884 else:
17956
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
885 ui.write(('Parent: %d\n' % cs.parents[0].id))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
886
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
887 if opts["ancestors"]:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
888 b = cs.branch
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
889 r = []
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
890 while b:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
891 b, c = ancestors[b]
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
892 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
893 if r:
17956
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
894 ui.write(('Ancestors: %s\n' % (','.join(r))))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
895
17956
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
896 ui.write(('Log:\n'))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
897 ui.write('%s\n\n' % cs.comment)
17956
a08775ec89f2 i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents: 17424
diff changeset
898 ui.write(('Members: \n'))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
899 for f in cs.entries:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
900 fn = f.file
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
901 if fn.startswith(opts["prefix"]):
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
902 fn = fn[len(opts["prefix"]):]
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
903 ui.write('\t%s:%s->%s%s \n' % (
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
904 fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL',
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
905 '.'.join([str(x) for x in f.revision]),
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
906 ['', '(DEAD)'][f.dead]))
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
907 ui.write('\n')
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
908
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
909 # have we seen the start tag?
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
910 if revisions and off:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
911 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
912 revisions[0] in cs.tags:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
913 off = False
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
914
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
915 # see if we reached the end tag
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
916 if len(revisions) > 1 and not off:
7502
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
917 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
918 revisions[1] in cs.tags:
16905fc2690f Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7280
diff changeset
919 break