Bug in util.py

Jun Inoue jun.lambda at gmail.com
Sun Oct 29 05:05:04 CST 2006


Hi, I came across a bug in util.py.  I have a repo whose absolute path
is /home/dvl/repo.  There's a symlink /dvl -> /home/dvl, and if I open
a file in the repo with emacs through the symlink, the hg-diff-repo
command fails.  Apparently, when mercurial tries to figure out if
/dvl/repo is the same thing as /home/dvl/repo, samestat() tests true
on the first loop so `rel' never gets updated and os.path.join () gets
an empty parameter list.


Sample of error output:

Traceback (most recent call last):
  File "/usr/bin/hg", line 12, in ?
    commands.run()
  File "/var/lib/python-support/python2.4/mercurial/commands.py", line 3266, in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/var/lib/python-support/python2.4/mercurial/commands.py", line 3465, in dispatch
    return d()
  File "/var/lib/python-support/python2.4/mercurial/commands.py", line 3424, in <lambda>
    d = lambda: func(u, repo, *args, **cmdoptions)
  File "/var/lib/python-support/python2.4/mercurial/commands.py", line 1414, in diff
    fns, matchfn, anypats = matchpats(repo, pats, opts)
  File "/var/lib/python-support/python2.4/mercurial/commands.py", line 50, in matchpats
    opts.get('exclude'), head)
  File "/var/lib/python-support/python2.4/mercurial/util.py", line 260, in cmdmatcher
    return _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src)
  File "/var/lib/python-support/python2.4/mercurial/util.py", line 347, in _matcher
    name = canonpath(canonroot, cwd, name)
  File "/var/lib/python-support/python2.4/mercurial/util.py", line 241, in canonpath
    name = os.path.join(*rel)
TypeError: join() takes at least 1 argument (0 given)


-------------- next part --------------
--- util.py	2006-10-28 23:08:48.056118221 -0700
+++ /var/lib/python-support/python2.4/mercurial/util.py	2006-10-29 03:00:22.596976864 -0800
@@ -237,6 +237,9 @@
             except OSError:
                 break
             if samestat(name_st, root_st):
+                if rel == []:
+                    # `name' was actually the same as `root'
+                    return ''
                 rel.reverse()
                 name = os.path.join(*rel)
                 audit_path(name)


More information about the Mercurial-devel mailing list