Show More
@@ -53,11 +53,13 b' class convert_cvs(converter_source):' | |||
|
53 | 53 | os.chdir(self.path) |
|
54 | 54 | id = None |
|
55 | 55 | state = 0 |
|
56 | filerevids = {} | |
|
56 | 57 | for l in util.popen(cmd): |
|
57 | 58 | if state == 0: # header |
|
58 | 59 | if l.startswith("PatchSet"): |
|
59 | 60 | id = l[9:-2] |
|
60 | 61 | if maxrev and int(id) > maxrev: |
|
62 | # ignore everything | |
|
61 | 63 | state = 3 |
|
62 | 64 | elif l.startswith("Date"): |
|
63 | 65 | date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"]) |
@@ -68,7 +70,8 b' class convert_cvs(converter_source):' | |||
|
68 | 70 | self.lastbranch[branch] = id |
|
69 | 71 | elif l.startswith("Ancestor branch"): |
|
70 | 72 | ancestor = l[17:-1] |
|
71 |
|
|
|
73 | # figure out the parent later | |
|
74 | self.parent[id] = None | |
|
72 | 75 | elif l.startswith("Author"): |
|
73 | 76 | author = self.recode(l[8:-1]) |
|
74 | 77 | elif l.startswith("Tag:") or l.startswith("Tags:"): |
@@ -77,23 +80,36 b' class convert_cvs(converter_source):' | |||
|
77 | 80 | if (len(t) > 1) or (t[0] and (t[0] != "(none)")): |
|
78 | 81 | self.tags.update(dict.fromkeys(t, id)) |
|
79 | 82 | elif l.startswith("Log:"): |
|
83 | # switch to gathering log | |
|
80 | 84 | state = 1 |
|
81 | 85 | log = "" |
|
82 | 86 | elif state == 1: # log |
|
83 | 87 | if l == "Members: \n": |
|
88 | # switch to gathering members | |
|
84 | 89 | files = {} |
|
90 | oldrevs = [] | |
|
85 | 91 | log = self.recode(log[:-1]) |
|
86 | 92 | state = 2 |
|
87 | 93 | else: |
|
94 | # gather log | |
|
88 | 95 | log += l |
|
89 | elif state == 2: | |
|
90 | if l == "\n": # | |
|
96 | elif state == 2: # members | |
|
97 | if l == "\n": # start of next entry | |
|
91 | 98 | state = 0 |
|
92 | 99 | p = [self.parent[id]] |
|
93 | 100 | if id == "1": |
|
94 | 101 | p = [] |
|
95 | 102 | if branch == "HEAD": |
|
96 | 103 | branch = "" |
|
104 | if branch and p[0] == None: | |
|
105 | latest = None | |
|
106 | # the last changeset that contains a base | |
|
107 | # file is our parent | |
|
108 | for r in oldrevs: | |
|
109 | latest = max(filerevids[r], latest) | |
|
110 | p = [latest] | |
|
111 | ||
|
112 | # add current commit to set | |
|
97 | 113 | c = commit(author=author, date=date, parents=p, |
|
98 | 114 | desc=log, branch=branch) |
|
99 | 115 | self.changeset[id] = c |
@@ -102,9 +118,14 b' class convert_cvs(converter_source):' | |||
|
102 | 118 | colon = l.rfind(':') |
|
103 | 119 | file = l[1:colon] |
|
104 | 120 | rev = l[colon+1:-2] |
|
105 |
rev = rev.split("->") |
|
|
121 | oldrev, rev = rev.split("->") | |
|
106 | 122 | files[file] = rev |
|
123 | ||
|
124 | # save some information for identifying branch points | |
|
125 | oldrevs.append("%s:%s" % (oldrev, file)) | |
|
126 | filerevids["%s:%s" % (rev, file)] = id | |
|
107 | 127 | elif state == 3: |
|
128 | # swallow all input | |
|
108 | 129 | continue |
|
109 | 130 | |
|
110 | 131 | self.heads = self.lastbranch.values() |
@@ -30,6 +30,8 b' class mercurial_sink(converter_sink):' | |||
|
30 | 30 | if os.path.isdir(path) and len(os.listdir(path)) > 0: |
|
31 | 31 | try: |
|
32 | 32 | self.repo = hg.repository(self.ui, path) |
|
33 | if not self.repo.local(): | |
|
34 | raise NoRepo(_('%s is not a local Mercurial repo') % path) | |
|
33 | 35 | except hg.RepoError, err: |
|
34 | 36 | ui.print_exc() |
|
35 | 37 | raise NoRepo(err.args[0]) |
@@ -37,6 +39,8 b' class mercurial_sink(converter_sink):' | |||
|
37 | 39 | try: |
|
38 | 40 | ui.status(_('initializing destination %s repository\n') % path) |
|
39 | 41 | self.repo = hg.repository(self.ui, path, create=True) |
|
42 | if not self.repo.local(): | |
|
43 | raise NoRepo(_('%s is not a local Mercurial repo') % path) | |
|
40 | 44 | self.created.append(path) |
|
41 | 45 | except hg.RepoError, err: |
|
42 | 46 | ui.print_exc() |
@@ -646,7 +646,7 b' class svn_source(converter_source):' | |||
|
646 | 646 | # '2007-01-04T17:35:00.902377Z' |
|
647 | 647 | date = util.parsedate(date[:19] + " UTC", ["%Y-%m-%dT%H:%M:%S"]) |
|
648 | 648 | |
|
649 | log = message and self.recode(message) | |
|
649 | log = message and self.recode(message) or '' | |
|
650 | 650 | author = author and self.recode(author) or '' |
|
651 | 651 | try: |
|
652 | 652 | branch = self.module.split("/")[-1] |
@@ -15,7 +15,7 b' platform-specific details from the core.' | |||
|
15 | 15 | from i18n import _ |
|
16 | 16 | import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile, strutil |
|
17 | 17 | import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil |
|
18 |
import |
|
|
18 | import urlparse | |
|
19 | 19 | |
|
20 | 20 | try: |
|
21 | 21 | set = set |
@@ -71,3 +71,25 b' hg convert --filemap filemap src src-fil' | |||
|
71 | 71 | cat src-hg/b/c |
|
72 | 72 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
73 | 73 | |
|
74 | echo % commit branch | |
|
75 | cd src | |
|
76 | cvs -q update -r1.1 b/c | |
|
77 | cvs -q tag -b branch | |
|
78 | cvs -q update -r branch | |
|
79 | echo d >> b/c | |
|
80 | cvs -q commit -mci2 . | grep '<--' |\ | |
|
81 | sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g' | |
|
82 | cd .. | |
|
83 | ||
|
84 | echo % convert again | |
|
85 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' | |
|
86 | cat src-hg/a | |
|
87 | cat src-hg/b/c | |
|
88 | ||
|
89 | echo % convert again with --filemap | |
|
90 | hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' | |
|
91 | cat src-hg/b/c | |
|
92 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' | |
|
93 | ||
|
94 | echo "graphlog = " >> $HGRCPATH | |
|
95 | hg -R src-hg glog --template '#rev# (#branches#) #desc# files: #files#\n' |
@@ -67,3 +67,43 b' 3 ci1 files: b/c' | |||
|
67 | 67 | 2 update tags files: .hgtags |
|
68 | 68 | 1 ci0 files: b/c |
|
69 | 69 | 0 Initial revision files: b/c |
|
70 | % commit branch | |
|
71 | U b/c | |
|
72 | T a | |
|
73 | T b/c | |
|
74 | checking in src/b/c,v | |
|
75 | % convert again | |
|
76 | connecting to cvsrepo | |
|
77 | scanning source... | |
|
78 | sorting... | |
|
79 | converting... | |
|
80 | 0 ci2 | |
|
81 | a | |
|
82 | a | |
|
83 | c | |
|
84 | d | |
|
85 | % convert again with --filemap | |
|
86 | connecting to cvsrepo | |
|
87 | scanning source... | |
|
88 | sorting... | |
|
89 | converting... | |
|
90 | 0 ci2 | |
|
91 | c | |
|
92 | d | |
|
93 | 4 ci2 files: b/c | |
|
94 | 3 ci1 files: b/c | |
|
95 | 2 update tags files: .hgtags | |
|
96 | 1 ci0 files: b/c | |
|
97 | 0 Initial revision files: b/c | |
|
98 | o 5 (branch) ci2 files: b/c | |
|
99 | | | |
|
100 | | o 4 () ci1 files: a b/c | |
|
101 | | | | |
|
102 | | o 3 () update tags files: .hgtags | |
|
103 | | | | |
|
104 | | o 2 () ci0 files: b/c | |
|
105 | |/ | |
|
106 | | o 1 (INITIAL) import files: | |
|
107 | |/ | |
|
108 | o 0 () Initial revision files: a b/c | |
|
109 |
General Comments 0
You need to be logged in to leave comments.
Login now