[PATCH] Allow "file://" as local path

Christian Ebert blacktrash at gmx.net
Fri Feb 22 17:37:32 CST 2008


This patch is in reference to 0d36de68669c, and more a reminder
that only allowing "localhost" is in a way still inconsistent.
Even this patch is a compromise as local hostnames are valid as
well. They could be obtained by something like:

import socket
def _localhostnames():
    hl = []
    for h in socket.gethostbyaddr(socket.gethostname()):
        if isinstance(h, str):
            h = [h]
        hl += h
    return hl

There already was a lengthy discussion about this at

Personally I'm fine without any of it ;)


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1203722692 -3600
# Node ID b1e2ca4c0f4606df7bc086adc3f75a26b5f8e62b
# Parent  f857eac30cd54fc2249c8044388718687df7bed5
Allow "file://" as local path

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -119,7 +119,8 @@
         ui.status(_("destination directory: %s\n") % dest)
     def localpath(path):
-        if path.startswith('file://localhost/'):
+        if (path.startswith('file://localhost/') or
+            path.startswith('file://')):
             return path[16:]
         if path.startswith('file://'):
             return path[7:]

More information about the Mercurial-devel mailing list