Show More
@@ -57,12 +57,86 b' class statusentry:' | |||
|
57 | 57 | return self.rev + ':' + self.name |
|
58 | 58 | |
|
59 | 59 | class patchheader(object): |
|
60 | def __init__(self, message, comments, user, date, haspatch): | |
|
60 | def __init__(self, pf): | |
|
61 | def eatdiff(lines): | |
|
62 | while lines: | |
|
63 | l = lines[-1] | |
|
64 | if (l.startswith("diff -") or | |
|
65 | l.startswith("Index:") or | |
|
66 | l.startswith("===========")): | |
|
67 | del lines[-1] | |
|
68 | else: | |
|
69 | break | |
|
70 | def eatempty(lines): | |
|
71 | while lines: | |
|
72 | l = lines[-1] | |
|
73 | if re.match('\s*$', l): | |
|
74 | del lines[-1] | |
|
75 | else: | |
|
76 | break | |
|
77 | ||
|
78 | message = [] | |
|
79 | comments = [] | |
|
80 | user = None | |
|
81 | date = None | |
|
82 | format = None | |
|
83 | subject = None | |
|
84 | diffstart = 0 | |
|
85 | ||
|
86 | for line in file(pf): | |
|
87 | line = line.rstrip() | |
|
88 | if line.startswith('diff --git'): | |
|
89 | diffstart = 2 | |
|
90 | break | |
|
91 | if diffstart: | |
|
92 | if line.startswith('+++ '): | |
|
93 | diffstart = 2 | |
|
94 | break | |
|
95 | if line.startswith("--- "): | |
|
96 | diffstart = 1 | |
|
97 | continue | |
|
98 | elif format == "hgpatch": | |
|
99 | # parse values when importing the result of an hg export | |
|
100 | if line.startswith("# User "): | |
|
101 | user = line[7:] | |
|
102 | elif line.startswith("# Date "): | |
|
103 | date = line[7:] | |
|
104 | elif not line.startswith("# ") and line: | |
|
105 | message.append(line) | |
|
106 | format = None | |
|
107 | elif line == '# HG changeset patch': | |
|
108 | format = "hgpatch" | |
|
109 | elif (format != "tagdone" and (line.startswith("Subject: ") or | |
|
110 | line.startswith("subject: "))): | |
|
111 | subject = line[9:] | |
|
112 | format = "tag" | |
|
113 | elif (format != "tagdone" and (line.startswith("From: ") or | |
|
114 | line.startswith("from: "))): | |
|
115 | user = line[6:] | |
|
116 | format = "tag" | |
|
117 | elif format == "tag" and line == "": | |
|
118 | # when looking for tags (subject: from: etc) they | |
|
119 | # end once you find a blank line in the source | |
|
120 | format = "tagdone" | |
|
121 | elif message or line: | |
|
122 | message.append(line) | |
|
123 | comments.append(line) | |
|
124 | ||
|
125 | eatdiff(message) | |
|
126 | eatdiff(comments) | |
|
127 | eatempty(message) | |
|
128 | eatempty(comments) | |
|
129 | ||
|
130 | # make sure message isn't empty | |
|
131 | if format and format.startswith("tag") and subject: | |
|
132 | message.insert(0, "") | |
|
133 | message.insert(0, subject) | |
|
134 | ||
|
61 | 135 | self.message = message |
|
62 | 136 | self.comments = comments |
|
63 | 137 | self.user = user |
|
64 | 138 | self.date = date |
|
65 |
self.haspatch = |
|
|
139 | self.haspatch = diffstart > 1 | |
|
66 | 140 | |
|
67 | 141 | def setuser(self, user): |
|
68 | 142 | if not self.setheader(['From: ', '# User '], user): |
@@ -314,83 +388,6 b' class queue:' | |||
|
314 | 388 | if self.series_dirty: write_list(self.full_series, self.series_path) |
|
315 | 389 | if self.guards_dirty: write_list(self.active_guards, self.guards_path) |
|
316 | 390 | |
|
317 | def readheaders(self, patch): | |
|
318 | def eatdiff(lines): | |
|
319 | while lines: | |
|
320 | l = lines[-1] | |
|
321 | if (l.startswith("diff -") or | |
|
322 | l.startswith("Index:") or | |
|
323 | l.startswith("===========")): | |
|
324 | del lines[-1] | |
|
325 | else: | |
|
326 | break | |
|
327 | def eatempty(lines): | |
|
328 | while lines: | |
|
329 | l = lines[-1] | |
|
330 | if re.match('\s*$', l): | |
|
331 | del lines[-1] | |
|
332 | else: | |
|
333 | break | |
|
334 | ||
|
335 | pf = self.join(patch) | |
|
336 | message = [] | |
|
337 | comments = [] | |
|
338 | user = None | |
|
339 | date = None | |
|
340 | format = None | |
|
341 | subject = None | |
|
342 | diffstart = 0 | |
|
343 | ||
|
344 | for line in file(pf): | |
|
345 | line = line.rstrip() | |
|
346 | if line.startswith('diff --git'): | |
|
347 | diffstart = 2 | |
|
348 | break | |
|
349 | if diffstart: | |
|
350 | if line.startswith('+++ '): | |
|
351 | diffstart = 2 | |
|
352 | break | |
|
353 | if line.startswith("--- "): | |
|
354 | diffstart = 1 | |
|
355 | continue | |
|
356 | elif format == "hgpatch": | |
|
357 | # parse values when importing the result of an hg export | |
|
358 | if line.startswith("# User "): | |
|
359 | user = line[7:] | |
|
360 | elif line.startswith("# Date "): | |
|
361 | date = line[7:] | |
|
362 | elif not line.startswith("# ") and line: | |
|
363 | message.append(line) | |
|
364 | format = None | |
|
365 | elif line == '# HG changeset patch': | |
|
366 | format = "hgpatch" | |
|
367 | elif (format != "tagdone" and (line.startswith("Subject: ") or | |
|
368 | line.startswith("subject: "))): | |
|
369 | subject = line[9:] | |
|
370 | format = "tag" | |
|
371 | elif (format != "tagdone" and (line.startswith("From: ") or | |
|
372 | line.startswith("from: "))): | |
|
373 | user = line[6:] | |
|
374 | format = "tag" | |
|
375 | elif format == "tag" and line == "": | |
|
376 | # when looking for tags (subject: from: etc) they | |
|
377 | # end once you find a blank line in the source | |
|
378 | format = "tagdone" | |
|
379 | elif message or line: | |
|
380 | message.append(line) | |
|
381 | comments.append(line) | |
|
382 | ||
|
383 | eatdiff(message) | |
|
384 | eatdiff(comments) | |
|
385 | eatempty(message) | |
|
386 | eatempty(comments) | |
|
387 | ||
|
388 | # make sure message isn't empty | |
|
389 | if format and format.startswith("tag") and subject: | |
|
390 | message.insert(0, "") | |
|
391 | message.insert(0, subject) | |
|
392 | return patchheader(message, comments, user, date, diffstart > 1) | |
|
393 | ||
|
394 | 391 | def removeundo(self, repo): |
|
395 | 392 | undo = repo.sjoin('undo') |
|
396 | 393 | if not os.path.exists(undo): |
@@ -433,7 +430,7 b' class queue:' | |||
|
433 | 430 | if n is None: |
|
434 | 431 | raise util.Abort(_("repo commit failed")) |
|
435 | 432 | try: |
|
436 |
ph = mergeq. |
|
|
433 | ph = patchheader(mergeq.join(patch)) | |
|
437 | 434 | except: |
|
438 | 435 | raise util.Abort(_("unable to read %s") % patch) |
|
439 | 436 | |
@@ -560,7 +557,7 b' class queue:' | |||
|
560 | 557 | pf = os.path.join(patchdir, patchname) |
|
561 | 558 | |
|
562 | 559 | try: |
|
563 |
ph = self. |
|
|
560 | ph = patchheader(self.join(patchname)) | |
|
564 | 561 | except: |
|
565 | 562 | self.ui.warn(_("Unable to read %s\n") % patchname) |
|
566 | 563 | err = 1 |
@@ -1120,7 +1117,7 b' class queue:' | |||
|
1120 | 1117 | raise util.Abort(_("cannot refresh a revision with children")) |
|
1121 | 1118 | cparents = repo.changelog.parents(top) |
|
1122 | 1119 | patchparent = self.qparents(repo, top) |
|
1123 |
ph = self. |
|
|
1120 | ph = patchheader(self.join(patchfn)) | |
|
1124 | 1121 | |
|
1125 | 1122 | patchf = self.opener(patchfn, 'r') |
|
1126 | 1123 | |
@@ -1349,7 +1346,7 b' class queue:' | |||
|
1349 | 1346 | summary=False): |
|
1350 | 1347 | def displayname(patchname): |
|
1351 | 1348 | if summary: |
|
1352 |
ph = self. |
|
|
1349 | ph = patchheader(self.join(patchname)) | |
|
1353 | 1350 | msg = ph.message |
|
1354 | 1351 | msg = msg and ': ' + msg[0] or ': ' |
|
1355 | 1352 | else: |
@@ -1922,7 +1919,7 b' def refresh(ui, repo, *pats, **opts):' | |||
|
1922 | 1919 | if message: |
|
1923 | 1920 | raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
|
1924 | 1921 | patch = q.applied[-1].name |
|
1925 |
ph = q. |
|
|
1922 | ph = patchheader(q.join(patch)) | |
|
1926 | 1923 | message = ui.edit('\n'.join(ph.message), ph.user or ui.username()) |
|
1927 | 1924 | setupheaderopts(ui, opts) |
|
1928 | 1925 | ret = q.refresh(repo, pats, msg=message, **opts) |
@@ -1984,7 +1981,7 b' def fold(ui, repo, *files, **opts):' | |||
|
1984 | 1981 | |
|
1985 | 1982 | for p in patches: |
|
1986 | 1983 | if not message: |
|
1987 |
ph = q. |
|
|
1984 | ph = patchheader(q.join(p)) | |
|
1988 | 1985 | if ph.message: |
|
1989 | 1986 | messages.append(ph.message) |
|
1990 | 1987 | pf = q.join(p) |
@@ -1994,7 +1991,7 b' def fold(ui, repo, *files, **opts):' | |||
|
1994 | 1991 | patch.updatedir(ui, repo, files) |
|
1995 | 1992 | |
|
1996 | 1993 | if not message: |
|
1997 |
ph = q. |
|
|
1994 | ph = patchheader(q.join(parent)) | |
|
1998 | 1995 | message, user = ph.message, ph.user |
|
1999 | 1996 | for msg in messages: |
|
2000 | 1997 | message.append('* * *') |
@@ -2075,7 +2072,7 b' def header(ui, repo, patch=None):' | |||
|
2075 | 2072 | ui.write('no patches applied\n') |
|
2076 | 2073 | return 1 |
|
2077 | 2074 | patch = q.lookup('qtip') |
|
2078 |
ph = repo.mq. |
|
|
2075 | ph = patchheader(repo.mq.join(patch)) | |
|
2079 | 2076 | |
|
2080 | 2077 | ui.write('\n'.join(ph.message) + '\n') |
|
2081 | 2078 |
General Comments 0
You need to be logged in to leave comments.
Login now