changeset 15895:933b9ff73750

merge with stable
author Matt Mackall <mpm@selenic.com>
date Sun, 15 Jan 2012 18:00:01 -0600
parents 44fa047cef57 (current diff) a3e2b9a1f063 (diff)
children 30c34fde40cc
files mercurial/context.py tests/test-keyword.t
diffstat 4 files changed, 48 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bugzilla.py	Wed Jan 11 15:53:42 2012 -0500
+++ b/hgext/bugzilla.py	Sun Jan 15 18:00:01 2012 -0600
@@ -255,7 +255,7 @@
 from mercurial.i18n import _
 from mercurial.node import short
 from mercurial import cmdutil, mail, templater, util
-import re, time, xmlrpclib
+import re, time, urlparse, xmlrpclib
 
 class bzaccess(object):
     '''Base class for access to Bugzilla.'''
@@ -473,17 +473,16 @@
 
 # Buzgilla via XMLRPC interface.
 
-class CookieSafeTransport(xmlrpclib.SafeTransport):
-    """A SafeTransport that retains cookies over its lifetime.
+class cookietransportrequest(object):
+    """A Transport request method that retains cookies over its lifetime.
 
     The regular xmlrpclib transports ignore cookies. Which causes
     a bit of a problem when you need a cookie-based login, as with
     the Bugzilla XMLRPC interface.
 
-    So this is a SafeTransport which looks for cookies being set
-    in responses and saves them to add to all future requests.
-    It appears a SafeTransport can do both HTTP and HTTPS sessions,
-    which saves us having to do a CookieTransport too.
+    So this is a helper for defining a Transport which looks for
+    cookies being set in responses and saves them to add to all future
+    requests.
     """
 
     # Inspiration drawn from
@@ -537,6 +536,18 @@
 
         return unmarshaller.close()
 
+# The explicit calls to the underlying xmlrpclib __init__() methods are
+# necessary. The xmlrpclib.Transport classes are old-style classes, and
+# it turns out their __init__() doesn't get called when doing multiple
+# inheritance with a new-style class.
+class cookietransport(cookietransportrequest, xmlrpclib.Transport):
+    def __init__(self, use_datetime=0):
+        xmlrpclib.Transport.__init__(self, use_datetime)
+
+class cookiesafetransport(cookietransportrequest, xmlrpclib.SafeTransport):
+    def __init__(self, use_datetime=0):
+        xmlrpclib.SafeTransport.__init__(self, use_datetime)
+
 class bzxmlrpc(bzaccess):
     """Support for access to Bugzilla via the Bugzilla XMLRPC API.
 
@@ -553,9 +564,15 @@
         user = self.ui.config('bugzilla', 'user', 'bugs')
         passwd = self.ui.config('bugzilla', 'password')
 
-        self.bzproxy = xmlrpclib.ServerProxy(bzweb, CookieSafeTransport())
+        self.bzproxy = xmlrpclib.ServerProxy(bzweb, self.transport(bzweb))
         self.bzproxy.User.login(dict(login=user, password=passwd))
 
+    def transport(self, uri):
+        if urlparse.urlparse(uri, "http")[0] == "https":
+            return cookiesafetransport()
+        else:
+            return cookietransport()
+
     def get_bug_comments(self, id):
         """Return a string with all comment text for a bug."""
         c = self.bzproxy.Bug.comments(dict(ids=[id]))
--- a/hgext/keyword.py	Wed Jan 11 15:53:42 2012 -0500
+++ b/hgext/keyword.py	Sun Jan 15 18:00:01 2012 -0600
@@ -680,7 +680,8 @@
         # not make sense
         if (fctx._filerev is None and
             (self._repo._encodefilterpats or
-             kwt.match(fctx.path()) and not 'l' in fctx.flags()) or
+             kwt.match(fctx.path()) and not 'l' in fctx.flags() or
+             self.size() - 4 == fctx.size()) or
             self.size() == fctx.size()):
             return self._filelog.cmp(self._filenode, fctx.data())
         return True
--- a/mercurial/context.py	Wed Jan 11 15:53:42 2012 -0500
+++ b/mercurial/context.py	Sun Jan 15 18:00:01 2012 -0600
@@ -388,7 +388,7 @@
         if (fctx._filerev is None
             and (self._repo._encodefilterpats
                  # if file data starts with '\1\n', empty metadata block is
-                 # prepended, which adds 4 bytes to fielog.size().
+                 # prepended, which adds 4 bytes to filelog.size().
                  or self.size() - 4 == fctx.size())
             or self.size() == fctx.size()):
             return self._filelog.cmp(self._filenode, fctx.data())
--- a/tests/test-keyword.t	Wed Jan 11 15:53:42 2012 -0500
+++ b/tests/test-keyword.t	Sun Jan 15 18:00:01 2012 -0600
@@ -162,13 +162,31 @@
   ignore $Id$
   a
 
-Test hook execution
-
   $ diff a hooktest
 
   $ cp $HGRCPATH.nohooks $HGRCPATH
   $ rm hooktest
 
+hg status of kw-ignored binary file starting with '\1\n'
+
+  $ printf '\1\nfoo' > i
+  $ hg -q commit -Am metasep i
+  $ hg status
+  $ printf '\1\nbar' > i
+  $ hg status
+  M i
+  $ hg -q commit -m "modify metasep" i
+  $ hg status --rev 2:3
+  M i
+  $ touch empty
+  $ hg -q commit -A -m "another file"
+  $ hg status -A --rev 3:4 i
+  C i
+
+  $ hg -q strip -n 2
+
+Test hook execution
+
 bundle
 
   $ hg bundle --base null ../kw.hg