# HG changeset patch # User Yuya Nishihara # Date 2016-09-30 12:38:47 # Node ID 3f4e1c033f40aaa8111de9b8212f05e8e09590aa # Parent 02328b5d775d9d13cbd0d639f642e77d02232796 url: fix crash by empty path with #fragments Before, "#foo" paths made hg crash. We've moved the #fragment parsing at 64fbd0de9773, but we shouldn't set path to None too early. This patch just removes the "if not path:" block since that's checked a few lines later. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -2377,6 +2377,22 @@ class url(object): >>> url('http://host/a?b#c', parsequery=False, parsefragment=False) + + Empty path: + + >>> url('') + + >>> url('#a') + + >>> url('http://host/') + + >>> url('http://host/#a') + + + Only scheme: + + >>> url('http:') + """ _safechars = "!~*'()+" @@ -2393,8 +2409,6 @@ class url(object): if parsefragment and '#' in path: path, self.fragment = path.split('#', 1) - if not path: - path = None # special case for Windows drive letters and UNC paths if hasdriveletter(path) or path.startswith(r'\\'): diff --git a/tests/test-url-rev.t b/tests/test-url-rev.t --- a/tests/test-url-rev.t +++ b/tests/test-url-rev.t @@ -320,3 +320,12 @@ Test handling common incoming revisions remote: 1 outgoing $ cd .. + +Test url#rev syntax of local destination path, which should be taken as +a 'url#rev' path + + $ hg clone repo '#foo' + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg root -R '#foo' + $TESTTMP/#foo (glob)