249 def __init__(self, ui, path, patchdir=None): |
249 def __init__(self, ui, path, patchdir=None): |
250 self.basepath = path |
250 self.basepath = path |
251 try: |
251 try: |
252 fh = open(os.path.join(path, 'patches.queue')) |
252 fh = open(os.path.join(path, 'patches.queue')) |
253 cur = fh.read().rstrip() |
253 cur = fh.read().rstrip() |
|
254 fh.close() |
254 if not cur: |
255 if not cur: |
255 curpath = os.path.join(path, 'patches') |
256 curpath = os.path.join(path, 'patches') |
256 else: |
257 else: |
257 curpath = os.path.join(path, 'patches-' + cur) |
258 curpath = os.path.join(path, 'patches-' + cur) |
258 except IOError: |
259 except IOError: |
1779 if not patchname: |
1780 if not patchname: |
1780 raise util.Abort( |
1781 raise util.Abort( |
1781 _('need --name to import a patch from -')) |
1782 _('need --name to import a patch from -')) |
1782 text = sys.stdin.read() |
1783 text = sys.stdin.read() |
1783 else: |
1784 else: |
1784 text = url.open(self.ui, filename).read() |
1785 fp = url.open(self.ui, filename) |
|
1786 text = fp.read() |
|
1787 fp.close() |
1785 except (OSError, IOError): |
1788 except (OSError, IOError): |
1786 raise util.Abort(_("unable to read file %s") % filename) |
1789 raise util.Abort(_("unable to read file %s") % filename) |
1787 if not patchname: |
1790 if not patchname: |
1788 patchname = normname(os.path.basename(filename)) |
1791 patchname = normname(os.path.basename(filename)) |
1789 self.check_reserved_name(patchname) |
1792 self.check_reserved_name(patchname) |
1790 checkfile(patchname) |
1793 checkfile(patchname) |
1791 patchf = self.opener(patchname, "w") |
1794 patchf = self.opener(patchname, "w") |
1792 patchf.write(text) |
1795 patchf.write(text) |
|
1796 patchf.close() |
1793 if not force: |
1797 if not force: |
1794 checkseries(patchname) |
1798 checkseries(patchname) |
1795 if patchname not in self.series: |
1799 if patchname not in self.series: |
1796 index = self.full_series_end() + i |
1800 index = self.full_series_end() + i |
1797 self.full_series[index:index] = [patchname] |
1801 self.full_series[index:index] = [patchname] |
2785 current = _getcurrent() |
2789 current = _getcurrent() |
2786 |
2790 |
2787 try: |
2791 try: |
2788 fh = repo.opener(_allqueues, 'r') |
2792 fh = repo.opener(_allqueues, 'r') |
2789 queues = [queue.strip() for queue in fh if queue.strip()] |
2793 queues = [queue.strip() for queue in fh if queue.strip()] |
|
2794 fh.close() |
2790 if current not in queues: |
2795 if current not in queues: |
2791 queues.append(current) |
2796 queues.append(current) |
2792 except IOError: |
2797 except IOError: |
2793 queues = [_defaultqueue] |
2798 queues = [_defaultqueue] |
2794 |
2799 |