Merge with crew-stable
authorPatrick Mezard <pmezard@gmail.com>
Sat, 13 Mar 2010 20:02:46 +0100
changeset 10676 13341047d517
parent 10671 001ffc2b3d22 (current diff)
parent 10675 3c05ecffe20d (diff)
child 10677 f2558a8228be
Merge with crew-stable
hgext/rebase.py
mercurial/hgweb/hgwebdir_mod.py
--- a/hgext/rebase.py	Sat Mar 13 19:57:52 2010 +0100
+++ b/hgext/rebase.py	Sat Mar 13 20:02:46 2010 +0100
@@ -440,11 +440,15 @@
         branch = repo[None].branch()
         dest = repo[branch].rev()
     else:
-        if 'qtip' in repo.tags() and (repo[dest].hex() in
-                                [s.rev for s in repo.mq.applied]):
-            raise util.Abort(_('cannot rebase onto an applied mq patch'))
         dest = repo[dest].rev()
 
+    # This check isn't strictly necessary, since mq detects commits over an
+    # applied patch. But it prevents messing up the working directory when
+    # a partially completed rebase is blocked by mq.
+    if 'qtip' in repo.tags() and (repo[dest].hex() in
+                            [s.rev for s in repo.mq.applied]):
+        raise util.Abort(_('cannot rebase onto an applied mq patch'))
+
     if src:
         commonbase = repo[src].ancestor(repo[dest])
         if commonbase == repo[src]:
--- a/mercurial/hgweb/hgwebdir_mod.py	Sat Mar 13 19:57:52 2010 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sat Mar 13 20:02:46 2010 +0100
@@ -6,7 +6,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import os, re, time
+import os, re, time, urlparse
 from mercurial.i18n import _
 from mercurial import ui, hg, util, templater
 from mercurial import error, encoding
@@ -226,9 +226,7 @@
                     parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
                 if req.env['SCRIPT_NAME']:
                     parts.insert(0, req.env['SCRIPT_NAME'])
-                m = re.match('((?:https?://)?)(.*)', '/'.join(parts))
-                # squish repeated slashes out of the path component
-                url = m.group(1) + re.sub('/+', '/', m.group(2)) + '/'
+                url = re.sub(r'/+', '/', '/'.join(parts) + '/')
 
                 # update time with local timezone
                 try:
@@ -281,8 +279,7 @@
                 for column in sortable]
 
         self.refresh()
-        if self._baseurl is not None:
-            req.env['SCRIPT_NAME'] = self._baseurl
+        self.updatereqenv(req.env)
 
         return tmpl("index", entries=entries, subdir=subdir,
                     sortcolumn=sortcolumn, descending=descending,
@@ -305,8 +302,7 @@
         def config(section, name, default=None, untrusted=True):
             return self.ui.config(section, name, default, untrusted)
 
-        if self._baseurl is not None:
-            req.env['SCRIPT_NAME'] = self._baseurl
+        self.updatereqenv(req.env)
 
         url = req.env.get('SCRIPT_NAME', '')
         if not url.endswith('/'):
@@ -336,3 +332,19 @@
                                              "staticurl": staticurl,
                                              "sessionvars": sessionvars})
         return tmpl
+
+    def updatereqenv(self, env):
+        def splitnetloc(netloc):
+            if ':' in netloc:
+                return netloc.split(':', 1)
+            else:
+                return (netloc, None)
+
+        if self._baseurl is not None:
+            urlcomp = urlparse.urlparse(self._baseurl)
+            host, port = splitnetloc(urlcomp[1])
+            path = urlcomp[2]
+            env['SERVER_NAME'] = host
+            if port:
+                env['SERVER_PORT'] = port
+            env['SCRIPT_NAME'] = path
--- a/tests/test-hgwebdir	Sat Mar 13 19:57:52 2010 +0100
+++ b/tests/test-hgwebdir	Sat Mar 13 20:02:46 2010 +0100
@@ -51,6 +51,13 @@
 echo % should give a 404 - repo is not published
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/c/file/tip/c?style=raw'
 
+echo % atom-log without basedir
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/a/atom-log' \
+    | grep '<link' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
+
+echo % rss-log without basedir
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/a/rss-log' \
+    | grep '<guid' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
 
 cat > paths.conf <<EOF
 [paths]
