Mercurial > hg
annotate hgext/convert/cvsps.py @ 6907:6dcbe191a9b5
Fix up tests
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 18 Aug 2008 16:50:36 -0500 |
parents | f67d1468ac50 |
children | 12472a240398 |
rev | line source |
---|---|
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
1 # |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
2 # Mercurial built-in replacement for cvsps. |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
3 # |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
4 # Copyright 2008, Frank Kingswood <frank@kingswood-consulting.co.uk> |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
5 # |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
7 # of the GNU General Public License, incorporated herein by reference. |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
8 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
9 import os |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
10 import re |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
11 import sys |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
12 import cPickle as pickle |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
13 from mercurial import util |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
14 from mercurial.i18n import _ |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
15 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
16 def listsort(list, key): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
17 "helper to sort by key in Python 2.3" |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
18 try: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
19 list.sort(key=key) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
20 except TypeError: |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
21 list.sort(lambda l, r: cmp(key(l), key(r))) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
22 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
23 class logentry(object): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
24 '''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
|
25 .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
|
26 .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
|
27 .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
|
28 .comment - commit message |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
29 .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
|
30 .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
|
31 .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
|
32 .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
|
33 .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
|
34 .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
|
35 .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
|
36 .tags - list of tags on the file |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
37 ''' |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
38 def __init__(self, **entries): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
39 self.__dict__.update(entries) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
40 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
41 class logerror(Exception): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
42 pass |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
43 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
44 def createlog(ui, directory=None, root="", rlog=True, cache=None): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
45 '''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
|
46 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
47 # 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
|
48 # 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
|
49 _scache = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
50 def scache(s): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
51 "return a shared version of a string" |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
52 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
|
53 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
54 ui.status(_('collecting CVS rlog\n')) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
55 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
56 log = [] # list of logentry objects containing the CVS state |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
57 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
58 # patterns to match in CVS (r)log output, by state of use |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
59 re_00 = re.compile('RCS file: (.+)$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
60 re_01 = re.compile('cvs \\[r?log aborted\\]: (.+)$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
61 re_02 = re.compile('cvs (r?log|server): (.+)\n$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
62 re_03 = re.compile("(Cannot access.+CVSROOT)|(can't create temporary directory.+)$") |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
63 re_10 = re.compile('Working file: (.+)$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
64 re_20 = re.compile('symbolic names:') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
65 re_30 = re.compile('\t(.+): ([\\d.]+)$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
66 re_31 = re.compile('----------------------------$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
67 re_32 = re.compile('=============================================================================$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
68 re_50 = re.compile('revision ([\\d.]+)(\s+locked by:\s+.+;)?$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
69 re_60 = re.compile(r'date:\s+(.+);\s+author:\s+(.+);\s+state:\s+(.+?);(\s+lines:\s+(\+\d+)?\s+(-\d+)?;)?') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
70 re_70 = re.compile('branches: (.+);$') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
71 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
72 prefix = '' # leading path to strip of what we get from CVS |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
73 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
74 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
|
75 # 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
|
76 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
77 # 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
|
78 try: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
79 prefix = file(os.path.join('CVS','Repository')).read().strip() |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
80 if prefix == ".": |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
81 prefix = "" |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
82 directory = prefix |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
83 except IOError: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
84 raise logerror('Not a CVS sandbox') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
85 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
86 if prefix and not prefix.endswith('/'): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
87 prefix += '/' |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
88 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
89 # 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
|
90 try: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
91 root = file(os.path.join('CVS','Root')).read().strip() |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
92 except IOError: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
93 pass |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
94 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
95 if not root: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
96 root = os.environ.get('CVSROOT', '') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
97 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
98 # 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
|
99 oldlog = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
100 date = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
101 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
102 if cache: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
103 cachedir = os.path.expanduser('~/.hg.cvsps') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
104 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
|
105 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
|
106 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
107 # 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
|
108 # 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
|
109 # in it, slashes, colons and such. So here we take just the |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
110 # alphanumerics, concatenated in a way that does not mix up the |
6696
49c0be9eb8c4
cvsps: fix a final whitespace nit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6688
diff
changeset
|
111 # 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
|
112 # :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
|
113 # and |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
114 # /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
|
115 # are mapped to different cache file names. |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
116 cachefile = root.split(":") + [directory, "cache"] |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
117 cachefile = ['-'.join(re.findall(r'\w+', s)) for s in cachefile if s] |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
118 cachefile = os.path.join(cachedir, |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
119 '.'.join([s for s in cachefile if s])) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
120 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
121 if cache == 'update': |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
122 try: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
123 ui.note(_('reading cvs log cache %s\n') % cachefile) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
124 oldlog = pickle.load(file(cachefile)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
125 ui.note(_('cache has %d log entries\n') % len(oldlog)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
126 except Exception, e: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
127 ui.note(_('error reading cache: %r\n') % e) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
128 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
129 if oldlog: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
130 date = oldlog[-1].date # last commit date as a (time,tz) tuple |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
131 date = util.datestr(date, '%Y/%m/%d %H:%M:%S %1%2') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
132 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
133 # build the CVS commandline |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
134 cmd = ['cvs', '-q'] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
135 if root: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
136 cmd.append('-d%s' % root) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
137 p = root.split(':')[-1] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
138 if not p.endswith('/'): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
139 p += '/' |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
140 prefix = p + prefix |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
141 cmd.append(['log', 'rlog'][rlog]) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
142 if date: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
143 # no space between option and date string |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
144 cmd.append('-d>%s' % date) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
145 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
|
146 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
147 # state machine begins here |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
148 tags = {} # dictionary of revisions on current file with their tags |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
149 state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
150 store = False # set when a new record can be appended |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
151 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
152 cmd = [util.shellquote(arg) for arg in cmd] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
153 ui.note("running %s\n" % (' '.join(cmd))) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
154 ui.debug("prefix=%r directory=%r root=%r\n" % (prefix, directory, root)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
155 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
156 for line in util.popen(' '.join(cmd)): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
157 if line.endswith('\n'): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
158 line = line[:-1] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
159 #ui.debug('state=%d line=%r\n' % (state, line)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
160 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
161 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
|
162 # 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
|
163 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
|
164 if match: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
165 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
|
166 tags = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
167 if rlog: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
168 filename = rcs[:-2] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
169 if filename.startswith(prefix): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
170 filename = filename[len(prefix):] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
171 if filename.startswith('/'): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
172 filename = filename[1:] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
173 if filename.startswith('Attic/'): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
174 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
|
175 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
176 filename = filename.replace('/Attic/', '/') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
177 state = 2 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
178 continue |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
179 state = 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
180 continue |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
181 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
|
182 if match: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
183 raise Exception(match.group(1)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
184 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
|
185 if match: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
186 raise Exception(match.group(2)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
187 if re_03.match(line): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
188 raise Exception(line) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
189 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
190 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
|
191 # 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
|
192 match = re_10.match(line) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
193 assert match, _('RCS file must be followed by working file') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
194 filename = 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
|
195 state = 2 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
196 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
197 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
|
198 # 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
|
199 if re_20.match(line): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
200 state = 3 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
201 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
202 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
|
203 # 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
|
204 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
|
205 if match: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
206 rev = [int(x) for x in match.group(2).split('.')] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
207 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
208 # 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
|
209 revn = len(rev) |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
210 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
|
211 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
|
212 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
|
213 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
214 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
|
215 tags[rev] = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
216 tags[rev].append(match.group(1)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
217 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
218 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
|
219 state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
220 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
|
221 state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
222 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
223 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
|
224 # 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
|
225 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
|
226 state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
227 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
228 assert not re_32.match(line), _('Must have at least some revisions') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
229 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
230 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
|
231 # 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
|
232 # 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
|
233 # 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
|
234 match = re_50.match(line) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
235 assert match, _('expected revision number') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
236 e = logentry(rcs=scache(rcs), file=scache(filename), |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
237 revision=tuple([int(x) for x in match.group(1).split('.')]), |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
238 branches=[], parent=None) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
239 state = 6 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
240 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
241 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
|
242 # 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
|
243 match = re_60.match(line) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
244 assert match, _('revision must be followed by date line') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
245 d = match.group(1) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
246 if d[2] == '/': |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
247 # Y2K |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
248 d = '19' + d |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
249 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
250 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
|
251 # cvs log dates always in GMT |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
252 d = d + ' UTC' |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
253 e.date = util.parsedate(d, ['%y/%m/%d %H:%M:%S', '%Y/%m/%d %H:%M:%S', '%Y-%m-%d %H:%M:%S']) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
254 e.author = scache(match.group(2)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
255 e.dead = match.group(3).lower() == 'dead' |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
256 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
265 e.lines = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
266 e.comment = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
267 state = 7 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
268 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
269 elif state == 7: |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
270 # 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
|
271 # 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
|
272 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
|
273 if m: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
274 e.branches = [tuple([int(y) for y in x.strip().split('.')]) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
275 for x in m.group(1).split(';')] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
276 state = 8 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
277 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
|
278 state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
279 store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
280 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
|
281 state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
282 store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
283 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
284 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
|
285 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
286 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
|
287 # 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
|
288 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
|
289 state = 5 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
290 store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
291 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
|
292 state = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
293 store = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
294 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
295 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
|
296 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
297 if store: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
298 # 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
|
299 store = False |
6762 | 300 e.tags = util.sort([scache(x) for x in tags.get(e.revision, [])]) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
301 e.comment = scache('\n'.join(e.comment)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
302 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
303 revn = len(e.revision) |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
304 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
|
305 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
|
306 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
307 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
|
308 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
309 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
|
310 |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
311 if len(log) % 100 == 0: |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
312 ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80)+'\n') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
313 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
314 listsort(log, key=lambda x:(x.rcs, x.revision)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
315 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
316 # 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
|
317 versions = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
326 # 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
|
327 if cache: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
328 if log: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
329 # join up the old and new logs |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
330 listsort(log, key=lambda x:x.date) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
331 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
332 if oldlog and oldlog[-1].date >= log[0].date: |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
333 raise logerror('Log cache overlaps with new log entries,' |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
334 ' re-run without cache.') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
335 |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
336 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
|
337 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
338 # write the new cachefile |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
339 ui.note(_('writing cvs log cache %s\n') % cachefile) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
340 pickle.dump(log, file(cachefile, 'w')) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
341 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
342 log = oldlog |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
343 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
344 ui.status(_('%d log entries\n') % len(log)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
345 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
346 return log |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
347 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
348 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
349 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
|
350 '''Class changeset has the following attributes: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
351 .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
|
352 .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
|
353 .comment - commit message |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
354 .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
|
355 .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
|
356 .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
|
357 .tags - list of tags on this changeset |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
358 ''' |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
359 def __init__(self, **entries): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
360 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
|
361 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
362 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
|
363 '''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
|
364 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
365 ui.status(_('creating changesets\n')) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
366 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
367 # Merge changesets |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
368 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
369 listsort(log, key=lambda x:(x.comment, x.author, x.branch, x.date)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
370 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
371 changesets = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
372 files = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
373 c = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
374 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
|
375 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
376 # Check if log entry belongs to the current changeset or not. |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
377 if not (c and |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
378 e.comment == c.comment and |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
379 e.author == c.author and |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
380 e.branch == c.branch and |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
381 ((c.date[0] + c.date[1]) <= |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
382 (e.date[0] + e.date[1]) <= |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
383 (c.date[0] + c.date[1]) + fuzz) and |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
384 e.file not in files): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
385 c = changeset(comment=e.comment, author=e.author, |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
386 branch=e.branch, date=e.date, entries=[]) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
387 changesets.append(c) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
388 files = {} |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
389 if len(changesets) % 100 == 0: |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
390 t = '%d %s' % (len(changesets), repr(e.comment)[1:-1]) |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
391 ui.status(util.ellipsis(t, 80) + '\n') |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
392 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
393 c.entries.append(e) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
394 files[e.file] = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
395 c.date = e.date # changeset date is date of latest commit in it |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
396 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
397 # 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
|
398 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
399 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
|
400 def pathcompare(l, r): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
401 'Mimic cvsps sorting order' |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
402 l = l.split('/') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
403 r = r.split('/') |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
404 nl = len(l) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
405 nr = len(r) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
406 n = min(nl, nr) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
407 for i in range(n): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
408 if i + 1 == nl and nl < nr: |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
409 return -1 |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
410 elif i + 1 == nr and nl > nr: |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
411 return +1 |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
412 elif l[i] < r[i]: |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
413 return -1 |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
414 elif l[i] > r[i]: |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
415 return +1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
416 return 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
417 def entitycompare(l, r): |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
418 return pathcompare(l.file, r.file) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
419 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
420 c.entries.sort(entitycompare) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
421 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
422 # 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
|
423 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
424 def cscmp(l, r): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
425 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
|
426 if d: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
427 return d |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
428 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
429 # 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
|
430 le = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
431 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
|
432 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
|
433 re = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
434 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
|
435 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
|
436 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
437 d = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
438 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
|
439 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
|
440 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
|
441 d = 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
442 break |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
443 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
444 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
|
445 if le.get(e.rcs, None) == e.parent: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
446 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
|
447 d = -1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
448 break |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
449 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
450 return d |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
451 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
452 changesets.sort(cscmp) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
453 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
454 # Collect tags |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
455 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
456 globaltags = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
457 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
|
458 tags = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
459 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
|
460 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
|
461 # 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
|
462 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
|
463 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
464 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
|
465 tags = {} |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
466 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
|
467 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
|
468 tags[tag] = True |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
469 # remember tags only if this is the latest changeset to have it |
6762 | 470 c.tags = util.sort([tag for tag in tags if globaltags[tag] is c]) |
6687
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
471 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
472 # 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
|
473 # 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
|
474 # {{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
|
475 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
476 if mergeto is None: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
477 mergeto = r'{{mergetobranch ([-\w]+)}}' |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
478 if mergeto: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
479 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
|
480 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
481 if mergefrom is None: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
482 mergefrom = r'{{mergefrombranch ([-\w]+)}}' |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
483 if mergefrom: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
484 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
|
485 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
486 versions = {} # changeset index where we saw any particular file version |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
487 branches = {} # changeset index where we saw a branch |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
488 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
|
489 i = 0 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
490 while i<n: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
491 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
|
492 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
493 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
|
494 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
|
495 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
496 p = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
497 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
|
498 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
|
499 else: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
500 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
|
501 p = max(p, versions.get((f.rcs, f.parent), None)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
502 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
503 c.parents = [] |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
504 if p is not None: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
505 c.parents.append(changesets[p]) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
506 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
507 if mergefrom: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
508 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
|
509 if m: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
510 m = m.group(1) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
511 if m == 'HEAD': |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
512 m = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
513 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
|
514 c.parents.append(changesets[branches[m]]) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
515 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
516 if mergeto: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
517 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
|
518 if m: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
519 try: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
520 m = m.group(1) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
521 if m == 'HEAD': |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
522 m = None |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
523 except: |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
524 m = None # if no group found then merge to HEAD |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
525 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
|
526 # insert empty changeset for merge |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
527 cc = changeset(author=c.author, branch=m, date=c.date, |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
528 comment='convert-repo: CVS merge from branch %s' % c.branch, |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
529 entries=[], tags=[], parents=[changesets[branches[m]], c]) |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
530 changesets.insert(i + 1, cc) |
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
531 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
|
532 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
533 # 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
|
534 n += 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
535 i += 2 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
536 continue |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
537 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
538 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
|
539 i += 1 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
540 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
541 # Number changesets |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
542 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
543 for i, c in enumerate(changesets): |
6688
5cd7a8433cd4
cvsps: fix up some whitespace
Matt Mackall <mpm@selenic.com>
parents:
6687
diff
changeset
|
544 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
|
545 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
546 ui.status(_('%d changeset entries\n') % len(changesets)) |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
547 |
f8ef39206f6a
convert: cvsps.py - code to generate changesets from a CVS repository
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
diff
changeset
|
548 return changesets |