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

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


Hi,

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
<http://www.selenic.com/pipermail/mercurial-devel/2007-September/002837.html>
ff.

Personally I'm fine without any of it ;)

c



# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1203722692 -3600
# Node ID b1e2ca4c0f4606df7bc086adc3f75a26b5f8e62b
# Parent  f857eac30cd54fc2249c8044388718687df7bed5
Allow "file://127.0.0.1/" 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://127.0.0.1/')):
             return path[16:]
         if path.startswith('file://'):
             return path[7:]



More information about the Mercurial-devel mailing list