changeset 9731:0e080d519d1b

hgweb: treat rev as raw-rev if user agent is hg
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 06 Nov 2009 22:46:46 +0100
parents 732fc0e9d411
children 092bcf431562
files mercurial/hgweb/hgweb_mod.py tests/test-hgweb-diffs tests/test-hgweb-diffs.out
diffstat 3 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Fri Nov 06 13:48:17 2009 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Fri Nov 06 22:46:46 2009 +0100
@@ -151,6 +151,10 @@
                 if args:
                     req.form['file'] = args
 
+            ua = req.env.get('HTTP_USER_AGENT', '')
+            if cmd == 'rev' and 'mercurial' in ua:
+                req.form['style'] = ['raw']
+
             if cmd == 'archive':
                 fn = req.form['node'][0]
                 for type_, spec in self.archive_specs.iteritems():
--- a/tests/test-hgweb-diffs	Fri Nov 06 13:48:17 2009 +0200
+++ b/tests/test-hgweb-diffs	Fri Nov 06 22:46:46 2009 +0100
@@ -38,5 +38,11 @@
 echo % diff removed file
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a'
 
+cd ..
+echo % test import rev as raw-rev
+hg clone -r0 test test1
+cd test1
+hg import --exact http://localhost:$HGPORT/rev/1
+
 echo % errors
-cat errors.log
+cat ../test/errors.log
--- a/tests/test-hgweb-diffs.out	Fri Nov 06 13:48:17 2009 +0200
+++ b/tests/test-hgweb-diffs.out	Fri Nov 06 22:46:46 2009 +0100
@@ -417,4 +417,13 @@
 </body>
 </html>
 
+% test import rev as raw-rev
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 2 changes to 2 files
+updating to branch default
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+applying http://localhost:20059/rev/1
 % errors