Show More
@@ -56,10 +56,7 b' class statusentry:' | |||||
56 | class queue: |
|
56 | class queue: | |
57 | def __init__(self, ui, path, patchdir=None): |
|
57 | def __init__(self, ui, path, patchdir=None): | |
58 | self.basepath = path |
|
58 | self.basepath = path | |
59 | if patchdir: |
|
59 | self.path = patchdir or os.path.join(path, "patches") | |
60 | self.path = patchdir |
|
|||
61 | else: |
|
|||
62 | self.path = os.path.join(path, "patches") |
|
|||
63 | self.opener = util.opener(self.path) |
|
60 | self.opener = util.opener(self.path) | |
64 | self.ui = ui |
|
61 | self.ui = ui | |
65 | self.applied = [] |
|
62 | self.applied = [] | |
@@ -69,14 +66,17 b' class queue:' | |||||
69 | self.series_path = "series" |
|
66 | self.series_path = "series" | |
70 | self.status_path = "status" |
|
67 | self.status_path = "status" | |
71 |
|
68 | |||
72 |
if os.path.exists( |
|
69 | if os.path.exists(self.join(self.series_path)): | |
73 | self.full_series = self.opener(self.series_path).read().splitlines() |
|
70 | self.full_series = self.opener(self.series_path).read().splitlines() | |
74 | self.parse_series() |
|
71 | self.parse_series() | |
75 |
|
72 | |||
76 |
if os.path.exists( |
|
73 | if os.path.exists(self.join(self.status_path)): | |
77 | self.applied = [statusentry(l) |
|
74 | self.applied = [statusentry(l) | |
78 | for l in self.opener(self.status_path).read().splitlines()] |
|
75 | for l in self.opener(self.status_path).read().splitlines()] | |
79 |
|
76 | |||
|
77 | def join(self, *p): | |||
|
78 | return os.path.join(self.path, *p) | |||
|
79 | ||||
80 | def find_series(self, patch): |
|
80 | def find_series(self, patch): | |
81 | pre = re.compile("(\s*)([^#]+)") |
|
81 | pre = re.compile("(\s*)([^#]+)") | |
82 | index = 0 |
|
82 | index = 0 | |
@@ -124,7 +124,7 b' class queue:' | |||||
124 | else: |
|
124 | else: | |
125 | break |
|
125 | break | |
126 |
|
126 | |||
127 |
pf = |
|
127 | pf = self.join(patch) | |
128 | message = [] |
|
128 | message = [] | |
129 | comments = [] |
|
129 | comments = [] | |
130 | user = None |
|
130 | user = None | |
@@ -390,7 +390,7 b' class queue:' | |||||
390 | if r: |
|
390 | if r: | |
391 | r.remove([patch], True) |
|
391 | r.remove([patch], True) | |
392 | else: |
|
392 | else: | |
393 |
os.unlink( |
|
393 | os.unlink(self.join(patch)) | |
394 | i = self.find_series(patch) |
|
394 | i = self.find_series(patch) | |
395 | del self.full_series[i] |
|
395 | del self.full_series[i] | |
396 | self.parse_series() |
|
396 | self.parse_series() | |
@@ -409,7 +409,7 b' class queue:' | |||||
409 | if c or a or d or r: |
|
409 | if c or a or d or r: | |
410 | raise util.Abort(_("local changes found, refresh first")) |
|
410 | raise util.Abort(_("local changes found, refresh first")) | |
411 | def new(self, repo, patch, msg=None, force=None): |
|
411 | def new(self, repo, patch, msg=None, force=None): | |
412 |
if os.path.exists( |
|
412 | if os.path.exists(self.join(patch)): | |
413 | raise util.Abort(_('patch "%s" already exists') % patch) |
|
413 | raise util.Abort(_('patch "%s" already exists') % patch) | |
414 | commitfiles = [] |
|
414 | commitfiles = [] | |
415 | (c, a, r, d, u) = repo.changes(None, None) |
|
415 | (c, a, r, d, u) = repo.changes(None, None) | |
@@ -632,7 +632,7 b' class queue:' | |||||
632 | if res and res == patch: |
|
632 | if res and res == patch: | |
633 | return res |
|
633 | return res | |
634 |
|
634 | |||
635 |
if not os.path.isfile( |
|
635 | if not os.path.isfile(self.join(patch)): | |
636 | try: |
|
636 | try: | |
637 | sno = int(patch) |
|
637 | sno = int(patch) | |
638 | except(ValueError, OverflowError): |
|
638 | except(ValueError, OverflowError): | |
@@ -966,7 +966,7 b' class queue:' | |||||
966 | return True |
|
966 | return True | |
967 |
|
967 | |||
968 | def qrepo(self, create=False): |
|
968 | def qrepo(self, create=False): | |
969 |
if create or os.path.isdir( |
|
969 | if create or os.path.isdir(self.join(".hg")): | |
970 | return hg.repository(self.ui, path=self.path, create=create) |
|
970 | return hg.repository(self.ui, path=self.path, create=create) | |
971 |
|
971 | |||
972 | def restore(self, repo, rev, delete=None, qupdate=None): |
|
972 | def restore(self, repo, rev, delete=None, qupdate=None): | |
@@ -1126,7 +1126,7 b' class queue:' | |||||
1126 | if existing: |
|
1126 | if existing: | |
1127 | if not patch: |
|
1127 | if not patch: | |
1128 | patch = filename |
|
1128 | patch = filename | |
1129 |
if not os.path.isfile( |
|
1129 | if not os.path.isfile(self.join(patch)): | |
1130 | raise util.Abort(_("patch %s does not exist") % patch) |
|
1130 | raise util.Abort(_("patch %s does not exist") % patch) | |
1131 | else: |
|
1131 | else: | |
1132 | try: |
|
1132 | try: | |
@@ -1135,7 +1135,7 b' class queue:' | |||||
1135 | raise util.Abort(_("unable to read %s") % patch) |
|
1135 | raise util.Abort(_("unable to read %s") % patch) | |
1136 | if not patch: |
|
1136 | if not patch: | |
1137 | patch = os.path.split(filename)[1] |
|
1137 | patch = os.path.split(filename)[1] | |
1138 |
if not force and os.path.exists( |
|
1138 | if not force and os.path.exists(self.join(patch)): | |
1139 | raise util.Abort(_('patch "%s" already exists') % patch) |
|
1139 | raise util.Abort(_('patch "%s" already exists') % patch) | |
1140 | patchf = self.opener(patch, "w") |
|
1140 | patchf = self.opener(patch, "w") | |
1141 | patchf.write(text) |
|
1141 | patchf.write(text) | |
@@ -1350,7 +1350,7 b' def fold(ui, repo, *files, **opts):' | |||||
1350 | for patch in patches: |
|
1350 | for patch in patches: | |
1351 | if not message: |
|
1351 | if not message: | |
1352 | messages.append(q.readheaders(patch)[0]) |
|
1352 | messages.append(q.readheaders(patch)[0]) | |
1353 |
pf = |
|
1353 | pf = q.join(patch) | |
1354 | (patchsuccess, files, fuzz) = q.patch(repo, pf) |
|
1354 | (patchsuccess, files, fuzz) = q.patch(repo, pf) | |
1355 | if not patchsuccess: |
|
1355 | if not patchsuccess: | |
1356 | raise util.Abort(_('Error folding patch %s') % patch) |
|
1356 | raise util.Abort(_('Error folding patch %s') % patch) | |
@@ -1461,7 +1461,7 b' def rename(ui, repo, patch, name=None, *' | |||||
1461 | if name in q.series: |
|
1461 | if name in q.series: | |
1462 | raise util.Abort(_('A patch named %s already exists in the series file') % name) |
|
1462 | raise util.Abort(_('A patch named %s already exists in the series file') % name) | |
1463 |
|
1463 | |||
1464 |
absdest = |
|
1464 | absdest = q.join(name) | |
1465 | if os.path.exists(absdest): |
|
1465 | if os.path.exists(absdest): | |
1466 | raise util.Abort(_('%s already exists') % absdest) |
|
1466 | raise util.Abort(_('%s already exists') % absdest) | |
1467 |
|
1467 | |||
@@ -1485,7 +1485,7 b' def rename(ui, repo, patch, name=None, *' | |||||
1485 | q.applied[info[0]] = statusentry(info[1], name) |
|
1485 | q.applied[info[0]] = statusentry(info[1], name) | |
1486 | q.applied_dirty = 1 |
|
1486 | q.applied_dirty = 1 | |
1487 |
|
1487 | |||
1488 |
util.rename( |
|
1488 | util.rename(q.join(patch), absdest) | |
1489 | r = q.qrepo() |
|
1489 | r = q.qrepo() | |
1490 | if r: |
|
1490 | if r: | |
1491 | wlock = r.wlock() |
|
1491 | wlock = r.wlock() | |
@@ -1530,7 +1530,7 b' def save(ui, repo, **opts):' | |||||
1530 | util.copyfiles(path, newpath) |
|
1530 | util.copyfiles(path, newpath) | |
1531 | if opts['empty']: |
|
1531 | if opts['empty']: | |
1532 | try: |
|
1532 | try: | |
1533 |
os.unlink( |
|
1533 | os.unlink(q.join(q.status_path)) | |
1534 | except: |
|
1534 | except: | |
1535 | pass |
|
1535 | pass | |
1536 | return 0 |
|
1536 | return 0 |
General Comments 0
You need to be logged in to leave comments.
Login now