@@ -119,6 +126,28 @@
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/b/file/tip/b?style=raw'
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/c/file/tip/c?style=raw'
 
+echo % atom-log with basedir /
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/atom-log' \
+    | grep '<link' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
+
+echo % rss-log with basedir /
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/rss-log' \
+    | grep '<guid' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
+
+"$TESTDIR/killdaemons.py"
+
+hg serve --config web.baseurl=http://hg.example.com:8080/foo/ -p $HGPORT2 -d \
+    --pid-file=hg.pid --webdir-conf collections.conf \
+    -A access-collections-2.log -E error-collections-2.log
+cat hg.pid >> $DAEMON_PIDS
+
+echo % atom-log with basedir /foo/
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/atom-log' \
+    | grep '<link' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
+
+echo % rss-log with basedir /foo/
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/rss-log' \
+    | grep '<guid' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
 
 echo % paths errors 1
 cat error-paths-1.log
@@ -128,3 +157,5 @@
 cat error-paths-3.log
 echo % collections errors
 cat error-collections.log
+echo % collections errors 2
+cat error-collections-2.log
--- a/tests/test-hgwebdir.out	Sat Mar 13 19:57:52 2010 +0100
+++ b/tests/test-hgwebdir.out	Sat Mar 13 20:02:46 2010 +0100
@@ -25,6 +25,12 @@
 
 
 error: repository c not found
+% atom-log without basedir
+ <link rel="self" href="http://example.com:8080/a/atom-log"/>
+ <link rel="alternate" href="http://example.com:8080/a/"/>
+  <link href="http://example.com:8080/a/rev/8580ff50825a"/>
+% rss-log without basedir
+    <guid isPermaLink="true">http://example.com:8080/a/rev/8580ff50825a</guid>
 % should succeed, slashy names
 200 Script output follows
 
@@ -323,10 +329,10 @@
 200 Script output follows
 
 
-http://hg.example.com:8080/a/
-http://hg.example.com:8080/a/.hg/patches/
-http://hg.example.com:8080/b/
-http://hg.example.com:8080/c/
+/a/
+/a/.hg/patches/
+/b/
+/c/
 
 200 Script output follows
 
@@ -337,7 +343,20 @@
 200 Script output follows
 
 c
+% atom-log with basedir /
+ <link rel="self" href="http://example.com:8080/a/atom-log"/>
+ <link rel="alternate" href="http://example.com:8080/a/"/>
+  <link href="http://example.com:8080/a/rev/8580ff50825a"/>
+% rss-log with basedir /
+    <guid isPermaLink="true">http://example.com:8080/a/rev/8580ff50825a</guid>
+% atom-log with basedir /foo/
+ <link rel="self" href="http://example.com:8080/foo/a/atom-log"/>
+ <link rel="alternate" href="http://example.com:8080/foo/a/"/>
+  <link href="http://example.com:8080/foo/a/rev/8580ff50825a"/>
+% rss-log with basedir /foo/
+    <guid isPermaLink="true">http://example.com:8080/foo/a/rev/8580ff50825a</guid>
 % paths errors 1
 % paths errors 2
 % paths errors 3
 % collections errors
+% collections errors 2
--- a/tests/test-rebase-mq	Sat Mar 13 19:57:52 2010 +0100
+++ b/tests/test-rebase-mq	Sat Mar 13 20:02:46 2010 +0100
@@ -45,6 +45,12 @@
 hg rebase -s 1 -d 3
 
 echo
+echo '% Rebase - same thing, but mq patch is default dest'
+hg update -q 1
+hg rebase
+hg update -q qtip
+
+echo
 echo '% Rebase - generate a conflict'
 hg rebase -s 2 -d 1
 
--- a/tests/test-rebase-mq.out	Sat Mar 13 19:57:52 2010 +0100
+++ b/tests/test-rebase-mq.out	Sat Mar 13 20:02:46 2010 +0100
@@ -11,6 +11,9 @@
 % Rebase - try to rebase on an applied mq patch
 abort: cannot rebase onto an applied mq patch
 
+% Rebase - same thing, but mq patch is default dest
+abort: cannot rebase onto an applied mq patch
+
 % Rebase - generate a conflict
 merging f
 warning: conflicts during merge.