##// END OF EJS Templates
CVS convert: Find correct parent for new branch (issue704)...
Thomas Arendsen Hein -
r5920:5df7cb79 default
parent child Browse files
Show More
@@ -49,11 +49,13 b' class convert_cvs(converter_source):'
49 os.chdir(self.path)
49 os.chdir(self.path)
50 id = None
50 id = None
51 state = 0
51 state = 0
52 filerevids = {}
52 for l in util.popen(cmd):
53 for l in util.popen(cmd):
53 if state == 0: # header
54 if state == 0: # header
54 if l.startswith("PatchSet"):
55 if l.startswith("PatchSet"):
55 id = l[9:-2]
56 id = l[9:-2]
56 if maxrev and int(id) > maxrev:
57 if maxrev and int(id) > maxrev:
58 # ignore everything
57 state = 3
59 state = 3
58 elif l.startswith("Date"):
60 elif l.startswith("Date"):
59 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"])
61 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"])
@@ -64,7 +66,8 b' class convert_cvs(converter_source):'
64 self.lastbranch[branch] = id
66 self.lastbranch[branch] = id
65 elif l.startswith("Ancestor branch"):
67 elif l.startswith("Ancestor branch"):
66 ancestor = l[17:-1]
68 ancestor = l[17:-1]
67 self.parent[id] = self.lastbranch[ancestor]
69 # figure out the parent later
70 self.parent[id] = None
68 elif l.startswith("Author"):
71 elif l.startswith("Author"):
69 author = self.recode(l[8:-1])
72 author = self.recode(l[8:-1])
70 elif l.startswith("Tag:") or l.startswith("Tags:"):
73 elif l.startswith("Tag:") or l.startswith("Tags:"):
@@ -73,23 +76,36 b' class convert_cvs(converter_source):'
73 if (len(t) > 1) or (t[0] and (t[0] != "(none)")):
76 if (len(t) > 1) or (t[0] and (t[0] != "(none)")):
74 self.tags.update(dict.fromkeys(t, id))
77 self.tags.update(dict.fromkeys(t, id))
75 elif l.startswith("Log:"):
78 elif l.startswith("Log:"):
79 # switch to gathering log
76 state = 1
80 state = 1
77 log = ""
81 log = ""
78 elif state == 1: # log
82 elif state == 1: # log
79 if l == "Members: \n":
83 if l == "Members: \n":
84 # switch to gathering members
80 files = {}
85 files = {}
86 oldrevs = []
81 log = self.recode(log[:-1])
87 log = self.recode(log[:-1])
82 state = 2
88 state = 2
83 else:
89 else:
90 # gather log
84 log += l
91 log += l
85 elif state == 2:
92 elif state == 2: # members
86 if l == "\n": #
93 if l == "\n": # start of next entry
87 state = 0
94 state = 0
88 p = [self.parent[id]]
95 p = [self.parent[id]]
89 if id == "1":
96 if id == "1":
90 p = []
97 p = []
91 if branch == "HEAD":
98 if branch == "HEAD":
92 branch = ""
99 branch = ""
100 if branch and p[0] == None:
101 latest = None
102 # the last changeset that contains a base
103 # file is our parent
104 for r in oldrevs:
105 latest = max(filerevids[r], latest)
106 p = [latest]
107
108 # add current commit to set
93 c = commit(author=author, date=date, parents=p,
109 c = commit(author=author, date=date, parents=p,
94 desc=log, branch=branch)
110 desc=log, branch=branch)
95 self.changeset[id] = c
111 self.changeset[id] = c
@@ -98,9 +114,14 b' class convert_cvs(converter_source):'
98 colon = l.rfind(':')
114 colon = l.rfind(':')
99 file = l[1:colon]
115 file = l[1:colon]
100 rev = l[colon+1:-2]
116 rev = l[colon+1:-2]
101 rev = rev.split("->")[1]
117 oldrev, rev = rev.split("->")
102 files[file] = rev
118 files[file] = rev
119
120 # save some information for identifying branch points
121 oldrevs.append("%s:%s" % (oldrev, file))
122 filerevids["%s:%s" % (rev, file)] = id
103 elif state == 3:
123 elif state == 3:
124 # swallow all input
104 continue
125 continue
105
126
106 self.heads = self.lastbranch.values()
127 self.heads = self.lastbranch.values()
@@ -101,12 +101,12 b' 1 ci0 files: b/c'
101 0 Initial revision files: b/c
101 0 Initial revision files: b/c
102 o 5 (branch) ci2 files: b/c
102 o 5 (branch) ci2 files: b/c
103 |
103 |
104 o 4 () ci1 files: a b/c
104 | o 4 () ci1 files: a b/c
105 |
105 | |
106 o 3 () update tags files: .hgtags
106 | o 3 () update tags files: .hgtags
107 |
107 | |
108 o 2 () ci0 files: b/c
108 | o 2 () ci0 files: b/c
109 |
109 |/
110 | o 1 (INITIAL) import files:
110 | o 1 (INITIAL) import files:
111 |/
111 |/
112 o 0 () Initial revision files: a b/c
112 o 0 () Initial revision files: a b/c
General Comments 0
You need to be logged in to leave comments. Login now