Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 30078:173bdb502503
import: abort instead of crashing when copy source does not exist (issue5375)
Previously, when a patch contained a move or copy from a source that did not
exist, `hg import` would crash. This patch changes import to raise a PatchError
with an explanantion of what is wrong with the patch to avoid the stack trace
and bad user experience.
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Sat, 08 Oct 2016 05:26:58 -0700 |
parents | e40343ce9c4c |
children | 564b33acc21f |
comparison
equal
deleted
inserted
replaced
30077:8f42d8c412c8 | 30078:173bdb502503 |
---|---|
1950 backend.unlink(gp.path) | 1950 backend.unlink(gp.path) |
1951 continue | 1951 continue |
1952 data, mode = None, None | 1952 data, mode = None, None |
1953 if gp.op in ('RENAME', 'COPY'): | 1953 if gp.op in ('RENAME', 'COPY'): |
1954 data, mode = store.getfile(gp.oldpath)[:2] | 1954 data, mode = store.getfile(gp.oldpath)[:2] |
1955 # FIXME: failing getfile has never been handled here | 1955 if data is None: |
1956 assert data is not None | 1956 # This means that the old path does not exist |
1957 raise PatchError(_("source file '%s' does not exist") | |
1958 % gp.oldpath) | |
1957 if gp.mode: | 1959 if gp.mode: |
1958 mode = gp.mode | 1960 mode = gp.mode |
1959 if gp.op == 'ADD': | 1961 if gp.op == 'ADD': |
1960 # Added files without content have no hunk and | 1962 # Added files without content have no hunk and |
1961 # must be created | 1963 # must be created |