Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 2861:0f08f2c042ec
Move patch-related code into its own module.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 11 Aug 2006 15:50:16 -0700 |
parents | b3d1145ed06c |
children | 1f813d4fbcc8 |
comparison
equal
deleted
inserted
replaced
2860:b3d1145ed06c | 2861:0f08f2c042ec |
---|---|
8 from demandload import demandload | 8 from demandload import demandload |
9 from node import * | 9 from node import * |
10 from i18n import gettext as _ | 10 from i18n import gettext as _ |
11 demandload(globals(), "os re sys signal shutil imp urllib pdb") | 11 demandload(globals(), "os re sys signal shutil imp urllib pdb") |
12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") | 12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") |
13 demandload(globals(), "fnmatch mdiff random signal tempfile time") | 13 demandload(globals(), "fnmatch mdiff patch random signal tempfile time") |
14 demandload(globals(), "traceback errno socket version struct atexit sets bz2") | 14 demandload(globals(), "traceback errno socket version struct atexit sets bz2") |
15 demandload(globals(), "archival cStringIO changegroup email.Parser") | 15 demandload(globals(), "archival cStringIO changegroup email.Parser") |
16 demandload(globals(), "hgweb.server sshserver") | 16 demandload(globals(), "hgweb.server sshserver") |
17 | 17 |
18 class UnknownCommand(Exception): | 18 class UnknownCommand(Exception): |
1824 | 1824 |
1825 wlock = repo.wlock() | 1825 wlock = repo.wlock() |
1826 lock = repo.lock() | 1826 lock = repo.lock() |
1827 | 1827 |
1828 wlock = repo.wlock() | 1828 wlock = repo.wlock() |
1829 for patch in patches: | 1829 for p in patches: |
1830 pf = os.path.join(d, patch) | 1830 pf = os.path.join(d, p) |
1831 | 1831 |
1832 message = None | 1832 message = None |
1833 user = None | 1833 user = None |
1834 date = None | 1834 date = None |
1835 hgpatch = False | 1835 hgpatch = False |
1836 | 1836 |
1837 p = email.Parser.Parser() | 1837 parser = email.Parser.Parser() |
1838 if pf == '-': | 1838 if pf == '-': |
1839 msg = p.parse(sys.stdin) | 1839 msg = parser.parse(sys.stdin) |
1840 ui.status(_("applying patch from stdin\n")) | 1840 ui.status(_("applying patch from stdin\n")) |
1841 else: | 1841 else: |
1842 msg = p.parse(file(pf)) | 1842 msg = parser.parse(file(pf)) |
1843 ui.status(_("applying %s\n") % patch) | 1843 ui.status(_("applying %s\n") % p) |
1844 | 1844 |
1845 fd, tmpname = tempfile.mkstemp(prefix='hg-patch-') | 1845 fd, tmpname = tempfile.mkstemp(prefix='hg-patch-') |
1846 tmpfp = os.fdopen(fd, 'w') | 1846 tmpfp = os.fdopen(fd, 'w') |
1847 try: | 1847 try: |
1848 message = msg['Subject'] | 1848 message = msg['Subject'] |
1906 | 1906 |
1907 tmpfp.close() | 1907 tmpfp.close() |
1908 if not diffs_seen: | 1908 if not diffs_seen: |
1909 raise util.Abort(_('no diffs found')) | 1909 raise util.Abort(_('no diffs found')) |
1910 | 1910 |
1911 files = util.patch(strip, tmpname, ui, cwd=repo.root) | 1911 files = patch.patch(strip, tmpname, ui, cwd=repo.root) |
1912 removes = [] | 1912 removes = [] |
1913 if len(files) > 0: | 1913 if len(files) > 0: |
1914 cfiles = files.keys() | 1914 cfiles = files.keys() |
1915 copies = [] | 1915 copies = [] |
1916 copts = {'after': False, 'force': False} | 1916 copts = {'after': False, 'force': False} |