Mercurial > hg
comparison hgext/convert/cvs.py @ 5921:549a7ebe1607
merge with crew-stable
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 22 Jan 2008 00:55:01 +0100 |
parents | 493632bb171c 5df7cb799baf |
children | fb259a3572e9 |
comparison
equal
deleted
inserted
replaced
5915:d0576d065993 | 5921:549a7ebe1607 |
---|---|
51 d = os.getcwd() | 51 d = os.getcwd() |
52 try: | 52 try: |
53 os.chdir(self.path) | 53 os.chdir(self.path) |
54 id = None | 54 id = None |
55 state = 0 | 55 state = 0 |
56 filerevids = {} | |
56 for l in util.popen(cmd): | 57 for l in util.popen(cmd): |
57 if state == 0: # header | 58 if state == 0: # header |
58 if l.startswith("PatchSet"): | 59 if l.startswith("PatchSet"): |
59 id = l[9:-2] | 60 id = l[9:-2] |
60 if maxrev and int(id) > maxrev: | 61 if maxrev and int(id) > maxrev: |
62 # ignore everything | |
61 state = 3 | 63 state = 3 |
62 elif l.startswith("Date"): | 64 elif l.startswith("Date"): |
63 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"]) | 65 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"]) |
64 date = util.datestr(date) | 66 date = util.datestr(date) |
65 elif l.startswith("Branch"): | 67 elif l.startswith("Branch"): |
66 branch = l[8:-1] | 68 branch = l[8:-1] |
67 self.parent[id] = self.lastbranch.get(branch, 'bad') | 69 self.parent[id] = self.lastbranch.get(branch, 'bad') |
68 self.lastbranch[branch] = id | 70 self.lastbranch[branch] = id |
69 elif l.startswith("Ancestor branch"): | 71 elif l.startswith("Ancestor branch"): |
70 ancestor = l[17:-1] | 72 ancestor = l[17:-1] |
71 self.parent[id] = self.lastbranch[ancestor] | 73 # figure out the parent later |
74 self.parent[id] = None | |
72 elif l.startswith("Author"): | 75 elif l.startswith("Author"): |
73 author = self.recode(l[8:-1]) | 76 author = self.recode(l[8:-1]) |
74 elif l.startswith("Tag:") or l.startswith("Tags:"): | 77 elif l.startswith("Tag:") or l.startswith("Tags:"): |
75 t = l[l.index(':')+1:] | 78 t = l[l.index(':')+1:] |
76 t = [ut.strip() for ut in t.split(',')] | 79 t = [ut.strip() for ut in t.split(',')] |
77 if (len(t) > 1) or (t[0] and (t[0] != "(none)")): | 80 if (len(t) > 1) or (t[0] and (t[0] != "(none)")): |
78 self.tags.update(dict.fromkeys(t, id)) | 81 self.tags.update(dict.fromkeys(t, id)) |
79 elif l.startswith("Log:"): | 82 elif l.startswith("Log:"): |
83 # switch to gathering log | |
80 state = 1 | 84 state = 1 |
81 log = "" | 85 log = "" |
82 elif state == 1: # log | 86 elif state == 1: # log |
83 if l == "Members: \n": | 87 if l == "Members: \n": |
88 # switch to gathering members | |
84 files = {} | 89 files = {} |
90 oldrevs = [] | |
85 log = self.recode(log[:-1]) | 91 log = self.recode(log[:-1]) |
86 state = 2 | 92 state = 2 |
87 else: | 93 else: |
94 # gather log | |
88 log += l | 95 log += l |
89 elif state == 2: | 96 elif state == 2: # members |
90 if l == "\n": # | 97 if l == "\n": # start of next entry |
91 state = 0 | 98 state = 0 |
92 p = [self.parent[id]] | 99 p = [self.parent[id]] |
93 if id == "1": | 100 if id == "1": |
94 p = [] | 101 p = [] |
95 if branch == "HEAD": | 102 if branch == "HEAD": |
96 branch = "" | 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 c = commit(author=author, date=date, parents=p, | 113 c = commit(author=author, date=date, parents=p, |
98 desc=log, branch=branch) | 114 desc=log, branch=branch) |
99 self.changeset[id] = c | 115 self.changeset[id] = c |
100 self.files[id] = files | 116 self.files[id] = files |
101 else: | 117 else: |
102 colon = l.rfind(':') | 118 colon = l.rfind(':') |
103 file = l[1:colon] | 119 file = l[1:colon] |
104 rev = l[colon+1:-2] | 120 rev = l[colon+1:-2] |
105 rev = rev.split("->")[1] | 121 oldrev, rev = rev.split("->") |
106 files[file] = rev | 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 elif state == 3: | 127 elif state == 3: |
128 # swallow all input | |
108 continue | 129 continue |
109 | 130 |
110 self.heads = self.lastbranch.values() | 131 self.heads = self.lastbranch.values() |
111 finally: | 132 finally: |
112 os.chdir(d) | 133 os.chdir(d) |