changeset 5123:79373ec3f27d

merge with crew-stable
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 06 Aug 2007 01:00:10 -0300
parents 487659a90497 (current diff) 167c422c745f (diff)
children a2c11f49e989
files mercurial/dirstate.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/httprepo.py tests/test-rebuildstate tests/test-rebuildstate.out
diffstat 7 files changed, 94 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Sun Aug 05 12:09:55 2007 -0700
+++ b/mercurial/dirstate.py	Mon Aug 06 01:00:10 2007 -0300
@@ -250,8 +250,14 @@
         except KeyError:
             self._ui.warn(_("not in dirstate: %s!\n") % f)
 
+    def clear(self):
+        self._map = {}
+        self._copymap = {}
+        self._pl = [nullid, nullid]
+        self._dirty = True
+
     def rebuild(self, parent, files):
-        self.invalidate()
+        self.clear()
         for f in files:
             if files.execf(f):
                 self._map[f] = ('n', 0777, -1, 0)
--- a/mercurial/hgweb/hgweb_mod.py	Sun Aug 05 12:09:55 2007 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Mon Aug 06 01:00:10 2007 -0300
@@ -488,7 +488,7 @@
                     continue
 
                 yield {"parity": parity.next(),
-                       "path": os.path.join(abspath, f),
+                       "path": "%s%s" % (abspath, f),
                        "basename": f[:-1]}
 
         yield self.t("manifest",
--- a/mercurial/hgweb/hgwebdir_mod.py	Sun Aug 05 12:09:55 2007 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Mon Aug 06 01:00:10 2007 -0300
@@ -17,7 +17,8 @@
 class hgwebdir(object):
     def __init__(self, config, parentui=None):
         def cleannames(items):
-            return [(name.strip(os.sep), path) for name, path in items]
+            return [(util.pconvert(name.strip(os.sep)), path)
+                    for name, path in items]
 
         self.parentui = parentui
         self.motd = None
--- a/mercurial/httprepo.py	Sun Aug 05 12:09:55 2007 -0700
+++ b/mercurial/httprepo.py	Mon Aug 06 01:00:10 2007 -0300
@@ -144,6 +144,43 @@
         raise IOError(None, _('connection ended unexpectedly'))
     yield zd.flush()
 
+_safe = ('abcdefghijklmnopqrstuvwxyz'
+         'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+         '0123456789' '_.-/')
+_safeset = None
+_hex = None
+def quotepath(path):
+    '''quote the path part of a URL
+
+    This is similar to urllib.quote, but it also tries to avoid
+    quoting things twice (inspired by wget):
+
+    >>> quotepath('abc def')
+    'abc%20def'
+    >>> quotepath('abc%20def')
+    'abc%20def'
+    >>> quotepath('abc%20 def')
+    'abc%20%20def'
+    >>> quotepath('abc def%20')
+    'abc%20def%20'
+    >>> quotepath('abc def%2')
+    'abc%20def%252'
+    >>> quotepath('abc def%')
+    'abc%20def%25'
+    '''
+    global _safeset, _hex
+    if _safeset is None:
+        _safeset = util.set(_safe)
+        _hex = util.set('abcdefABCDEF0123456789')
+    l = list(path)
+    for i in xrange(len(l)):
+        c = l[i]
+        if c == '%' and i + 2 < len(l) and (l[i+1] in _hex and l[i+2] in _hex):
+            pass
+        elif c not in _safeset:
+            l[i] = '%%%02X' % ord(c)
+    return ''.join(l)
+
 class httprepository(remoterepository):
     def __init__(self, ui, path):
         self.path = path
@@ -153,13 +190,16 @@
         if query or frag:
             raise util.Abort(_('unsupported URL component: "%s"') %
                              (query or frag))
-        if not urlpath: urlpath = '/'
+        if not urlpath:
+            urlpath = '/'
+        urlpath = quotepath(urlpath)
         host, port, user, passwd = netlocsplit(netloc)
 
         # urllib cannot handle URLs with embedded user or passwd
         self._url = urlparse.urlunsplit((scheme, netlocunsplit(host, port),
                                          urlpath, '', ''))
         self.ui = ui
+        self.ui.debug(_('using %s\n') % self._url)
 
         proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
         # XXX proxyauthinfo = None
--- a/tests/test-doctest.py	Sun Aug 05 12:09:55 2007 -0700
+++ b/tests/test-doctest.py	Mon Aug 06 01:00:10 2007 -0300
@@ -5,3 +5,5 @@
 
 doctest.testmod(mercurial.changelog)
 
+import mercurial.httprepo
+doctest.testmod(mercurial.httprepo)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-rebuildstate	Mon Aug 06 01:00:10 2007 -0300
@@ -0,0 +1,24 @@
+#!/bin/sh
+# basic test for hg debugrebuildstate
+
+hg init repo
+cd repo
+
+touch foo bar
+hg ci -Am 'add foo bar'
+
+touch baz
+hg add baz
+hg rm bar
+
+echo '% state dump'
+hg debugstate | cut -b 1-16,35- | sort
+echo '% status'
+hg st -A
+
+hg debugrebuildstate
+echo '% state dump'
+hg debugstate | cut -b 1-16,35- | sort
+echo '% status'
+hg st -A
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-rebuildstate.out	Mon Aug 06 01:00:10 2007 -0300
@@ -0,0 +1,17 @@
+adding bar
+adding foo
+% state dump
+a   0         -1 baz
+n 644          0 foo
+r   0          0 bar
+% status
+A baz
+R bar
+C foo
+% state dump
+n 666         -1 bar
+n 666         -1 foo
+% status
+! bar
+? baz
+C foo