Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/mq.py @ 1852:fdf9cbf56ec7
Fix mq's usage of opener, which don't allow absolute paths now.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 07 Mar 2006 22:41:24 +0100 |
parents | 876e4e6ad82b |
children | e8b86fb8ae33 |
comparison
equal
deleted
inserted
replaced
1851:5c374776a8bc | 1852:fdf9cbf56ec7 |
---|---|
15 | 15 |
16 repomap = {} | 16 repomap = {} |
17 | 17 |
18 class queue: | 18 class queue: |
19 def __init__(self, ui, path, patchdir=None): | 19 def __init__(self, ui, path, patchdir=None): |
20 self.opener = util.opener(path) | |
21 self.basepath = path | 20 self.basepath = path |
22 if patchdir: | 21 if patchdir: |
23 self.path = patchdir | 22 self.path = patchdir |
24 else: | 23 else: |
25 self.path = os.path.join(path, "patches") | 24 self.path = os.path.join(path, "patches") |
25 self.opener = util.opener(self.path) | |
26 self.ui = ui | 26 self.ui = ui |
27 self.applied = [] | 27 self.applied = [] |
28 self.full_series = [] | 28 self.full_series = [] |
29 self.applied_dirty = 0 | 29 self.applied_dirty = 0 |
30 self.series_dirty = 0 | 30 self.series_dirty = 0 |
31 self.series_path = os.path.join(self.path, "series") | 31 self.series_path = "series" |
32 self.status_path = os.path.join(self.path, "status") | 32 self.status_path = "status" |
33 | 33 |
34 s = self.series_path | 34 if os.path.exists(os.path.join(self.path, self.series_path)): |
35 if os.path.exists(s): | 35 self.full_series = self.opener(self.series_path).read().splitlines() |
36 self.full_series = self.opener(s).read().splitlines() | |
37 self.read_series(self.full_series) | 36 self.read_series(self.full_series) |
38 | 37 |
39 s = self.status_path | 38 if os.path.exists(os.path.join(self.path, self.status_path)): |
40 if os.path.exists(s): | 39 self.applied = self.opener(self.status_path).read().splitlines() |
41 self.applied = self.opener(s).read().splitlines() | |
42 | 40 |
43 def find_series(self, patch): | 41 def find_series(self, patch): |
44 pre = re.compile("(\s*)([^#]+)") | 42 pre = re.compile("(\s*)([^#]+)") |
45 index = 0 | 43 index = 0 |
46 for l in self.full_series: | 44 for l in self.full_series: |
184 message, comments, user, patchfound = mergeq.readheaders(patch) | 182 message, comments, user, patchfound = mergeq.readheaders(patch) |
185 except: | 183 except: |
186 self.ui.warn("Unable to read %s\n" % patch) | 184 self.ui.warn("Unable to read %s\n" % patch) |
187 sys.exit(1) | 185 sys.exit(1) |
188 | 186 |
189 patchf = self.opener(os.path.join(self.path, patch), "w") | 187 patchf = self.opener(patch, "w") |
190 if comments: | 188 if comments: |
191 comments = "\n".join(comments) + '\n\n' | 189 comments = "\n".join(comments) + '\n\n' |
192 patchf.write(comments) | 190 patchf.write(comments) |
193 commands.dodiff(patchf, self.ui, repo, head, n) | 191 commands.dodiff(patchf, self.ui, repo, head, n) |
194 patchf.close() | 192 patchf.close() |
400 self.full_series[insert:insert] = [patch] | 398 self.full_series[insert:insert] = [patch] |
401 self.applied.append(revlog.hex(n) + ":" + patch) | 399 self.applied.append(revlog.hex(n) + ":" + patch) |
402 self.read_series(self.full_series) | 400 self.read_series(self.full_series) |
403 self.series_dirty = 1 | 401 self.series_dirty = 1 |
404 self.applied_dirty = 1 | 402 self.applied_dirty = 1 |
405 p = self.opener(os.path.join(self.path, patch), "w") | 403 p = self.opener(patch, "w") |
406 if msg: | 404 if msg: |
407 msg = msg + "\n" | 405 msg = msg + "\n" |
408 p.write(msg) | 406 p.write(msg) |
409 p.close() | 407 p.close() |
410 wlock = None | 408 wlock = None |
714 top = revlog.bin(top) | 712 top = revlog.bin(top) |
715 cparents = repo.changelog.parents(top) | 713 cparents = repo.changelog.parents(top) |
716 patchparent = self.qparents(repo, top) | 714 patchparent = self.qparents(repo, top) |
717 message, comments, user, patchfound = self.readheaders(patch) | 715 message, comments, user, patchfound = self.readheaders(patch) |
718 | 716 |
719 patchf = self.opener(os.path.join(self.path, patch), "w") | 717 patchf = self.opener(patch, "w") |
720 if comments: | 718 if comments: |
721 comments = "\n".join(comments) + '\n\n' | 719 comments = "\n".join(comments) + '\n\n' |
722 patchf.write(comments) | 720 patchf.write(comments) |
723 | 721 |
724 tip = repo.changelog.tip() | 722 tip = repo.changelog.tip() |
833 list = [] | 831 list = [] |
834 for root, dirs, files in os.walk(self.path): | 832 for root, dirs, files in os.walk(self.path): |
835 d = root[len(self.path) + 1:] | 833 d = root[len(self.path) + 1:] |
836 for f in files: | 834 for f in files: |
837 fl = os.path.join(d, f) | 835 fl = os.path.join(d, f) |
838 if (fl not in self.series and fl != "status" and | 836 if (fl not in self.series and |
839 fl != "series" and not fl.startswith('.')): | 837 fl not in (self.status_path, self.series_path) |
838 and not fl.startswith('.')): | |
840 list.append(fl) | 839 list.append(fl) |
841 list.sort() | 840 list.sort() |
842 if list: | 841 if list: |
843 for x in list: | 842 for x in list: |
844 if self.ui.verbose: | 843 if self.ui.verbose: |
1010 if not patch: | 1009 if not patch: |
1011 patch = os.path.split(filename)[1] | 1010 patch = os.path.split(filename)[1] |
1012 if not force and os.path.isfile(os.path.join(self.path, patch)): | 1011 if not force and os.path.isfile(os.path.join(self.path, patch)): |
1013 self.ui.warn("patch %s already exists\n" % patch) | 1012 self.ui.warn("patch %s already exists\n" % patch) |
1014 sys.exit(1) | 1013 sys.exit(1) |
1015 patchf = self.opener(os.path.join(self.path, patch), "w") | 1014 patchf = self.opener(patch, "w") |
1016 patchf.write(text) | 1015 patchf.write(text) |
1017 if patch in self.series: | 1016 if patch in self.series: |
1018 self.ui.warn("patch %s is already in the series file\n" % patch) | 1017 self.ui.warn("patch %s is already in the series file\n" % patch) |
1019 sys.exit(1) | 1018 sys.exit(1) |
1020 index = self.series_end() + i | 1019 index = self.series_end() + i |
1203 newpath = savename(path) | 1202 newpath = savename(path) |
1204 ui.warn("copy %s to %s\n" % (path, newpath)) | 1203 ui.warn("copy %s to %s\n" % (path, newpath)) |
1205 util.copyfiles(path, newpath) | 1204 util.copyfiles(path, newpath) |
1206 if opts['empty']: | 1205 if opts['empty']: |
1207 try: | 1206 try: |
1208 os.unlink(q.status_path) | 1207 os.unlink(os.path.join(q.path, q.status_path)) |
1209 except: | 1208 except: |
1210 pass | 1209 pass |
1211 return 0 | 1210 return 0 |
1212 | 1211 |
1213 def strip(ui, repo, rev, **opts): | 1212 def strip(ui, repo, rev, **opts): |