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