changeset 14015:39920ce75842

merge default heads
author Martin Geisler <mg@aragost.com>
date Tue, 26 Apr 2011 12:56:56 +0200
parents b69471bdb678 (diff) bcff4759d17d (current diff)
children bd738875943a
files
diffstat 5 files changed, 97 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Mon Apr 25 21:20:44 2011 +0200
+++ b/contrib/check-code.py	Tue Apr 26 12:56:56 2011 +0200
@@ -42,6 +42,7 @@
 
 
 testpats = [
+  [
     (r'(pushd|popd)', "don't use 'pushd' or 'popd', use 'cd'"),
     (r'\W\$?\(\([^\)]*\)\)', "don't use (()) or $(()), use 'expr'"),
     (r'^function', "don't use 'function', use old style"),
@@ -67,6 +68,9 @@
     (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
     (r'ls\s+[^|-]+\s+-', "options to 'ls' must come before filenames"),
     (r'[^>]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
+  ],
+  # warnings
+  []
 ]
 
 testfilters = [
@@ -77,6 +81,7 @@
 uprefix = r"^  \$ "
 uprefixc = r"^  > "
 utestpats = [
+  [
     (r'^(\S|  $ ).*(\S\s+|^\s+)\n', "trailing whitespace on non-output"),
     (uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"),
     (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
@@ -85,9 +90,12 @@
      "explicit exit code checks unnecessary"),
     (uprefix + r'set -e', "don't use set -e"),
     (uprefixc + r'( *)\t', "don't use tabs to indent"),
+  ],
+  # warnings
+  []
 ]
 
-for p, m in testpats:
+for p, m in testpats[0] + testpats[1]:
     if p.startswith('^'):
         p = uprefix + p[1:]
     else:
@@ -99,6 +107,7 @@
 ]
 
 pypats = [
+  [
     (r'^\s*def\s*\w+\s*\(.*,\s*\(',
      "tuple parameter unpacking not available in Python 3+"),
     (r'lambda\s*\(.*,.*\)',
@@ -112,7 +121,6 @@
     (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
     (r'^\s+\w+=\w+[^,)]$', "missing whitespace in assignment"),
     (r'.{85}', "line too long"),
-    (r'.{81}', "warning: line over 80 characters"),
     (r'[^\n]\Z', "no trailing newline"),
     (r'(\S\s+|^\s+)\n', "trailing whitespace"),
 #    (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"),
@@ -150,12 +158,17 @@
     (r'[^+=*!<>&| -](\s=|=\s)[^= ]',
      "wrong whitespace around ="),
     (r'raise Exception', "don't raise generic exceptions"),
+    (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
+    (r' [=!]=\s+(True|False|None)',
+     "comparison with singleton, use 'is' or 'is not' instead"),
+  ],
+  # warnings
+  [
+    (r'.{81}', "warning: line over 80 characters"),
     (r'^\s*except:$', "warning: naked except clause"),
     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
      "warning: unwrapped ui message"),
-    (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
-    (r' [=!]=\s+(True|False|None)',
-     "comparison with singleton, use 'is' or 'is not' instead"),
+  ]
 ]
 
 pyfilters = [
@@ -166,6 +179,7 @@
 ]
 
 cpats = [
+  [
     (r'//', "don't use //-style comments"),
     (r'^  ', "don't use spaces to indent"),
     (r'\S\t', "don't use tabs except for indent"),
@@ -182,6 +196,9 @@
     (r'^#\s+\w', "use #foo, not # foo"),
     (r'[^\n]\Z', "no trailing newline"),
     (r'^\s*#import\b', "use only #include in standard C code"),
+  ],
+  # warnings
+  []
 ]
 
 cfilters = [
@@ -258,14 +275,16 @@
             break
         for p, r in filters:
             post = re.sub(p, r, post)
+        if warnings:
+            pats = pats[0] + pats[1]
+        else:
+            pats = pats[0]
         # print post # uncomment to show filtered version
         z = enumerate(zip(pre.splitlines(), post.splitlines(True)))
         for n, l in z:
             if "check-code" + "-ignore" in l[0]:
                 continue
             for p, msg in pats:
-                if not warnings and msg.startswith("warning"):
-                    continue
                 if re.search(p, l[1]):
                     bd = ""
                     if blame:
--- a/hgext/mq.py	Mon Apr 25 21:20:44 2011 +0200
+++ b/hgext/mq.py	Tue Apr 26 12:56:56 2011 +0200
@@ -737,11 +737,29 @@
                     os.unlink(self.join(p))
 
         if numrevs:
+            qfinished = self.applied[:numrevs]
             del self.applied[:numrevs]
             self.applied_dirty = 1
 
-        for i in sorted([self.find_series(p) for p in patches], reverse=True):
-            del self.full_series[i]
+        unknown = []
+
+        for (i, p) in sorted([(self.find_series(p), p) for p in patches],
+                             reverse=True):
+            if i is not None:
+                del self.full_series[i]
+            else:
+                unknown.append(p)
+
+        if unknown:
+            if numrevs:
+                rev  = dict((entry.name, entry.node) for entry in qfinished)
+                for p in unknown:
+                    msg = _('revision %s refers to unknown patches: %s\n')
+                    self.ui.warn(msg % (short(rev[p]), p))
+            else:
+                msg = _('unknown patches: %s\n')
+                raise util.Abort(''.join(msg % p for p in unknown))
+
         self.parse_series()
         self.series_dirty = 1
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/notcapable	Tue Apr 26 12:56:56 2011 +0200
@@ -0,0 +1,19 @@
+# Disable the $CAP wire protocol capability.
+
+if test -z "$CAP"
+then
+    echo "CAP environment variable not set."
+fi
+
+cat > notcapable-$CAP.py << EOF
+from mercurial import extensions, repo
+def extsetup():
+    extensions.wrapfunction(repo.repository, 'capable', wrapper)
+def wrapper(orig, self, name, *args, **kwargs):
+    if name == '$CAP':
+        return False
+    return orig(self, name, *args, **kwargs)
+EOF
+
+echo '[extensions]' >> $HGRCPATH
+echo "notcapable-$CAP = `pwd`/notcapable-$CAP.py" >> $HGRCPATH
--- a/tests/test-mq-qdelete.t	Mon Apr 25 21:20:44 2011 +0200
+++ b/tests/test-mq-qdelete.t	Tue Apr 26 12:56:56 2011 +0200
@@ -162,3 +162,33 @@
   adding 3.diff to series file
   $ hg qfinish -a
   no patches applied
+
+
+resilience to inconsistency: qfinish -a with applied patches not in series
+
+  $ hg qser
+  3.diff
+  $ hg qapplied
+  $ hg qpush
+  applying 3.diff
+  patch 3.diff is empty
+  now at: 3.diff
+  $ echo next >>  base
+  $ hg qrefresh -d '1 0'
+  $ echo > .hg/patches/series # remove 3.diff from series to confuse mq
+  $ hg qfinish -a
+  revision c4dd2b624061 refers to unknown patches: 3.diff
+
+more complex state 'both known and unknown patches
+
+  $ echo hip >>  base
+  $ hg qnew -f -d '1 0' -m 4 4.diff
+  $ echo hop >>  base
+  $ hg qnew -f -d '1 0' -m 5 5.diff
+  $ echo > .hg/patches/series # remove 4.diff and 5.diff from series to confuse mq
+  $ echo hup >>  base
+  $ hg qnew -f -d '1 0' -m 6 6.diff
+  $ hg qfinish -a
+  revision 6fdec4b20ec3 refers to unknown patches: 5.diff
+  revision 2ba51db7ba24 refers to unknown patches: 4.diff
+
--- a/tests/test-push-http.t	Mon Apr 25 21:20:44 2011 +0200
+++ b/tests/test-push-http.t	Tue Apr 26 12:56:56 2011 +0200
@@ -68,17 +68,8 @@
 
 expect success, server lacks the unbundlehash capability
 
-  $ cat > unbundlehash-off.py << EOF
-  > from mercurial import extensions, repo
-  > def extsetup():
-  >     extensions.wrapfunction(repo.repository, 'capable', wrapper)
-  > def wrapper(orig, self, name, *args, **kwargs):
-  >     if name == 'unbundlehash':
-  >         return False
-  >     return orig(self, name, *args, **kwargs)
-  > EOF
-  $ echo '[extensions]' >> .hg/hgrc
-  $ echo "unbundlehash-off = `pwd`/unbundlehash-off.py" >> .hg/hgrc
+  $ CAP=unbundlehash
+  $ . "$TESTDIR/notcapable"
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes