Show More
@@ -39,6 +39,16 b' versionstr = "0.45"' | |||||
39 |
|
39 | |||
40 | commands.norepo += " qclone qversion" |
|
40 | commands.norepo += " qclone qversion" | |
41 |
|
41 | |||
|
42 | class StatusEntry: | |||
|
43 | def __init__(self, rev, name=None): | |||
|
44 | if not name: | |||
|
45 | self.rev, self.name = rev.split(':') | |||
|
46 | else: | |||
|
47 | self.rev, self.name = rev, name | |||
|
48 | ||||
|
49 | def __str__(self): | |||
|
50 | return self.rev + ':' + self.name | |||
|
51 | ||||
42 | class queue: |
|
52 | class queue: | |
43 | def __init__(self, ui, path, patchdir=None): |
|
53 | def __init__(self, ui, path, patchdir=None): | |
44 | self.basepath = path |
|
54 | self.basepath = path | |
@@ -60,7 +70,8 b' class queue:' | |||||
60 | self.read_series(self.full_series) |
|
70 | self.read_series(self.full_series) | |
61 |
|
71 | |||
62 | if os.path.exists(os.path.join(self.path, self.status_path)): |
|
72 | if os.path.exists(os.path.join(self.path, self.status_path)): | |
63 | self.applied = self.opener(self.status_path).read().splitlines() |
|
73 | self.applied = [StatusEntry(l) | |
|
74 | for l in self.opener(self.status_path).read().splitlines()] | |||
64 |
|
75 | |||
65 | def find_series(self, patch): |
|
76 | def find_series(self, patch): | |
66 | pre = re.compile("(\s*)([^#]+)") |
|
77 | pre = re.compile("(\s*)([^#]+)") | |
@@ -95,7 +106,7 b' class queue:' | |||||
95 | else: |
|
106 | else: | |
96 | nl = "" |
|
107 | nl = "" | |
97 | f = self.opener(self.status_path, "w") |
|
108 | f = self.opener(self.status_path, "w") | |
98 | f.write("\n".join(self.applied) + nl) |
|
109 | f.write("\n".join([str(x) for x in self.applied]) + nl) | |
99 | if self.series_dirty: |
|
110 | if self.series_dirty: | |
100 | if len(self.full_series) > 0: |
|
111 | if len(self.full_series) > 0: | |
101 | nl = "\n" |
|
112 | nl = "\n" | |
@@ -222,12 +233,10 b' class queue:' | |||||
222 | return p1 |
|
233 | return p1 | |
223 | if len(self.applied) == 0: |
|
234 | if len(self.applied) == 0: | |
224 | return None |
|
235 | return None | |
225 | (top, patch) = self.applied[-1].split(':') |
|
236 | return revlog.bin(self.applied[-1].rev) | |
226 | top = revlog.bin(top) |
|
|||
227 | return top |
|
|||
228 | pp = repo.changelog.parents(rev) |
|
237 | pp = repo.changelog.parents(rev) | |
229 | if pp[1] != revlog.nullid: |
|
238 | if pp[1] != revlog.nullid: | |
230 |
arevs = [ x. |
|
239 | arevs = [ x.rev for x in self.applied ] | |
231 | p0 = revlog.hex(pp[0]) |
|
240 | p0 = revlog.hex(pp[0]) | |
232 | p1 = revlog.hex(pp[1]) |
|
241 | p1 = revlog.hex(pp[1]) | |
233 | if p0 in arevs: |
|
242 | if p0 in arevs: | |
@@ -247,7 +256,7 b' class queue:' | |||||
247 | pname = ".hg.patches.merge.marker" |
|
256 | pname = ".hg.patches.merge.marker" | |
248 | n = repo.commit(None, '[mq]: merge marker', user=None, force=1, |
|
257 | n = repo.commit(None, '[mq]: merge marker', user=None, force=1, | |
249 | wlock=wlock) |
|
258 | wlock=wlock) | |
250 |
self.applied.append(revlog.hex(n) |
|
259 | self.applied.append(StatusEntry(revlog.hex(n), pname)) | |
251 | self.applied_dirty = 1 |
|
260 | self.applied_dirty = 1 | |
252 |
|
261 | |||
253 | head = self.qparents(repo) |
|
262 | head = self.qparents(repo) | |
@@ -265,7 +274,7 b' class queue:' | |||||
265 | rev = revlog.bin(info[1]) |
|
274 | rev = revlog.bin(info[1]) | |
266 | (err, head) = self.mergeone(repo, mergeq, head, patch, rev, wlock) |
|
275 | (err, head) = self.mergeone(repo, mergeq, head, patch, rev, wlock) | |
267 | if head: |
|
276 | if head: | |
268 |
self.applied.append(revlog.hex(head) |
|
277 | self.applied.append(StatusEntry(revlog.hex(head), patch)) | |
269 | self.applied_dirty = 1 |
|
278 | self.applied_dirty = 1 | |
270 | if err: |
|
279 | if err: | |
271 | return (err, head) |
|
280 | return (err, head) | |
@@ -364,7 +373,7 b' class queue:' | |||||
364 | raise util.Abort(_("repo commit failed")) |
|
373 | raise util.Abort(_("repo commit failed")) | |
365 |
|
374 | |||
366 | if update_status: |
|
375 | if update_status: | |
367 |
self.applied.append(revlog.hex(n) |
|
376 | self.applied.append(StatusEntry(revlog.hex(n), patch)) | |
368 |
|
377 | |||
369 | if patcherr: |
|
378 | if patcherr: | |
370 | if not patchfound: |
|
379 | if not patchfound: | |
@@ -402,8 +411,7 b' class queue:' | |||||
402 |
|
411 | |||
403 | def check_toppatch(self, repo): |
|
412 | def check_toppatch(self, repo): | |
404 | if len(self.applied) > 0: |
|
413 | if len(self.applied) > 0: | |
405 |
|
|
414 | top = revlog.bin(self.applied[-1].rev) | |
406 | top = revlog.bin(top) |
|
|||
407 | pp = repo.dirstate.parents() |
|
415 | pp = repo.dirstate.parents() | |
408 | if top not in pp: |
|
416 | if top not in pp: | |
409 | raise util.Abort(_("queue top not at same revision as working directory")) |
|
417 | raise util.Abort(_("queue top not at same revision as working directory")) | |
@@ -434,7 +442,7 b' class queue:' | |||||
434 | if n == None: |
|
442 | if n == None: | |
435 | raise util.Abort(_("repo commit failed")) |
|
443 | raise util.Abort(_("repo commit failed")) | |
436 | self.full_series[insert:insert] = [patch] |
|
444 | self.full_series[insert:insert] = [patch] | |
437 |
self.applied.append(revlog.hex(n) |
|
445 | self.applied.append(StatusEntry(revlog.hex(n), patch)) | |
438 | self.read_series(self.full_series) |
|
446 | self.read_series(self.full_series) | |
439 | self.series_dirty = 1 |
|
447 | self.series_dirty = 1 | |
440 | self.applied_dirty = 1 |
|
448 | self.applied_dirty = 1 | |
@@ -600,10 +608,9 b' class queue:' | |||||
600 | def isapplied(self, patch): |
|
608 | def isapplied(self, patch): | |
601 | """returns (index, rev, patch)""" |
|
609 | """returns (index, rev, patch)""" | |
602 | for i in xrange(len(self.applied)): |
|
610 | for i in xrange(len(self.applied)): | |
603 |
|
|
611 | a = self.applied[i] | |
604 |
a = p |
|
612 | if a.name == patch: | |
605 | if a[1] == patch: |
|
613 | return (i, a.rev, a.name) | |
606 | return (i, a[0], a[1]) |
|
|||
607 | return None |
|
614 | return None | |
608 |
|
615 | |||
609 | # if the exact patch name does not exist, we try a few |
|
616 | # if the exact patch name does not exist, we try a few | |
@@ -706,7 +713,7 b' class queue:' | |||||
706 | ret = self.mergepatch(repo, mergeq, s, wlock) |
|
713 | ret = self.mergepatch(repo, mergeq, s, wlock) | |
707 | else: |
|
714 | else: | |
708 | ret = self.apply(repo, s, list, wlock=wlock) |
|
715 | ret = self.apply(repo, s, list, wlock=wlock) | |
709 |
top = self.applied[-1]. |
|
716 | top = self.applied[-1].name | |
710 | if ret[0]: |
|
717 | if ret[0]: | |
711 | self.ui.write("Errors during apply, please fix and refresh %s\n" % |
|
718 | self.ui.write("Errors during apply, please fix and refresh %s\n" % | |
712 | top) |
|
719 | top) | |
@@ -743,7 +750,7 b' class queue:' | |||||
743 |
|
750 | |||
744 | if not update: |
|
751 | if not update: | |
745 | parents = repo.dirstate.parents() |
|
752 | parents = repo.dirstate.parents() | |
746 |
rr = [ revlog.bin(x. |
|
753 | rr = [ revlog.bin(x.rev) for x in self.applied ] | |
747 | for p in parents: |
|
754 | for p in parents: | |
748 | if p in rr: |
|
755 | if p in rr: | |
749 | self.ui.warn("qpop: forcing dirstate update\n") |
|
756 | self.ui.warn("qpop: forcing dirstate update\n") | |
@@ -764,7 +771,7 b' class queue:' | |||||
764 | if popi >= end: |
|
771 | if popi >= end: | |
765 | self.ui.warn("qpop: %s is already at the top\n" % patch) |
|
772 | self.ui.warn("qpop: %s is already at the top\n" % patch) | |
766 | return |
|
773 | return | |
767 |
info = [ popi ] + self.applied[popi]. |
|
774 | info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name] | |
768 |
|
775 | |||
769 | start = info[0] |
|
776 | start = info[0] | |
770 | rev = revlog.bin(info[1]) |
|
777 | rev = revlog.bin(info[1]) | |
@@ -797,7 +804,7 b' class queue:' | |||||
797 | self.strip(repo, rev, update=False, backup='strip', wlock=wlock) |
|
804 | self.strip(repo, rev, update=False, backup='strip', wlock=wlock) | |
798 | del self.applied[start:end] |
|
805 | del self.applied[start:end] | |
799 | if len(self.applied): |
|
806 | if len(self.applied): | |
800 |
self.ui.write("Now at: %s\n" % self.applied[-1]. |
|
807 | self.ui.write("Now at: %s\n" % self.applied[-1].name) | |
801 | else: |
|
808 | else: | |
802 | self.ui.write("Patch queue now empty\n") |
|
809 | self.ui.write("Patch queue now empty\n") | |
803 |
|
810 | |||
@@ -816,7 +823,7 b' class queue:' | |||||
816 | wlock = repo.wlock() |
|
823 | wlock = repo.wlock() | |
817 | self.check_toppatch(repo) |
|
824 | self.check_toppatch(repo) | |
818 | qp = self.qparents(repo) |
|
825 | qp = self.qparents(repo) | |
819 |
(top, patch) = self.applied[-1]. |
|
826 | (top, patch) = (self.applied[-1].rev, self.applied[-1].name) | |
820 | top = revlog.bin(top) |
|
827 | top = revlog.bin(top) | |
821 | cparents = repo.changelog.parents(top) |
|
828 | cparents = repo.changelog.parents(top) | |
822 | patchparent = self.qparents(repo, top) |
|
829 | patchparent = self.qparents(repo, top) | |
@@ -912,7 +919,7 b' class queue:' | |||||
912 |
|
919 | |||
913 | self.strip(repo, top, update=False, backup='strip', wlock=wlock) |
|
920 | self.strip(repo, top, update=False, backup='strip', wlock=wlock) | |
914 | n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) |
|
921 | n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock) | |
915 |
self.applied[-1] = revlog.hex(n) |
|
922 | self.applied[-1] = StatusEntry(revlog.hex(n), patch) | |
916 | self.applied_dirty = 1 |
|
923 | self.applied_dirty = 1 | |
917 | else: |
|
924 | else: | |
918 | commands.dodiff(patchf, self.ui, repo, patchparent, None) |
|
925 | commands.dodiff(patchf, self.ui, repo, patchparent, None) | |
@@ -1000,11 +1007,11 b' class queue:' | |||||
1000 | qpp = [ hg.bin(x) for x in l ] |
|
1007 | qpp = [ hg.bin(x) for x in l ] | |
1001 | elif datastart != None: |
|
1008 | elif datastart != None: | |
1002 | l = lines[i].rstrip() |
|
1009 | l = lines[i].rstrip() | |
1003 |
|
|
1010 | se = StatusEntry(l) | |
1004 |
id = |
|
1011 | id = se.rev | |
1005 |
file = |
|
1012 | file = se.name | |
1006 | if id: |
|
1013 | if id: | |
1007 |
applied.append( |
|
1014 | applied.append(se) | |
1008 | series.append(file) |
|
1015 | series.append(file) | |
1009 | if datastart == None: |
|
1016 | if datastart == None: | |
1010 | self.ui.warn("No saved patch data found\n") |
|
1017 | self.ui.warn("No saved patch data found\n") | |
@@ -1056,18 +1063,18 b' class queue:' | |||||
1056 | pp = r.dirstate.parents() |
|
1063 | pp = r.dirstate.parents() | |
1057 | msg += "\nDirstate: %s %s" % (hg.hex(pp[0]), hg.hex(pp[1])) |
|
1064 | msg += "\nDirstate: %s %s" % (hg.hex(pp[0]), hg.hex(pp[1])) | |
1058 | msg += "\n\nPatch Data:\n" |
|
1065 | msg += "\n\nPatch Data:\n" | |
1059 | text = msg + "\n".join(self.applied) + '\n' + (ar and "\n".join(ar) |
|
1066 | text = msg + "\n".join(str(self.applied)) + '\n' + (ar and "\n".join(ar) | |
1060 | + '\n' or "") |
|
1067 | + '\n' or "") | |
1061 | n = repo.commit(None, text, user=None, force=1) |
|
1068 | n = repo.commit(None, text, user=None, force=1) | |
1062 | if not n: |
|
1069 | if not n: | |
1063 | self.ui.warn("repo commit failed\n") |
|
1070 | self.ui.warn("repo commit failed\n") | |
1064 | return 1 |
|
1071 | return 1 | |
1065 |
self.applied.append(revlog.hex(n) |
|
1072 | self.applied.append(StatusEntry(revlog.hex(n),'.hg.patches.save.line')) | |
1066 | self.applied_dirty = 1 |
|
1073 | self.applied_dirty = 1 | |
1067 |
|
1074 | |||
1068 | def full_series_end(self): |
|
1075 | def full_series_end(self): | |
1069 | if len(self.applied) > 0: |
|
1076 | if len(self.applied) > 0: | |
1070 |
|
|
1077 | p = self.applied[-1].name | |
1071 | end = self.find_series(p) |
|
1078 | end = self.find_series(p) | |
1072 | if end == None: |
|
1079 | if end == None: | |
1073 | return len(self.full_series) |
|
1080 | return len(self.full_series) | |
@@ -1077,7 +1084,7 b' class queue:' | |||||
1077 | def series_end(self): |
|
1084 | def series_end(self): | |
1078 | end = 0 |
|
1085 | end = 0 | |
1079 | if len(self.applied) > 0: |
|
1086 | if len(self.applied) > 0: | |
1080 |
|
|
1087 | p = self.applied[-1].name | |
1081 | try: |
|
1088 | try: | |
1082 | end = self.series.index(p) |
|
1089 | end = self.series.index(p) | |
1083 | except ValueError: |
|
1090 | except ValueError: | |
@@ -1097,8 +1104,7 b' class queue:' | |||||
1097 | self.ui.write("%s\n" % p) |
|
1104 | self.ui.write("%s\n" % p) | |
1098 |
|
1105 | |||
1099 | def appliedname(self, index): |
|
1106 | def appliedname(self, index): | |
1100 | p = self.applied[index] |
|
1107 | pname = self.applied[index].name | |
1101 | pname = p.split(':')[1] |
|
|||
1102 | if not self.ui.verbose: |
|
1108 | if not self.ui.verbose: | |
1103 | p = pname |
|
1109 | p = pname | |
1104 | else: |
|
1110 | else: | |
@@ -1236,7 +1242,7 b' def clone(ui, source, dest=None, **opts)' | |||||
1236 | if sr.local(): |
|
1242 | if sr.local(): | |
1237 | reposetup(ui, sr) |
|
1243 | reposetup(ui, sr) | |
1238 | if sr.mq.applied: |
|
1244 | if sr.mq.applied: | |
1239 |
qbase = revlog.bin(sr.mq.applied[0]. |
|
1245 | qbase = revlog.bin(sr.mq.applied[0].rev) | |
1240 | if not hg.islocal(dest): |
|
1246 | if not hg.islocal(dest): | |
1241 | destrev = sr.parents(qbase)[0] |
|
1247 | destrev = sr.parents(qbase)[0] | |
1242 | ui.note(_('cloning main repo\n')) |
|
1248 | ui.note(_('cloning main repo\n')) | |
@@ -1314,7 +1320,7 b' def refresh(ui, repo, **opts):' | |||||
1314 | if opts['edit']: |
|
1320 | if opts['edit']: | |
1315 | if message: |
|
1321 | if message: | |
1316 | raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
|
1322 | raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) | |
1317 |
patch = q.applied[-1]. |
|
1323 | patch = q.applied[-1].name | |
1318 | (message, comment, user, date, hasdiff) = q.readheaders(patch) |
|
1324 | (message, comment, user, date, hasdiff) = q.readheaders(patch) | |
1319 | message = ui.edit('\n'.join(message), user or ui.username()) |
|
1325 | message = ui.edit('\n'.join(message), user or ui.username()) | |
1320 | q.refresh(repo, msg=message, short=opts['short']) |
|
1326 | q.refresh(repo, msg=message, short=opts['short']) | |
@@ -1492,7 +1498,7 b' def rename(ui, repo, patch, name=None, *' | |||||
1492 |
|
1498 | |||
1493 | info = q.isapplied(patch) |
|
1499 | info = q.isapplied(patch) | |
1494 | if info: |
|
1500 | if info: | |
1495 |
q.applied[info[0]] = info[1] |
|
1501 | q.applied[info[0]] = StatusEntry(info[1], name) | |
1496 | q.applied_dirty = 1 |
|
1502 | q.applied_dirty = 1 | |
1497 |
|
1503 | |||
1498 | util.rename(os.path.join(q.path, patch), absdest) |
|
1504 | util.rename(os.path.join(q.path, patch), absdest) | |
@@ -1573,7 +1579,7 b' def reposetup(ui, repo):' | |||||
1573 | if not q.applied: |
|
1579 | if not q.applied: | |
1574 | return tagscache |
|
1580 | return tagscache | |
1575 |
|
1581 | |||
1576 |
mqtags = [patch. |
|
1582 | mqtags = [(patch.rev, patch.name) for patch in q.applied] | |
1577 | mqtags.append((mqtags[-1][0], 'qtip')) |
|
1583 | mqtags.append((mqtags[-1][0], 'qtip')) | |
1578 | mqtags.append((mqtags[0][0], 'qbase')) |
|
1584 | mqtags.append((mqtags[0][0], 'qbase')) | |
1579 | for patch in mqtags: |
|
1585 | for patch in mqtags: |
General Comments 0
You need to be logged in to leave comments.
Login now