Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 13751:85d74f6babf6
patch: deprecate ui.patch / external patcher feature
Why?
- Mercurial internal patcher works correctly for regular patches and git
patches, is much faster at least on Windows and is more extensible.
- In theory, the external patcher can be used to handle exotic patch formats. I
do not know any and have not heard about any such use in years.
- Most patch programs cannot handle git format patches, which makes the API
caller to decide either to ignore ui.patch by calling patch.internalpatch()
directly, or take the risk of random failures with valid inputs.
- One thing a patch program could do Mercurial patcher cannot is applying with
--reverse. Apparently several shelve like extensions try to use that,
including passing the "reverse" option to Mercurial patcher, which has been
removed mid-2009. I never heard anybody complain about that, and would prefer
reimplementing it anyway.
And from the technical perspective:
- The external patcher makes everything harder to maintain and implement. EOL
normalization is not implemented, and I would bet file renames, if supported
by the patcher, are not correctly recorded in the dirstate.
- No tests.
How?
- Remove related documentation
- Clearly mark patch.externalpatch() as private
- Remove the debuginstall check. This deprecation request was actually
triggered by this last point. debuginstall is the only piece of code patching
without a repository. When migrating to an integrated patch() + updatedir()
call, this was really a showstopper, all workarounds were either ugly or
uselessly complicated to implement. If we do not support external patcher
anymore, the debuginstall check is not useful anymore.
- Remove patch.externalpatch() after 1.9 release.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 24 Mar 2011 10:28:29 +0100 |
parents | cede00420e1e |
children | 0f9282dc87f8 |
comparison
equal
deleted
inserted
replaced
13750:7eb82f88e157 | 13751:85d74f6babf6 |
---|---|
1556 templater.templater(templater.templatepath("map-cmdline.default")) | 1556 templater.templater(templater.templatepath("map-cmdline.default")) |
1557 except Exception, inst: | 1557 except Exception, inst: |
1558 ui.write(" %s\n" % inst) | 1558 ui.write(" %s\n" % inst) |
1559 ui.write(_(" (templates seem to have been installed incorrectly)\n")) | 1559 ui.write(_(" (templates seem to have been installed incorrectly)\n")) |
1560 problems += 1 | 1560 problems += 1 |
1561 | |
1562 # patch | |
1563 ui.status(_("Checking patch...\n")) | |
1564 patchproblems = 0 | |
1565 a = "1\n2\n3\n4\n" | |
1566 b = "1\n2\n3\ninsert\n4\n" | |
1567 fa = writetemp(a) | |
1568 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa), | |
1569 os.path.basename(fa)) | |
1570 fd = writetemp(d) | |
1571 | |
1572 files = {} | |
1573 try: | |
1574 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files) | |
1575 except util.Abort, e: | |
1576 ui.write(_(" patch call failed:\n")) | |
1577 ui.write(" " + str(e) + "\n") | |
1578 patchproblems += 1 | |
1579 else: | |
1580 if list(files) != [os.path.basename(fa)]: | |
1581 ui.write(_(" unexpected patch output!\n")) | |
1582 patchproblems += 1 | |
1583 a = open(fa).read() | |
1584 if a != b: | |
1585 ui.write(_(" patch test failed!\n")) | |
1586 patchproblems += 1 | |
1587 | |
1588 if patchproblems: | |
1589 if ui.config('ui', 'patch'): | |
1590 ui.write(_(" (Current patch tool may be incompatible with patch," | |
1591 " or misconfigured. Please check your configuration" | |
1592 " file)\n")) | |
1593 else: | |
1594 ui.write(_(" Internal patcher failure, please report this error" | |
1595 " to http://mercurial.selenic.com/wiki/BugTracker\n")) | |
1596 problems += patchproblems | |
1597 | |
1598 os.unlink(fa) | |
1599 os.unlink(fd) | |
1600 | 1561 |
1601 # editor | 1562 # editor |
1602 ui.status(_("Checking commit editor...\n")) | 1563 ui.status(_("Checking commit editor...\n")) |
1603 editor = ui.geteditor() | 1564 editor = ui.geteditor() |
1604 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) | 1565 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) |