Bug Report: hg {copy, rename, mv} with ".." to an empty directory fails with obscure error
Matt Mackall
mpm at selenic.com
Mon Oct 8 10:07:41 CDT 2007
On Sun, Oct 07, 2007 at 11:29:13AM -0700, Mike Neuman wrote:
> I made a one line change to canonpath which seems to fix the problem,
> but introduce a new one:
>
> *** /usr/local/lib/python2.4/site-packages/mercurial/util.py Mon Jun
> 25 19:18:18 2007
> --- util.py Sun Oct 7 11:24:01 2007
> ***************
> *** 366,371 ****
> --- 366,372 ----
> if not os.path.isabs(name):
> name = os.path.join(root, cwd, name)
> name = os.path.normpath(name)
> + name = os.path.realpath(name)
Good spotting!
Hmmm, that means someone else is using realpath. We should probably be
only using one or the other project-wide.
$ hgrep normpath | wc
20 82 1273
$ hgrep realpath | wc
5 22 355
Normpath is preferred as it's just a string op. But we can get into
trouble when someone goes through a symlink. We can probably be clever
and use realpath only as a fallback but it will take some care.
> Now the problem is the directory you're in gets blown away right from
> under you. Semantically, this makes sense, but it's pretty confusing to
> the user:
>
> % pwd
> /usr/home/mcn/devel/mercurial-0.9.4/test-rep
> % hg init .
> % mkdir dir1 dir2
> % touch dir1/file1
> % hg add dir1/file1
> % hg commit -m test
> % cd dir1
> % hg mv file1 ../dir2
> % pwd
> pwd: .: No such file or directory
> % cd ..
> /home
That's a feature.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list