[PATCH] pathutil: add doctests for canonpath()

Yuya Nishihara yuya at tcha.org
Sat Nov 4 22:40:20 EDT 2017


On Sat, 04 Nov 2017 22:23:32 -0400, Matt Harbison wrote:
> On Sat, 04 Nov 2017 22:11:21 -0400, Yuya Nishihara <yuya at tcha.org> wrote:
> > My concern is that the doctest is too limited in scope to cover possible  
> > bugs
> > caused by Windows drive letter. Maybe we could add a safer alternative to
> > os.path.relpath() and ban the use by check-code.
> 
> Seems like a good idea.  There are a few more uses of it, and I'm pretty  
> sure that at least cmdutil._conflictsmsg() is broke too, based on passing  
> repo.root and cwd.  (I guess thg doesn't use this function?)
> 
> I haven't been able to create the issue with the origpath code, and like I  
> said in the 'share --relative' patch, the error is useful there.  Is this  
> one of those things we can ban, but just record the few places it's needed  
> in test-check-code.t?

Perhaps os.path.relpath() can be replaced with two functions, which are:

 a) always return a relative path; raise Abort if not possible
 b) try to return a relative path only if possible; an absolute path otherwise

On Unix, they both are mapped to os.path.relpath.


More information about the Mercurial-devel mailing list