[PATCH] import: report directory-relative paths in error messages (issue5224)

Piotr Listkiewicz piotr.listkiewicz at gmail.com
Fri Sep 2 03:15:16 EDT 2016


>
> That's a layering violation, and not every backend has a 'repo' (only repo
> backends do). Also I think you're overthinking it; just warn
> unconditionally and let the user sort it out.


You are right, i will send V2

2016-09-01 17:02 GMT+02:00 Kevin Bullock <kbullock+mercurial at ringworld.org>:

> > On Sep 1, 2016, at 09:18, liscju <piotr.listkiewicz at gmail.com> wrote:
> >
> > # HG changeset patch
> > # User liscju <piotr.listkiewicz at gmail.com>
> > # Date 1472208500 -7200
> > #      Fri Aug 26 12:48:20 2016 +0200
> > # Node ID 6437b071045756ba8b76c90ece76df83afc52989
> > # Parent  b1809f5d7630a3fff0fa715bbd30dba0f07672a8
> > import: report directory-relative paths in error messages (issue5224)
> >
> > Import uses paths relative to the root of the repository, so when
> > user imports patch with paths relative to the current working directory
> > import aborts with 'unable to find file for patching'.
> >
> > This patch improves this situation by warning the user that paths are
> > relative to the root of repository when the path exists from
> > current working directory.
> >
> > diff --git a/mercurial/patch.py b/mercurial/patch.py
> > --- a/mercurial/patch.py
> > +++ b/mercurial/patch.py
> > @@ -669,6 +669,11 @@ class patchfile(object):
> >                 self.mode = (False, False)
> >         if self.missing:
> >             self.ui.warn(_("unable to find '%s' for patching\n") %
> self.fname)
> > +            wvfs = backend.repo.wvfs
>
> That's a layering violation, and not every backend has a 'repo' (only repo
> backends do). Also I think you're overthinking it; just warn
> unconditionally and let the user sort it out.
>
> > +            if wvfs.exists(wvfs.reljoin(backend.repo.getcwd(),
> self.fname)):
> > +                self.ui.warn(_("Note that paths are relative to the
> root "
> > +                               "of repository, use --prefix option to "
> > +                               "change it\n"))
>
> pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
> Kevin R. Bullock
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160902/51d5198f/attachment.html>


More information about the Mercurial-devel mailing list