author | Augie Fackler <augie@google.com> |
Tue, 11 Feb 2020 00:44:59 -0500 | |
changeset 44477 | ad718271a9eb |
parent 43787 | be8552f25cab |
child 45681 | a736ab681b78 |
permissions | -rw-r--r-- |
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 | 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 |
|
37886
fe148d7544a4
cvsps: wrap cmp methods (deprecated) in functools.cmp_to_key
Augie Fackler <augie@google.com>
parents:
37884
diff
changeset
|
9 |
import functools |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
10 |
import os |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
11 |
import re |
28369
71176606fa0a
convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents:
26593
diff
changeset
|
12 |
|
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28369
diff
changeset
|
13 |
from mercurial.i18n import _ |
43085
eef9a2d67051
py3: manually import pycompat.open into files that need it
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43080
diff
changeset
|
14 |
from mercurial.pycompat import open |
28369
71176606fa0a
convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents:
26593
diff
changeset
|
15 |
from mercurial import ( |
30638
1c5cbf28f007
py3: replace os.environ with encoding.environ (part 5 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30616
diff
changeset
|
16 |
encoding, |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
17 |
error, |
28369
71176606fa0a
convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents:
26593
diff
changeset
|
18 |
hook, |
30616
6f9fcd29e290
py3: replace os.sep with pycompat.ossep (part 4 of 4)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29324
diff
changeset
|
19 |
pycompat, |
28369
71176606fa0a
convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents:
26593
diff
changeset
|
20 |
util, |
71176606fa0a
convert: cvsps use absolute_import
timeless <timeless@mozdev.org>
parents:
26593
diff
changeset
|
21 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
22 |
from mercurial.utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
23 |
dateutil, |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
24 |
procutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
25 |
stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
26 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
27 |
|
29324
b501579147f1
py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29205
diff
changeset
|
28 |
pickle = util.pickle |
b501579147f1
py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29205
diff
changeset
|
29 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
30 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
31 |
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
|
32 |
'''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
|
33 |
.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
|
34 |
.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
|
35 |
.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
|
36 |
.comment - commit message |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
37 |
.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
|
38 |
.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
|
39 |
.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
|
40 |
.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
|
41 |
.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
|
42 |
.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
|
43 |
.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
|
44 |
.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
|
45 |
.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
|
46 |
.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
|
47 |
.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
|
48 |
rlog output) or None |
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
49 |
.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
|
50 |
''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
51 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
52 |
def __init__(self, **entries): |
10701
35893dcfd40c
cvsps: fix traceback involving 'synthetic'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10695
diff
changeset
|
53 |
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
|
54 |
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
|
55 |
|
8080
19229b0b292d
cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents:
8079
diff
changeset
|
56 |
def __repr__(self): |
43503
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
57 |
items = ("%s=%r" % (k, self.__dict__[k]) for k in sorted(self.__dict__)) |
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
58 |
return "%s(%s)" % (type(self).__name__, ", ".join(items)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
59 |
|
8080
19229b0b292d
cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents:
8079
diff
changeset
|
60 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
61 |
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
|
62 |
pass |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
63 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
64 |
|
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
65 |
def getrepopath(cvspath): |
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
66 |
"""Return the repository path from a CVS path. |
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
67 |
|
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
68 |
>>> getrepopath(b'/foo/bar') |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
69 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
70 |
>>> getrepopath(b'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
|
71 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
72 |
>>> getrepopath(b':pserver:10/foo/bar') |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
73 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
74 |
>>> getrepopath(b':pserver:10c:/foo/bar') |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
75 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
76 |
>>> getrepopath(b':pserver:/foo/bar') |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
77 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
78 |
>>> getrepopath(b':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
|
79 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
80 |
>>> getrepopath(b':pserver:truc@foo.bar:/foo/bar') |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
81 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
82 |
>>> getrepopath(b':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
|
83 |
'/foo/bar' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33388
diff
changeset
|
84 |
>>> getrepopath(b'user@server/path/to/repository') |
19145
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
85 |
'/path/to/repository' |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
86 |
""" |
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
87 |
# 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
|
88 |
# [:method:][[user][:password]@]hostname[:[port]]/path/to/repository |
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
89 |
# |
19145
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
90 |
# 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
|
91 |
# 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
|
92 |
# 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
|
93 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
94 |
parts = cvspath.split(b':') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
95 |
atposition = parts[-1].find(b'@') |
19145
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
96 |
start = 0 |
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
97 |
|
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
98 |
if atposition != -1: |
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
99 |
start = atposition |
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
100 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
101 |
repopath = parts[-1][parts[-1].find(b'/', start) :] |
19145
0a12e5f3a979
convert: fix bug of wrong CVS path parsing without port number (issue3678)
Blesso hrvoje1212@gmail.com
parents:
18718
diff
changeset
|
102 |
return repopath |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
103 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
104 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
105 |
def createlog(ui, directory=None, root=b"", rlog=True, cache=None): |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
106 |
'''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
|
107 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
108 |
# 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
|
109 |
# 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
|
110 |
_scache = {} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
111 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
112 |
def scache(s): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43503
diff
changeset
|
113 |
"""return a shared version of a string""" |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
114 |
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
|
115 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 |
ui.status(_(b'collecting CVS rlog\n')) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
117 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
118 |
log = [] # list of logentry objects containing the CVS state |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
119 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
120 |
# patterns to match in CVS (r)log output, by state of use |
37884
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
121 |
re_00 = re.compile(b'RCS file: (.+)$') |
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
122 |
re_01 = re.compile(b'cvs \\[r?log aborted\\]: (.+)$') |
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
123 |
re_02 = re.compile(b'cvs (r?log|server): (.+)\n$') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
124 |
re_03 = re.compile( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
125 |
b"(Cannot access.+CVSROOT)|(can't create temporary directory.+)$" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
126 |
) |
37884
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
127 |
re_10 = re.compile(b'Working file: (.+)$') |
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
128 |
re_20 = re.compile(b'symbolic names:') |
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
129 |
re_30 = re.compile(b'\t(.+): ([\\d.]+)$') |
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
130 |
re_31 = re.compile(b'----------------------------$') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
131 |
re_32 = re.compile( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
132 |
b'=======================================' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
133 |
b'======================================$' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
134 |
) |
41532
bd3f03d8cc9f
global: use raw strings for regular expressions with escapes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38783
diff
changeset
|
135 |
re_50 = re.compile(br'revision ([\d.]+)(\s+locked by:\s+.+;)?$') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
136 |
re_60 = re.compile( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
137 |
br'date:\s+(.+);\s+author:\s+(.+);\s+state:\s+(.+?);' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
138 |
br'(\s+lines:\s+(\+\d+)?\s+(-\d+)?;)?' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
139 |
br'(\s+commitid:\s+([^;]+);)?' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
140 |
br'(.*mergepoint:\s+([^;]+);)?' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
141 |
) |
37884
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
142 |
re_70 = re.compile(b'branches: (.+);$') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
143 |
|
37884
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
144 |
file_added_re = re.compile(br'file [^/]+ was (initially )?added on branch') |
7862
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
145 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
146 |
prefix = b'' # leading path to strip of what we get from CVS |
6687
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 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
|
149 |
# 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
|
150 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
151 |
# 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
|
152 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
153 |
with open(os.path.join(b'CVS', b'Repository'), b'rb') as f: |
43052
3b8a4587a456
cvsps: switch a file open to a with statement
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
154 |
prefix = f.read().strip() |
10695
b4b16e90712f
convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents:
10282
diff
changeset
|
155 |
directory = prefix |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
156 |
if prefix == b".": |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
157 |
prefix = b"" |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
158 |
except IOError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
159 |
raise logerror(_(b'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
|
160 |
|
30616
6f9fcd29e290
py3: replace os.sep with pycompat.ossep (part 4 of 4)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29324
diff
changeset
|
161 |
if prefix and not prefix.endswith(pycompat.ossep): |
6f9fcd29e290
py3: replace os.sep with pycompat.ossep (part 4 of 4)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29324
diff
changeset
|
162 |
prefix += pycompat.ossep |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
163 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
164 |
# 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
|
165 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
166 |
root = open(os.path.join(b'CVS', b'Root'), b'rb').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
|
167 |
except IOError: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
168 |
pass |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
169 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
170 |
if not root: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
171 |
root = encoding.environ.get(b'CVSROOT', b'') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
172 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
173 |
# 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
|
174 |
oldlog = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
175 |
date = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
176 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
177 |
if cache: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
178 |
cachedir = os.path.expanduser(b'~/.hg.cvsps') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
179 |
if not 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
|
180 |
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
|
181 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
182 |
# 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
|
183 |
# 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
|
184 |
# 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
|
185 |
# alphanumeric characters, concatenated in a way that does not |
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
16688
diff
changeset
|
186 |
# 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
|
187 |
# :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
|
188 |
# and |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
189 |
# /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
|
190 |
# are mapped to different cache file names. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
191 |
cachefile = root.split(b":") + [directory, b"cache"] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
192 |
cachefile = [b'-'.join(re.findall(br'\w+', s)) for s in cachefile if s] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
193 |
cachefile = os.path.join( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
194 |
cachedir, b'.'.join([s for s in cachefile if s]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
195 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
196 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
197 |
if cache == b'update': |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
198 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
199 |
ui.note(_(b'reading cvs log cache %s\n') % cachefile) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
200 |
oldlog = pickle.load(open(cachefile, b'rb')) |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
201 |
for e in oldlog: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
202 |
if not ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
203 |
util.safehasattr(e, b'branchpoints') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
204 |
and util.safehasattr(e, b'commitid') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
205 |
and util.safehasattr(e, b'mergepoint') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
206 |
): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
207 |
ui.status(_(b'ignoring old cache\n')) |
18286 | 208 |
oldlog = [] |
209 |
break |
|
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
210 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
211 |
ui.note(_(b'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
|
212 |
except Exception as e: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
213 |
ui.note(_(b'error reading cache: %r\n') % e) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
214 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
215 |
if oldlog: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
216 |
date = oldlog[-1].date # last commit date as a (time,tz) tuple |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
217 |
date = dateutil.datestr(date, b'%Y/%m/%d %H:%M:%S %1%2') |
6687
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 |
# build the CVS commandline |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 |
cmd = [b'cvs', b'-q'] |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
221 |
if root: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
222 |
cmd.append(b'-d%s' % root) |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
223 |
p = util.normpath(getrepopath(root)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
224 |
if not p.endswith(b'/'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
225 |
p += b'/' |
10695
b4b16e90712f
convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents:
10282
diff
changeset
|
226 |
if prefix: |
b4b16e90712f
convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents:
10282
diff
changeset
|
227 |
# looks like normpath replaces "" by "." |
b4b16e90712f
convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents:
10282
diff
changeset
|
228 |
prefix = p + util.normpath(prefix) |
b4b16e90712f
convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents:
10282
diff
changeset
|
229 |
else: |
b4b16e90712f
convert: teach cvsps to handle . repository (issue1649)
Mathieu Clabaut <mathieu.clabaut@systerel.fr>
parents:
10282
diff
changeset
|
230 |
prefix = p |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
231 |
cmd.append([b'log', b'rlog'][rlog]) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
232 |
if date: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
233 |
# no space between option and date string |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
234 |
cmd.append(b'-d>%s' % date) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
235 |
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
|
236 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
237 |
# state machine begins here |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
238 |
tags = {} # dictionary of revisions on current file with their tags |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
239 |
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
|
240 |
rcsmap = {} |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
241 |
state = 0 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
242 |
store = False # set when a new record can be appended |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
243 |
|
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
244 |
cmd = [procutil.shellquote(arg) for arg in cmd] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
245 |
ui.note(_(b"running %s\n") % (b' '.join(cmd))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
246 |
ui.debug(b"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
|
247 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 |
pfp = procutil.popen(b' '.join(cmd), b'rb') |
37458
00e4bd97b095
procutil: always popen() in binary mode
Yuya Nishihara <yuya@tcha.org>
parents:
37120
diff
changeset
|
249 |
peek = util.fromnativeeol(pfp.readline()) |
7593
9811cc670c51
cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents:
7573
diff
changeset
|
250 |
while True: |
9811cc670c51
cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents:
7573
diff
changeset
|
251 |
line = peek |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 |
if line == b'': |
7593
9811cc670c51
cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents:
7573
diff
changeset
|
253 |
break |
37458
00e4bd97b095
procutil: always popen() in binary mode
Yuya Nishihara <yuya@tcha.org>
parents:
37120
diff
changeset
|
254 |
peek = util.fromnativeeol(pfp.readline()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
255 |
if line.endswith(b'\n'): |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
256 |
line = line[:-1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
257 |
# ui.debug('state=%d line=%r\n' % (state, line)) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
258 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
259 |
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
|
260 |
# 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
|
261 |
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
|
262 |
if match: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
263 |
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
|
264 |
tags = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
265 |
if rlog: |
7097
d4218edd55bd
convert: fix builtin cvsps under Windows
Patrick Mezard <pmezard@gmail.com>
parents:
6956
diff
changeset
|
266 |
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
|
267 |
if filename.startswith(prefix): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
268 |
filename = filename[len(prefix) :] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
269 |
if filename.startswith(b'/'): |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
270 |
filename = filename[1:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
271 |
if filename.startswith(b'Attic/'): |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
272 |
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
|
273 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
274 |
filename = filename.replace(b'/Attic/', b'/') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
275 |
state = 2 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
276 |
continue |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
277 |
state = 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
278 |
continue |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
279 |
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
|
280 |
if match: |
11122
2114e44b08f6
clean up remaining generic exceptions
Matt Mackall <mpm@selenic.com>
parents:
10950
diff
changeset
|
281 |
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
|
282 |
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
|
283 |
if match: |
11122
2114e44b08f6
clean up remaining generic exceptions
Matt Mackall <mpm@selenic.com>
parents:
10950
diff
changeset
|
284 |
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
|
285 |
if re_03.match(line): |
11122
2114e44b08f6
clean up remaining generic exceptions
Matt Mackall <mpm@selenic.com>
parents:
10950
diff
changeset
|
286 |
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
|
287 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
288 |
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
|
289 |
# 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
|
290 |
match = re_10.match(line) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
291 |
assert match, _(b'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
|
292 |
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
|
293 |
state = 2 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
294 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
295 |
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
|
296 |
# 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
|
297 |
if re_20.match(line): |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
298 |
branchmap = {} |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
299 |
state = 3 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
300 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
301 |
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
|
302 |
# 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
|
303 |
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
|
304 |
if match: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
305 |
rev = [int(x) for x in match.group(2).split(b'.')] |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
306 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
307 |
# 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
|
308 |
revn = len(rev) |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
309 |
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
|
310 |
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
|
311 |
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
|
312 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
313 |
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
|
314 |
tags[rev] = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
315 |
tags[rev].append(match.group(1)) |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
316 |
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
|
317 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
318 |
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
|
319 |
state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
320 |
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
|
321 |
state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
322 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
323 |
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
|
324 |
# 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
|
325 |
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
|
326 |
state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
327 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
328 |
assert not re_32.match(line), _( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
329 |
b'must have at least some revisions' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
330 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
331 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
332 |
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
|
333 |
# 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
|
334 |
# 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
|
335 |
# 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
|
336 |
match = re_50.match(line) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
337 |
assert match, _(b'expected revision number') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
338 |
e = logentry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
339 |
rcs=scache(rcs), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
340 |
file=scache(filename), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 |
revision=tuple([int(x) for x in match.group(1).split(b'.')]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
342 |
branches=[], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
343 |
parent=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
344 |
commitid=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
345 |
mergepoint=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
346 |
branchpoints=set(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
347 |
) |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
348 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
349 |
state = 6 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
350 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
351 |
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
|
352 |
# 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
|
353 |
match = re_60.match(line) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
354 |
assert match, _(b'revision must be followed by date line') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
355 |
d = match.group(1) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
356 |
if d[2] == b'/': |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
357 |
# Y2K |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
358 |
d = b'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
|
359 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
360 |
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
|
361 |
# cvs log dates always in GMT |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
362 |
d = d + b' UTC' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
363 |
e.date = dateutil.parsedate( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
364 |
d, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
365 |
[ |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
366 |
b'%y/%m/%d %H:%M:%S', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
367 |
b'%Y/%m/%d %H:%M:%S', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
368 |
b'%Y-%m-%d %H:%M:%S', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
369 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
370 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
371 |
e.author = scache(match.group(2)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
372 |
e.dead = match.group(3).lower() == b'dead' |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
373 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
374 |
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
|
375 |
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
|
376 |
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
|
377 |
else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
378 |
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
|
379 |
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
|
380 |
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
|
381 |
else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
382 |
e.lines = None |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
383 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
384 |
if match.group(7): # cvs 1.12 commitid |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
385 |
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
|
386 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
387 |
if match.group(9): # cvsnt mergepoint |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
388 |
myrev = match.group(10).split(b'.') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
389 |
if len(myrev) == 2: # head |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
390 |
e.mergepoint = b'HEAD' |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
391 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 |
myrev = b'.'.join(myrev[:-2] + [b'0', myrev[-2]]) |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
393 |
branches = [b for b in branchmap if branchmap[b] == myrev] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
394 |
assert len(branches) == 1, ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
395 |
b'unknown branch: %s' % e.mergepoint |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
396 |
) |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
397 |
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
|
398 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
399 |
e.comment = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
400 |
state = 7 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
401 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
402 |
elif state == 7: |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
403 |
# 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
|
404 |
# 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
|
405 |
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
|
406 |
if m: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
407 |
e.branches = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
408 |
tuple([int(y) for y in x.strip().split(b'.')]) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
409 |
for x in m.group(1).split(b';') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
410 |
] |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
411 |
state = 8 |
7593
9811cc670c51
cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion <dgc@uchicago.edu>
parents:
7573
diff
changeset
|
412 |
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
|
413 |
state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
414 |
store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
415 |
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
|
416 |
state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
417 |
store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
418 |
else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
419 |
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
|
420 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
421 |
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
|
422 |
# 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
|
423 |
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
|
424 |
cpeek = peek |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
425 |
if cpeek.endswith(b'\n'): |
15205
4e5b7d130e76
convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents:
14945
diff
changeset
|
426 |
cpeek = cpeek[:-1] |
4e5b7d130e76
convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents:
14945
diff
changeset
|
427 |
if re_50.match(cpeek): |
4e5b7d130e76
convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents:
14945
diff
changeset
|
428 |
state = 5 |
4e5b7d130e76
convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents:
14945
diff
changeset
|
429 |
store = True |
4e5b7d130e76
convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents:
14945
diff
changeset
|
430 |
else: |
4e5b7d130e76
convert: detect false cset boundaries in cvsps descriptions
jakob krainz <jakob@hawo-net.de>
parents:
14945
diff
changeset
|
431 |
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
|
432 |
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
|
433 |
state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
434 |
store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
435 |
else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
436 |
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
|
437 |
|
7862
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
438 |
# 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
|
439 |
# 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
|
440 |
# 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
|
441 |
# 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
|
442 |
# 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
|
443 |
# 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
|
444 |
# createchangeset() can take care of them. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
445 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
446 |
store |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
447 |
and e.dead |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
448 |
and e.revision[-1] == 1 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
449 |
and len(e.comment) == 1 # 1.1 or 1.1.x.1 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
450 |
and file_added_re.match(e.comment[0]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
451 |
): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
452 |
ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
453 |
b'found synthetic revision in %s: %r\n' % (e.rcs, e.comment[0]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
454 |
) |
7862
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
455 |
e.synthetic = True |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
456 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
457 |
if store: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
458 |
# 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
|
459 |
store = False |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8171
diff
changeset
|
460 |
e.tags = sorted([scache(x) for x in tags.get(e.revision, [])]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
461 |
e.comment = scache(b'\n'.join(e.comment)) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
462 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
463 |
revn = len(e.revision) |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
464 |
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
|
465 |
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
|
466 |
else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
467 |
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
|
468 |
|
8756
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
469 |
# find the branches starting from this revision |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
470 |
branchpoints = set() |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
471 |
for branch, revision in pycompat.iteritems(branchmap): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 |
revparts = tuple([int(i) for i in revision.split(b'.')]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
473 |
if len(revparts) < 2: # bad tags |
10950 | 474 |
continue |
8756
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
475 |
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
|
476 |
# normal branch |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
477 |
if revparts[:-2] == e.revision: |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
478 |
branchpoints.add(branch) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
479 |
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
|
480 |
if revparts in e.branches: |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
481 |
branchpoints.add(branch) |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
482 |
e.branchpoints = branchpoints |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
483 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
484 |
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
|
485 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
486 |
rcsmap[e.rcs.replace(b'/Attic/', b'/')] = e.rcs |
26593
c60dfcc0abf2
cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents:
25660
diff
changeset
|
487 |
|
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
488 |
if len(log) % 100 == 0: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
489 |
ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
490 |
stringutil.ellipsis(b'%d %s' % (len(log), e.file), 80) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
491 |
+ b'\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
492 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
493 |
|
9032
1fa80c5428b8
compat: use 'key' argument instead of 'cmp' when sorting a list
Alejandro Santos <alejolp@alejolp.com>
parents:
9031
diff
changeset
|
494 |
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
|
495 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
496 |
# 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
|
497 |
versions = {} |
26593
c60dfcc0abf2
cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents:
25660
diff
changeset
|
498 |
for e in sorted(oldlog, key=lambda x: (x.rcs, x.revision)): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
499 |
rcs = e.rcs.replace(b'/Attic/', b'/') |
26593
c60dfcc0abf2
cvsps: fix computation of parent revisions when log caching is on
Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
parents:
25660
diff
changeset
|
500 |
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
|
501 |
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
|
502 |
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
|
503 |
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
|
504 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
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
|
512 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
513 |
# 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
|
514 |
if cache: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
515 |
if log: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
516 |
# 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
|
517 |
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
|
518 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
519 |
if oldlog and oldlog[-1].date >= log[0].date: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
520 |
raise logerror( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
521 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
522 |
b'log cache overlaps with new log entries,' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
523 |
b' re-run without cache.' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
524 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
525 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
526 |
|
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
527 |
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
|
528 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
529 |
# write the new cachefile |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
530 |
ui.note(_(b'writing cvs log cache %s\n') % cachefile) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
531 |
pickle.dump(log, open(cachefile, b'wb')) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
532 |
else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
533 |
log = oldlog |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
534 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
535 |
ui.status(_(b'%d log entries\n') % len(log)) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
536 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
537 |
encodings = ui.configlist(b'convert', b'cvsps.logencoding') |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
538 |
if encodings: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
539 |
|
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
540 |
def revstr(r): |
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
541 |
# this is needed, because logentry.revision is a tuple of "int" |
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
542 |
# (e.g. (1, 2) for "1.2") |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
543 |
return b'.'.join(pycompat.maplist(pycompat.bytestr, r)) |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
544 |
|
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
545 |
for entry in log: |
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
546 |
comment = entry.comment |
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
547 |
for e in encodings: |
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
548 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
549 |
entry.comment = comment.decode(pycompat.sysstr(e)).encode( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
550 |
'utf-8' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
551 |
) |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
552 |
if ui.debugflag: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
553 |
ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
554 |
b"transcoding by %s: %s of %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
555 |
% (e, revstr(entry.revision), entry.file) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
556 |
) |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
557 |
break |
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
558 |
except UnicodeDecodeError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
559 |
pass # try next encoding |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
560 |
except LookupError as inst: # unknown encoding, maybe |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
561 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
562 |
inst, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
563 |
hint=_( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
564 |
b'check convert.cvsps.logencoding configuration' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
565 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
566 |
) |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
567 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
568 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
569 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
570 |
b"no encoding can transcode" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
571 |
b" CVS log message for %s of %s" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
572 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
573 |
% (revstr(entry.revision), entry.file), |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
574 |
hint=_(b'check convert.cvsps.logencoding configuration'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
575 |
) |
33388
0823f0983eaa
convert: transcode CVS log messages by specified encoding (issue5597)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31408
diff
changeset
|
576 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
577 |
hook.hook(ui, None, b"cvslog", True, log=log) |
10095
69ce7a10e593
convert: implement two hooks in builtin cvsps
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
9467
diff
changeset
|
578 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
579 |
return log |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
580 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
581 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
582 |
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
|
583 |
'''Class changeset has the following attributes: |
8079
fb162c47000b
cvsps: update docstring for changeset class.
Greg Ward <greg-hg@gerg.ca>
parents:
8028
diff
changeset
|
584 |
.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
|
585 |
.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
|
586 |
.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
|
587 |
.comment - commit message |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
588 |
.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
|
589 |
.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
|
590 |
.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
|
591 |
.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
|
592 |
.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
|
593 |
.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
|
594 |
.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
|
595 |
.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
|
596 |
''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
597 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
598 |
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
|
599 |
self.id = None |
10701
35893dcfd40c
cvsps: fix traceback involving 'synthetic'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10695
diff
changeset
|
600 |
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
|
601 |
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
|
602 |
|
8080
19229b0b292d
cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents:
8079
diff
changeset
|
603 |
def __repr__(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
604 |
items = ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
605 |
b"%s=%r" % (k, self.__dict__[k]) for k in sorted(self.__dict__) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
606 |
) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
607 |
return b"%s(%s)" % (type(self).__name__, b", ".join(items)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
608 |
|
8080
19229b0b292d
cvsps: make debugging easier by adding __repr__() methods.
Greg Ward <greg-hg@gerg.ca>
parents:
8079
diff
changeset
|
609 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
610 |
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
|
611 |
'''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
|
612 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
613 |
ui.status(_(b'creating changesets\n')) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
614 |
|
18718
c8c3887a24c1
convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents:
18375
diff
changeset
|
615 |
# try to order commitids by date |
c8c3887a24c1
convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents:
18375
diff
changeset
|
616 |
mindate = {} |
c8c3887a24c1
convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents:
18375
diff
changeset
|
617 |
for e in log: |
c8c3887a24c1
convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents:
18375
diff
changeset
|
618 |
if e.commitid: |
38294
80f6e95fac2d
cvsps: avoid comparison between None and a tuple in date sorting
Augie Fackler <augie@google.com>
parents:
37918
diff
changeset
|
619 |
if e.commitid not in mindate: |
80f6e95fac2d
cvsps: avoid comparison between None and a tuple in date sorting
Augie Fackler <augie@google.com>
parents:
37918
diff
changeset
|
620 |
mindate[e.commitid] = e.date |
80f6e95fac2d
cvsps: avoid comparison between None and a tuple in date sorting
Augie Fackler <augie@google.com>
parents:
37918
diff
changeset
|
621 |
else: |
80f6e95fac2d
cvsps: avoid comparison between None and a tuple in date sorting
Augie Fackler <augie@google.com>
parents:
37918
diff
changeset
|
622 |
mindate[e.commitid] = min(e.date, mindate[e.commitid]) |
18718
c8c3887a24c1
convert: stabilize cvsps commitid sort order
Matt Mackall <mpm@selenic.com>
parents:
18375
diff
changeset
|
623 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
624 |
# Merge changesets |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
625 |
log.sort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
626 |
key=lambda x: ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
627 |
mindate.get(x.commitid, (-1, 0)), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
628 |
x.commitid or b'', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
629 |
x.comment, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
630 |
x.author, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
631 |
x.branch or b'', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
632 |
x.date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
633 |
x.branchpoints, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
634 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
635 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
636 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
637 |
changesets = [] |
8456
e9e2a2c9b294
convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8225
diff
changeset
|
638 |
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
|
639 |
c = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
640 |
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
|
641 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
642 |
# 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
|
643 |
|
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
16688
diff
changeset
|
644 |
# 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
|
645 |
# 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
|
646 |
# 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
|
647 |
# honoured by cvsps at this point). |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
648 |
# |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
649 |
# Consider the following case: |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
650 |
# foo 1.1 branchpoints: [MYBRANCH] |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
651 |
# bar 1.1 branchpoints: [MYBRANCH, MYBRANCH2] |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
652 |
# |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
653 |
# 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
|
654 |
# 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
|
655 |
# 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
|
656 |
# 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
|
657 |
# made to ensure that this is, in fact, what happens. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
658 |
if not ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
659 |
c |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
660 |
and e.branchpoints == c.branchpoints |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
661 |
and ( # cvs commitids |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
662 |
(e.commitid is not None and e.commitid == c.commitid) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
663 |
or ( # no commitids, use fuzzy commit detection |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
664 |
(e.commitid is None or c.commitid is None) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
665 |
and e.comment == c.comment |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
666 |
and e.author == c.author |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
667 |
and e.branch == c.branch |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
668 |
and ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
669 |
(c.date[0] + c.date[1]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
670 |
<= (e.date[0] + e.date[1]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
671 |
<= (c.date[0] + c.date[1]) + fuzz |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
672 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
673 |
and e.file not in files |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
674 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
675 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
676 |
): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
677 |
c = changeset( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
678 |
comment=e.comment, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
679 |
author=e.author, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
680 |
branch=e.branch, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
681 |
date=e.date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
682 |
entries=[], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
683 |
mergepoint=e.mergepoint, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
684 |
branchpoints=e.branchpoints, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
685 |
commitid=e.commitid, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
686 |
) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
687 |
changesets.append(c) |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
688 |
|
8456
e9e2a2c9b294
convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8225
diff
changeset
|
689 |
files = set() |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
690 |
if len(changesets) % 100 == 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
691 |
t = b'%d %s' % (len(changesets), repr(e.comment)[1:-1]) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
692 |
ui.status(stringutil.ellipsis(t, 80) + b'\n') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
693 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
694 |
c.entries.append(e) |
8456
e9e2a2c9b294
convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8225
diff
changeset
|
695 |
files.add(e.file) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
696 |
c.date = e.date # changeset date is date of latest commit in it |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
697 |
|
7862
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
698 |
# Mark synthetic changesets |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
699 |
|
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
700 |
for c in changesets: |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
701 |
# 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
|
702 |
# 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
|
703 |
# 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
|
704 |
# changesets: |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
705 |
# "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
|
706 |
# "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
|
707 |
# "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
|
708 |
# 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
|
709 |
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
|
710 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
711 |
# 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
|
712 |
|
15790
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
713 |
def entitycompare(l, r): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43503
diff
changeset
|
714 |
"""Mimic cvsps sorting order""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
715 |
l = l.file.split(b'/') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
716 |
r = r.file.split(b'/') |
15790
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
717 |
nl = len(l) |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
718 |
nr = len(r) |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
719 |
n = min(nl, nr) |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
720 |
for i in range(n): |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
721 |
if i + 1 == nl and nl < nr: |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
722 |
return -1 |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
723 |
elif i + 1 == nr and nl > nr: |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
724 |
return +1 |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
725 |
elif l[i] < r[i]: |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
726 |
return -1 |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
727 |
elif l[i] > r[i]: |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
728 |
return +1 |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
729 |
return 0 |
52f816b40674
cvsps: pull function definition out of loop
Martin Geisler <mg@aragost.com>
parents:
15205
diff
changeset
|
730 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
731 |
for c in changesets: |
37886
fe148d7544a4
cvsps: wrap cmp methods (deprecated) in functools.cmp_to_key
Augie Fackler <augie@google.com>
parents:
37884
diff
changeset
|
732 |
c.entries.sort(key=functools.cmp_to_key(entitycompare)) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
733 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
734 |
# 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
|
735 |
|
19505
7b815e38022a
convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
19145
diff
changeset
|
736 |
odd = set() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
737 |
|
31408
6e3c79bc9a35
convert: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30638
diff
changeset
|
738 |
def cscmp(l, r): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
739 |
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
|
740 |
if d: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
741 |
return d |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
742 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
743 |
# 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
|
744 |
le = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
745 |
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
|
746 |
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
|
747 |
re = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
748 |
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
|
749 |
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
|
750 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
751 |
d = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
752 |
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
|
753 |
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
|
754 |
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
|
755 |
d = 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
756 |
break |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
757 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
758 |
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
|
759 |
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
|
760 |
if d: |
7b815e38022a
convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
19145
diff
changeset
|
761 |
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
|
762 |
d = -1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
763 |
break |
22267
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
764 |
# 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
|
765 |
# 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
|
766 |
# 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
|
767 |
# 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
|
768 |
# 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
|
769 |
# 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
|
770 |
|
22267
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
771 |
# recommended replacement for cmp from |
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
772 |
# 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
|
773 |
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
|
774 |
# Sort bigger changes first. |
22267
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
775 |
if not d: |
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
776 |
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
|
777 |
# 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
|
778 |
if not d: |
867c3649be5d
cvsps: use a different tiebreaker to avoid flaky test
Augie Fackler <raf@durin42.com>
parents:
22267
diff
changeset
|
779 |
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
|
780 |
# 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
|
781 |
# a branch point. |
22267
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
782 |
if not d: |
90cf454edd70
cvsps: add two more tiebreakers in cscmp
Augie Fackler <raf@durin42.com>
parents:
22202
diff
changeset
|
783 |
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
|
784 |
return d |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
785 |
|
37886
fe148d7544a4
cvsps: wrap cmp methods (deprecated) in functools.cmp_to_key
Augie Fackler <augie@google.com>
parents:
37884
diff
changeset
|
786 |
changesets.sort(key=functools.cmp_to_key(cscmp)) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
787 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
788 |
# Collect tags |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
789 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
790 |
globaltags = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
791 |
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
|
792 |
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
|
793 |
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
|
794 |
# 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
|
795 |
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
|
796 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
797 |
for c in changesets: |
8456
e9e2a2c9b294
convert: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8225
diff
changeset
|
798 |
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
|
799 |
for e in c.entries: |
8483
221786b9ce34
convert/cvsps: use set.update for bulk update
Martin Geisler <mg@lazybytes.net>
parents:
8456
diff
changeset
|
800 |
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
|
801 |
# 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
|
802 |
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
|
803 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
804 |
# 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
|
805 |
# 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
|
806 |
# {{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
|
807 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
808 |
if mergeto is None: |
37884
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
809 |
mergeto = br'{{mergetobranch ([-\w]+)}}' |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
810 |
if mergeto: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
811 |
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
|
812 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
813 |
if mergefrom is None: |
37884
72284d296b02
cvsps: add b prefixes to regular expressions
Augie Fackler <augie@google.com>
parents:
37658
diff
changeset
|
814 |
mergefrom = br'{{mergefrombranch ([-\w]+)}}' |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
815 |
if mergefrom: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
816 |
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
|
817 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
818 |
versions = {} # changeset index where we saw any particular file version |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
819 |
branches = {} # changeset index where we saw a branch |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
820 |
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
|
821 |
i = 0 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
822 |
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
|
823 |
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
|
824 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
825 |
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
|
826 |
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
|
827 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
828 |
p = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
829 |
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
|
830 |
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
|
831 |
else: |
8756
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
832 |
# first changeset on a new branch |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
833 |
# 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
|
834 |
# 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
|
835 |
# commit without any intervening, unrelated commits. |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
836 |
|
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38295
diff
changeset
|
837 |
for candidate in pycompat.xrange(i): |
8756
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
838 |
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
|
839 |
if p is not None: |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
840 |
break |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
841 |
continue |
6019e6517f95
convert: better support for CVS branchpoints (issue1447)
Henrik Stuart <hg@hstuart.dk>
parents:
8661
diff
changeset
|
842 |
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
|
843 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
844 |
c.parents = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
845 |
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
|
846 |
p = changesets[p] |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
847 |
|
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
848 |
# 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
|
849 |
while p.synthetic: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
850 |
assert len(p.parents) <= 1, _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
851 |
b'synthetic changeset cannot have multiple parents' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
852 |
) |
7862
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
853 |
if p.parents: |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
854 |
p = p.parents[0] |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
855 |
else: |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
856 |
p = None |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
857 |
break |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
858 |
|
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
859 |
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
|
860 |
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
|
861 |
|
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
862 |
if c.mergepoint: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
863 |
if c.mergepoint == b'HEAD': |
7956
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
864 |
c.mergepoint = None |
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
865 |
c.parents.append(changesets[branches[c.mergepoint]]) |
3e7611a83230
convert: added cvsnt mergepoint support
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7950
diff
changeset
|
866 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
867 |
if mergefrom: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
868 |
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
|
869 |
if m: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
870 |
m = m.group(1) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
871 |
if m == b'HEAD': |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
872 |
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
|
873 |
try: |
4e5bd9b97bb3
cvsps: fix crash when log message refers to non-existent branch (issue1615).
Greg Ward <greg-hg@gerg.ca>
parents:
8080
diff
changeset
|
874 |
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
|
875 |
except KeyError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
876 |
ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
877 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
878 |
b"warning: CVS commit message references " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
879 |
b"non-existent branch %r:\n%s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
880 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
881 |
% (pycompat.bytestr(m), c.comment) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
882 |
) |
7950
9bbcfa898cd3
issue1578: fix crash: do not use synthetic changesets as merge parents.
Greg Ward <greg-hg@gerg.ca>
parents:
7862
diff
changeset
|
883 |
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
|
884 |
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
|
885 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
886 |
if mergeto: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
887 |
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
|
888 |
if m: |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
889 |
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
|
890 |
m = m.group(1) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
891 |
if m == b'HEAD': |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
892 |
m = None |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
893 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
894 |
m = None # if no group found then merge to HEAD |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
895 |
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
|
896 |
# insert empty changeset for merge |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
897 |
cc = changeset( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
898 |
author=c.author, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
899 |
branch=m, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
900 |
date=c.date, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
901 |
comment=b'convert-repo: CVS merge from branch %s' |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
902 |
% c.branch, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
903 |
entries=[], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
904 |
tags=[], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
905 |
parents=[changesets[branches[m]], c], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
906 |
) |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
907 |
changesets.insert(i + 1, cc) |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
908 |
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
|
909 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
910 |
# 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
|
911 |
n += 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
912 |
i += 2 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
913 |
continue |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
914 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
915 |
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
|
916 |
i += 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
917 |
|
7862
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
918 |
# 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
|
919 |
# 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
|
920 |
i = 0 |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
921 |
while i < len(changesets): |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
922 |
if changesets[i].synthetic: |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
923 |
del changesets[i] |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
924 |
else: |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
925 |
i += 1 |
02981000012e
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
Greg Ward <greg-hg@gerg.ca>
parents:
7601
diff
changeset
|
926 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
927 |
# Number changesets |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
928 |
|
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
929 |
for i, c in enumerate(changesets): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
930 |
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
|
931 |
|
19505
7b815e38022a
convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
19145
diff
changeset
|
932 |
if odd: |
7b815e38022a
convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
19145
diff
changeset
|
933 |
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
|
934 |
if l.id is not None and r.id is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
935 |
ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 |
_(b'changeset %d is both before and after %d\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
937 |
% (l.id, r.id) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
938 |
) |
19505
7b815e38022a
convert: handle changeset sorting errors without traceback (issue3961)
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
19145
diff
changeset
|
939 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
940 |
ui.status(_(b'%d changeset entries\n') % len(changesets)) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
941 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
942 |
hook.hook(ui, None, b"cvschangesets", True, changesets=changesets) |
10095
69ce7a10e593
convert: implement two hooks in builtin cvsps
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
9467
diff
changeset
|
943 |
|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
944 |
return changesets |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
945 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
946 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
947 |
def debugcvsps(ui, *args, **opts): |
8661
883f14fcd1df
convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents:
8483
diff
changeset
|
948 |
'''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
|
949 |
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
|
950 |
commit log entries and dates. |
883f14fcd1df
convert/cvsps: wrap long lines
Martin Geisler <mg@lazybytes.net>
parents:
8483
diff
changeset
|
951 |
''' |
36329
93943eef696f
py3: use pycompat.byteskwargs in hgext/convert/
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36132
diff
changeset
|
952 |
opts = pycompat.byteskwargs(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
953 |
if opts[b"new_cache"]: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
954 |
cache = b"write" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
955 |
elif opts[b"update_cache"]: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
956 |
cache = b"update" |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
957 |
else: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
958 |
cache = None |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
959 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
960 |
revisions = opts[b"revisions"] |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
961 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
962 |
try: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
963 |
if args: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
964 |
log = [] |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
965 |
for d in args: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
966 |
log += createlog(ui, d, root=opts[b"root"], cache=cache) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
967 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
968 |
log = createlog(ui, root=opts[b"root"], cache=cache) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24305
diff
changeset
|
969 |
except logerror as e: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
970 |
ui.write(b"%r\n" % e) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
971 |
return |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
972 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
973 |
changesets = createchangeset(ui, log, opts[b"fuzz"]) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
974 |
del log |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
975 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
976 |
# Print changesets (optionally filtered) |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
977 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
978 |
off = len(revisions) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
979 |
branches = {} # latest version number in each branch |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
980 |
ancestors = {} # parent branch |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
981 |
for cs in changesets: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
982 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
983 |
if opts[b"ancestors"]: |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
984 |
if cs.branch not in branches and cs.parents and cs.parents[0].id: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
985 |
ancestors[cs.branch] = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
986 |
changesets[cs.parents[0].id - 1].branch, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
987 |
cs.parents[0].id, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
988 |
) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
989 |
branches[cs.branch] = cs.id |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
990 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
991 |
# limit by branches |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
992 |
if ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
993 |
opts[b"branches"] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
994 |
and (cs.branch or b'HEAD') not in opts[b"branches"] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
995 |
): |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
996 |
continue |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
997 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
998 |
if not off: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
999 |
# 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
|
1000 |
# bug-for-bug compatibility with cvsps. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1001 |
ui.write(b'---------------------\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1002 |
ui.write((b'PatchSet %d \n' % cs.id)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1003 |
ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1004 |
( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1005 |
b'Date: %s\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1006 |
% dateutil.datestr(cs.date, b'%Y/%m/%d %H:%M:%S %1%2') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1007 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1008 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1009 |
ui.write((b'Author: %s\n' % cs.author)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1010 |
ui.write((b'Branch: %s\n' % (cs.branch or b'HEAD'))) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1011 |
ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1012 |
( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1013 |
b'Tag%s: %s \n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1014 |
% ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1015 |
[b'', b's'][len(cs.tags) > 1], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1016 |
b','.join(cs.tags) or b'(none)', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1017 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1018 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1019 |
) |
18261
1b7b5975793f
cvsps: use commitids (when present) to detect changesets
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
17956
diff
changeset
|
1020 |
if cs.branchpoints: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1021 |
ui.writenoi18n( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1022 |
b'Branchpoints: %s \n' % b', '.join(sorted(cs.branchpoints)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1023 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1024 |
if opts[b"parents"] and cs.parents: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1025 |
if len(cs.parents) > 1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1026 |
ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1027 |
( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1028 |
b'Parents: %s\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1029 |
% (b','.join([(b"%d" % p.id) for p in cs.parents])) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1030 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1031 |
) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1032 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1033 |
ui.write((b'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
|
1034 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1035 |
if opts[b"ancestors"]: |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1036 |
b = cs.branch |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1037 |
r = [] |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1038 |
while b: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1039 |
b, c = ancestors[b] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1040 |
r.append(b'%s:%d:%d' % (b or b"HEAD", c, branches[b])) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1041 |
if r: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1042 |
ui.write((b'Ancestors: %s\n' % (b','.join(r)))) |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1043 |
|
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1044 |
ui.writenoi18n(b'Log:\n') |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1045 |
ui.write(b'%s\n\n' % cs.comment) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1046 |
ui.writenoi18n(b'Members: \n') |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1047 |
for f in cs.entries: |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1048 |
fn = f.file |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1049 |
if fn.startswith(opts[b"prefix"]): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1050 |
fn = fn[len(opts[b"prefix"]) :] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1051 |
ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1052 |
b'\t%s:%s->%s%s \n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1053 |
% ( |
37887
dd071b34e60b
cvsps: portably convert int to bytes
Augie Fackler <augie@google.com>
parents:
37886
diff
changeset
|
1054 |
fn, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1055 |
b'.'.join([b"%d" % x for x in f.parent]) or b'INITIAL', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1056 |
b'.'.join([(b"%d" % x) for x in f.revision]), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1057 |
[b'', b'(DEAD)'][f.dead], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1058 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1059 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1060 |
ui.write(b'\n') |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1061 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1062 |
# have we seen the start tag? |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1063 |
if revisions and off: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1064 |
if revisions[0] == (b"%d" % cs.id) or revisions[0] in cs.tags: |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1065 |
off = False |
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1066 |
|
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1067 |
# see if we reached the end tag |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1068 |
if len(revisions) > 1 and not off: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43052
diff
changeset
|
1069 |
if revisions[1] == (b"%d" % cs.id) or revisions[1] in cs.tags: |
7502
16905fc2690f
Add debugcvsps command, replacing cvsps script
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7280
diff
changeset
|
1070 |
break |