[PATCH 2 of 2] largefiles: hide .hglf/ prefix for largefiles in hgweb

Martin Geisler mg at lazybytes.net
Sun Apr 15 09:06:29 CDT 2012


# HG changeset patch
# User Martin Geisler <mg at lazybytes.net>
# Date 1334498757 -7200
# Node ID 35ab2f646bb8b9790b652c8390c63408c5a06541
# Parent  7eaa67554bb5c19a6ca00afb2556243fc548baf7
largefiles: hide .hglf/ prefix for largefiles in hgweb

This makes the manifest view in hgweb match what you see in the
working copy and what you get when you download an archive in hgweb.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -172,6 +172,11 @@
     finally:
         wlock.release()
 
+# For overriding mercurial.hgweb.webcommands so that largefiles will
+# appear at their right place in the manifests.
+def decodepath(orig, path):
+    return lfutil.splitstandin(path) or path
+
 # -- Wrappers: modify existing commands --------------------------------
 
 # Add works by going through the files that the user wanted to add and
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -11,7 +11,7 @@
 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \
     httprepo, localrepo, merge, sshrepo, sshserver, wireproto
 from mercurial.i18n import _
-from mercurial.hgweb import hgweb_mod, protocol
+from mercurial.hgweb import hgweb_mod, protocol, webcommands
 
 import overrides
 import proto
@@ -107,6 +107,8 @@
     hgweb_mod.perms['getlfile'] = 'pull'
     hgweb_mod.perms['statlfile'] = 'pull'
 
+    extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
+
     # the hello wireproto command uses wireproto.capabilities, so it won't see
     # our largefiles capability unless we replace the actual function as well.
     proto.capabilitiesorig = wireproto.capabilities
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -127,6 +127,29 @@
   $ cat sub/large4
   large22
 
+Test display of largefiles in hgweb
+
+  $ hg serve -d -p $HGPORT --pid-file ../hg.pid
+  $ cat ../hg.pid >> $DAEMON_PIDS
+  $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/file/tip/?style=raw'
+  200 Script output follows
+  
+  
+  drwxr-xr-x sub
+  -rw-r--r-- 41 large3
+  -rw-r--r-- 9 normal3
+  
+  
+  $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/file/tip/sub/?style=raw'
+  200 Script output follows
+  
+  
+  -rw-r--r-- 41 large4
+  -rw-r--r-- 9 normal4
+  
+  
+  $ "$TESTDIR/killdaemons.py"
+
 Test archiving the various revisions.  These hit corner cases known with
 archiving.
 


More information about the Mercurial-devel mailing list