<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">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.</span></blockquote><div><br></div><div>You are right, i will send V2 </div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-01 17:02 GMT+02:00 Kevin Bullock <span dir="ltr"><<a href="mailto:kbullock+mercurial@ringworld.org" target="_blank">kbullock+mercurial@ringworld.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Sep 1, 2016, at 09:18, liscju <<a href="mailto:piotr.listkiewicz@gmail.com">piotr.listkiewicz@gmail.com</a>> wrote:<br>
><br>
> # HG changeset patch<br>
> # User liscju <<a href="mailto:piotr.listkiewicz@gmail.com">piotr.listkiewicz@gmail.com</a>><br>
> # Date 1472208500 -7200<br>
> #      Fri Aug 26 12:48:20 2016 +0200<br>
> # Node ID 6437b071045756ba8b76c90ece76df<wbr>83afc52989<br>
> # Parent  b1809f5d7630a3fff0fa715bbd30db<wbr>a0f07672a8<br>
> import: report directory-relative paths in error messages (issue5224)<br>
><br>
> Import uses paths relative to the root of the repository, so when<br>
> user imports patch with paths relative to the current working directory<br>
> import aborts with 'unable to find file for patching'.<br>
><br>
> This patch improves this situation by warning the user that paths are<br>
> relative to the root of repository when the path exists from<br>
> current working directory.<br>
><br>
> diff --git a/mercurial/patch.py b/mercurial/patch.py<br>
> --- a/mercurial/patch.py<br>
> +++ b/mercurial/patch.py<br>
> @@ -669,6 +669,11 @@ class patchfile(object):<br>
>                 self.mode = (False, False)<br>
>         if self.missing:<br>
>             self.ui.warn(_("unable to find '%s' for patching\n") % self.fname)<br>
> +            wvfs = backend.repo.wvfs<br>
<br>
</span>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.<br>
<span class=""><br>
> +            if wvfs.exists(wvfs.reljoin(<wbr>backend.repo.getcwd(), self.fname)):<br>
> +                self.ui.warn(_("Note that paths are relative to the root "<br>
> +                               "of repository, use --prefix option to "<br>
> +                               "change it\n"))<br>
<br>
</span>pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和<br>
Kevin R. Bullock<br>
<br>
</blockquote></div><br></div>