Show More
@@ -1680,6 +1680,8 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1680 | 1680 | unless the -f option is used. The importer neither parses nor |
|
1681 | 1681 | discards mail headers, so use -f only to override the "mailness" |
|
1682 | 1682 | safety check, not to import a real mail message. |
|
1683 | ||
|
1684 | To read a patch from standard input, use patch name "-". | |
|
1683 | 1685 | """ |
|
1684 | 1686 | patches = (patch1,) + patches |
|
1685 | 1687 | |
@@ -1698,51 +1700,70 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1698 | 1700 | '(---|\*\*\*)[ \t])') |
|
1699 | 1701 | |
|
1700 | 1702 | for patch in patches: |
|
1701 | ui.status(_("applying %s\n") % patch) | |
|
1702 | 1703 | pf = os.path.join(d, patch) |
|
1703 | 1704 | |
|
1704 | 1705 | message = [] |
|
1705 | 1706 | user = None |
|
1706 | 1707 | date = None |
|
1707 | 1708 | hgpatch = False |
|
1708 | for line in file(pf): | |
|
1709 | line = line.rstrip() | |
|
1710 | if (not message and not hgpatch and | |
|
1711 | mailre.match(line) and not opts['force']): | |
|
1712 | if len(line) > 35: | |
|
1713 | line = line[:32] + '...' | |
|
1714 | raise util.Abort(_('first line looks like a ' | |
|
1715 | 'mail header: ') + line) | |
|
1716 | if diffre.match(line): | |
|
1717 | break | |
|
1718 | elif hgpatch: | |
|
1719 | # parse values when importing the result of an hg export | |
|
1720 |
|
|
|
1721 |
|
|
|
1722 | ui.debug(_('User: %s\n') % user) | |
|
1723 |
|
|
|
1724 | date = line[7:] | |
|
1725 | elif not line.startswith("# ") and line: | |
|
1709 | if pf == '-': | |
|
1710 | f = sys.stdin | |
|
1711 | fd, tmpname = tempfile.mkstemp(prefix='hg-patch-') | |
|
1712 | pf = tmpname | |
|
1713 | tmpfp = os.fdopen(fd, 'w') | |
|
1714 | ui.status(_("applying patch from stdin\n")) | |
|
1715 | else: | |
|
1716 | f = open(pf) | |
|
1717 | tmpfp, tmpname = None, None | |
|
1718 | ui.status(_("applying %s\n") % patch) | |
|
1719 | try: | |
|
1720 | while True: | |
|
1721 | line = f.readline() | |
|
1722 | if not line: break | |
|
1723 | if tmpfp: tmpfp.write(line) | |
|
1724 | line = line.rstrip() | |
|
1725 | if (not message and not hgpatch and | |
|
1726 | mailre.match(line) and not opts['force']): | |
|
1727 | if len(line) > 35: | |
|
1728 | line = line[:32] + '...' | |
|
1729 | raise util.Abort(_('first line looks like a ' | |
|
1730 | 'mail header: ') + line) | |
|
1731 | if diffre.match(line): | |
|
1732 | if tmpfp: | |
|
1733 | for chunk in util.filechunkiter(f): | |
|
1734 | tmpfp.write(chunk) | |
|
1735 | break | |
|
1736 | elif hgpatch: | |
|
1737 | # parse values when importing the result of an hg export | |
|
1738 | if line.startswith("# User "): | |
|
1739 | user = line[7:] | |
|
1740 | ui.debug(_('User: %s\n') % user) | |
|
1741 | elif line.startswith("# Date "): | |
|
1742 | date = line[7:] | |
|
1743 | elif not line.startswith("# ") and line: | |
|
1744 | message.append(line) | |
|
1745 | hgpatch = False | |
|
1746 | elif line == '# HG changeset patch': | |
|
1747 | hgpatch = True | |
|
1748 | message = [] # We may have collected garbage | |
|
1749 | elif message or line: | |
|
1726 | 1750 | message.append(line) |
|
1727 | hgpatch = False | |
|
1728 | elif line == '# HG changeset patch': | |
|
1729 | hgpatch = True | |
|
1730 | message = [] # We may have collected garbage | |
|
1731 |
el |
|
|
1732 |
message. |
|
|
1733 | ||
|
1734 | # make sure message isn't empty | |
|
1735 | if not message: | |
|
1736 | message = _("imported patch %s\n") % patch | |
|
1737 | else: | |
|
1738 | message = '\n'.join(message).rstrip() | |
|
1739 | ui.debug(_('message:\n%s\n') % message) | |
|
1740 | ||
|
1741 | files = util.patch(strip, pf, ui) | |
|
1742 | ||
|
1743 | if len(files) > 0: | |
|
1744 | addremove_lock(ui, repo, files, {}) | |
|
1745 | repo.commit(files, message, user, date) | |
|
1751 | ||
|
1752 | # make sure message isn't empty | |
|
1753 | if not message: | |
|
1754 | message = _("imported patch %s\n") % patch | |
|
1755 | else: | |
|
1756 | message = '\n'.join(message).rstrip() | |
|
1757 | ui.debug(_('message:\n%s\n') % message) | |
|
1758 | ||
|
1759 | if tmpfp: tmpfp.close() | |
|
1760 | files = util.patch(strip, pf, ui) | |
|
1761 | ||
|
1762 | if len(files) > 0: | |
|
1763 | addremove_lock(ui, repo, files, {}) | |
|
1764 | repo.commit(files, message, user, date) | |
|
1765 | finally: | |
|
1766 | if tmpname: os.unlink(tmpname) | |
|
1746 | 1767 | |
|
1747 | 1768 | def incoming(ui, repo, source="default", **opts): |
|
1748 | 1769 | """show new changesets found in source |
General Comments 0
You need to be logged in to leave comments.
Login now