Mercurial > hg
changeset 10297:e7727a545c48
Merge with i18n
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 28 Jan 2010 23:13:45 -0600 |
parents | cade47dcac2d (diff) caeb7163492e (current diff) |
children | e768941f14c1 35bcb3152e67 |
files | |
diffstat | 190 files changed, 2201 insertions(+), 1595 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/check-code.py Thu Jan 28 23:13:45 2010 -0600 @@ -0,0 +1,160 @@ +#!/usr/bin/env python +# +# check-code - a style and portability checker for Mercurial +# +# Copyright 2010 Matt Mackall <mpm@selenic.com> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +import sys, re, glob + +def repquote(m): + t = re.sub(r"\S", "x", m.group(2)) + return m.group(1) + t + m.group(1) + +def repcomment(m): + return m.group(1) + "#" * len(m.group(2)) + +def repccomment(m): + t = re.sub(r"((?<=\n) )|\S", "x", m.group(2)) + return m.group(1) + t + "*/" + +def repcallspaces(m): + t = re.sub(r"\n\s+", "\n", m.group(2)) + return m.group(1) + t + +def repinclude(m): + return m.group(1) + "<foo>" + +def rephere(m): + t = re.sub(r"\S", "x", m.group(2)) + return m.group(1) + t + + +testpats = [ + (r'(pushd|popd)', "don't use pushd|popd, use cd"), + (r'\W\$?\(\([^\)]*\)\)', "don't use (()) or $(()), use expr"), + (r'^function', "don't use 'function', use old style"), + (r'grep.*-q', "don't use grep -q, redirect to /dev/null"), + (r'echo.*\\n', "don't use 'echo \n', use printf"), + (r'^diff.*-\w*N', "don't use diff -N"), + (r'(^| )wc[^|]*$', "filter wc output"), + (r'head -c', "don't use head -c, use dd"), + (r'ls.*-\w*R', "don't use ls -R, use find"), + (r'printf.*\\\d\d\d', "don't use printf \NNN, use python"), + (r'printf.*\\x', "don't use printf \\x, use python"), + (r'\$\(.*\)', "don't use $(expr), use `expr`"), + (r'rm -rf \*', "don't use naked rm -rf, target a directory"), + (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w', + "use egrep for extended grep syntax"), + (r'/bin/', "don't use explicit paths for tools"), + (r'\$PWD', "don't use $PWD, use `pwd`"), + (r'[^\n]\Z', "no trailing newline"), +] + +testfilters = [ + (r"( *)(#([^\n]*\S)?)", repcomment), + (r"<<(\S+)((.|\n)*?\n\1)", rephere), +] + +pypats = [ + (r'^\s*\t', "don't use tabs"), + (r'(\S\s+|^\s+)\n', "trailing whitespace"), + (r'\w,\w', "missing whitespace after ,"), + (r'\w[+/*\-<>]\w', "missing whitespace in expression"), + (r'^\s+\w+=\w+[^,)]$', "missing whitespace in assignment"), + (r'.{85}', "line too long"), + (r'[^\n]\Z', "no trailing newline"), +# (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"), +# (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"), + (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+', + "linebreak after :"), + (r'class\s[^(]:', "old-style class, use class foo(object)"), + (r'^\s+del\(', "del isn't a function"), + (r'^\s+except\(', "except isn't a function"), +# (r'class\s[A-Z][^\(]*\((?!Exception)', +# "don't capitalize non-exception classes"), +# (r'in range\(', "use xrange"), +# (r'^\s*print\s+', "avoid using print in core and extensions"), + (r'[\x80-\xff]', "non-ASCII character literal"), + (r'("\')\.format\(', "str.format() not available in Python 2.4"), + (r'^\s*with\s+', "with not available in Python 2.4"), + (r'if\s.*\selse', "if ... else form not available in Python 2.4"), + (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"), +# (r'\s\s=', "gratuitous whitespace before ="), + (r'\S(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator") +] + +pyfilters = [ + (r"""(''')(([^']|\\'|'{1,2}(?!'))*)'''""", repquote), + (r'''(""")(([^"]|\\"|"{1,2}(?!"))*)"""''', repquote), + (r'''(?<!")(")(([^"\n]|\\")+)"(?!")''', repquote), + (r"""(?<!')(')(([^'\n]|\\')+)'(?!')""", repquote), + (r"( *)(#([^\n]*\S)?)", repcomment), +] + +cpats = [ + (r'//', "don't use //-style comments"), + (r'^ ', "don't use spaces to indent"), + (r'\S\t', "don't use tabs except for indent"), + (r'(\S\s+|^\s+)\n', "trailing whitespace"), + (r'.{85}', "line too long"), + (r'(while|if|do|for)\(', "use space after while/if/do/for"), + (r'return\(', "return is not a function"), + (r' ;', "no space before ;"), + (r'\w+\* \w+', "use int *foo, not int* foo"), + (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"), + (r'\S+ (\+\+|--)', "use foo++, not foo ++"), + (r'\w,\w', "missing whitespace after ,"), + (r'\w[+/*]\w', "missing whitespace in expression"), + (r'^#\s+\w', "use #foo, not # foo"), + (r'[^\n]\Z', "no trailing newline"), +] + +cfilters = [ + (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment), + (r'''(?<!")(")(([^"]|\\")+"(?!"))''', repquote), + (r'''(#\s*include\s+<)([^>]+)>''', repinclude), + (r'(\()([^)]+\))', repcallspaces), +] + +checks = [ + ('python', r'.*\.(py|cgi)$', pyfilters, pypats), + ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats), + ('c', r'.*\.c$', cfilters, cpats), +] + +if len(sys.argv) == 1: + check = glob.glob("*") +else: + check = sys.argv[1:] + +for f in check: + for name, match, filters, pats in checks: + fc = 0 + if not re.match(match, f): + continue + pre = post = open(f).read() + if "no-" + "check-code" in pre: + break + for p, r in filters: + post = re.sub(p, r, post) + # 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 + lc = 0 + for p, msg in pats: + if re.search(p, l[1]): + if not lc: + print "%s:%d:" % (f, n + 1) + print " > %s" % l[0] + print " %s" % msg + lc += 1 + fc += 1 + if fc == 15: + print " (too many errors, giving up)" + break + break
--- a/contrib/hg-ssh Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/hg-ssh Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,7 @@ # Thomas Arendsen Hein <thomas@intevation.de> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """ hg-ssh - a wrapper for ssh access to a limited set of mercurial repos
--- a/contrib/hgsh/hgsh.c Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/hgsh/hgsh.c Thu Jan 28 23:13:45 2010 -0600 @@ -89,7 +89,7 @@ */ #ifndef HG_SHELL #define HG_SHELL NULL -// #define HG_SHELL "/bin/bash" +/* #define HG_SHELL "/bin/bash" */ #endif /* @@ -118,40 +118,40 @@ static void print_cmdline(int argc, char **argv) { - FILE *fp = stderr; - int i; + FILE *fp = stderr; + int i; - fputs("command: ", fp); + fputs("command: ", fp); - for (i = 0; i < argc; i++) { - char *spc = strpbrk(argv[i], " \t\r\n"); - if (spc) { - fputc('\'', fp); - } - fputs(argv[i], fp); - if (spc) { - fputc('\'', fp); - } - if (i < argc - 1) { - fputc(' ', fp); - } - } - fputc('\n', fp); - fflush(fp); + for (i = 0; i < argc; i++) { + char *spc = strpbrk(argv[i], " \t\r\n"); + if (spc) { + fputc('\'', fp); + } + fputs(argv[i], fp); + if (spc) { + fputc('\'', fp); + } + if (i < argc - 1) { + fputc(' ', fp); + } + } + fputc('\n', fp); + fflush(fp); } static void usage(const char *reason, int exitcode) { - char *hg_help = HG_HELP; + char *hg_help = HG_HELP; - if (reason) { - fprintf(stderr, "*** Error: %s.\n", reason); - } - fprintf(stderr, "*** This program has been invoked incorrectly.\n"); - if (hg_help) { - fprintf(stderr, "*** %s\n", hg_help); - } - exit(exitcode ? exitcode : EX_USAGE); + if (reason) { + fprintf(stderr, "*** Error: %s.\n", reason); + } + fprintf(stderr, "*** This program has been invoked incorrectly.\n"); + if (hg_help) { + fprintf(stderr, "*** %s\n", hg_help); + } + exit(exitcode ? exitcode : EX_USAGE); } /* @@ -162,43 +162,43 @@ */ static void forward_through_gateway(int argc, char **argv) { - char *ssh = SSH; - char *hg_host = HG_HOST; - char *hg_user = HG_USER; - char **nargv = alloca((10 + argc) * sizeof(char *)); - int i = 0, j; + char *ssh = SSH; + char *hg_host = HG_HOST; + char *hg_user = HG_USER; + char **nargv = alloca((10 + argc) * sizeof(char *)); + int i = 0, j; - nargv[i++] = ssh; - nargv[i++] = "-q"; - nargv[i++] = "-T"; - nargv[i++] = "-x"; - if (hg_user) { - nargv[i++] = "-l"; - nargv[i++] = hg_user; - } - nargv[i++] = hg_host; + nargv[i++] = ssh; + nargv[i++] = "-q"; + nargv[i++] = "-T"; + nargv[i++] = "-x"; + if (hg_user) { + nargv[i++] = "-l"; + nargv[i++] = hg_user; + } + nargv[i++] = hg_host; - /* - * sshd called us with added "-c", because it thinks we are a shell. - * drop it if we find it. - */ - j = 1; - if (j < argc && strcmp(argv[j], "-c") == 0) { - j++; - } + /* + * sshd called us with added "-c", because it thinks we are a shell. + * drop it if we find it. + */ + j = 1; + if (j < argc && strcmp(argv[j], "-c") == 0) { + j++; + } - for (; j < argc; i++, j++) { - nargv[i] = argv[j]; - } - nargv[i] = NULL; + for (; j < argc; i++, j++) { + nargv[i] = argv[j]; + } + nargv[i] = NULL; - if (debug) { - print_cmdline(i, nargv); - } + if (debug) { + print_cmdline(i, nargv); + } - execv(ssh, nargv); - perror(ssh); - exit(EX_UNAVAILABLE); + execv(ssh, nargv); + perror(ssh); + exit(EX_UNAVAILABLE); } /* @@ -209,44 +209,44 @@ */ static void run_shell(int argc, char **argv) { - char *hg_shell = HG_SHELL; - char **nargv; - char *c; - int i; + char *hg_shell = HG_SHELL; + char **nargv; + char *c; + int i; - nargv = alloca((argc + 3) * sizeof(char *)); - c = strrchr(hg_shell, '/'); + nargv = alloca((argc + 3) * sizeof(char *)); + c = strrchr(hg_shell, '/'); - /* tell "real" shell it is login shell, if needed. */ + /* tell "real" shell it is login shell, if needed. */ - if (argv[0][0] == '-' && c) { - nargv[0] = strdup(c); - if (nargv[0] == NULL) { - perror("malloc"); - exit(EX_OSERR); - } - nargv[0][0] = '-'; - } else { - nargv[0] = hg_shell; - } + if (argv[0][0] == '-' && c) { + nargv[0] = strdup(c); + if (nargv[0] == NULL) { + perror("malloc"); + exit(EX_OSERR); + } + nargv[0][0] = '-'; + } else { + nargv[0] = hg_shell; + } - for (i = 1; i < argc; i++) { - nargv[i] = argv[i]; - } - nargv[i] = NULL; + for (i = 1; i < argc; i++) { + nargv[i] = argv[i]; + } + nargv[i] = NULL; - if (debug) { - print_cmdline(i, nargv); - } + if (debug) { + print_cmdline(i, nargv); + } - execv(hg_shell, nargv); - perror(hg_shell); - exit(EX_OSFILE); + execv(hg_shell, nargv); + perror(hg_shell); + exit(EX_OSFILE); } enum cmdline { - hg_init, - hg_serve, + hg_init, + hg_serve, }; @@ -256,25 +256,25 @@ */ static int validate_repo(const char *repo_root, const char *subdir) { - char *abs_path; - struct stat st; - int ret; + char *abs_path; + struct stat st; + int ret; - if (asprintf(&abs_path, "%s.hg/%s", repo_root, subdir) == -1) { - ret = -1; - goto bail; - } + if (asprintf(&abs_path, "%s.hg/%s", repo_root, subdir) == -1) { + ret = -1; + goto bail; + } - /* verify that we really are looking at valid repo. */ + /* verify that we really are looking at valid repo. */ - if (stat(abs_path, &st) == -1) { - ret = 0; - } else { - ret = 1; - } + if (stat(abs_path, &st) == -1) { + ret = 0; + } else { + ret = 1; + } bail: - return ret; + return ret; } /* @@ -282,158 +282,159 @@ */ static void serve_data(int argc, char **argv) { - char *hg_root = HG_ROOT; - char *repo, *repo_root; - enum cmdline cmd; - char *nargv[6]; - size_t repolen; - int i; - - /* - * check argv for looking okay. we should be invoked with argv - * resembling like this: - * - * hgsh - * -c - * hg -R some/path serve --stdio - * - * the "-c" is added by sshd, because it thinks we are login shell. - */ + char *hg_root = HG_ROOT; + char *repo, *repo_root; + enum cmdline cmd; + char *nargv[6]; + size_t repolen; + int i; - if (argc != 3) { - goto badargs; - } - - if (strcmp(argv[1], "-c") != 0) { - goto badargs; - } - - if (sscanf(argv[2], "hg init %as", &repo) == 1) { - cmd = hg_init; - } - else if (sscanf(argv[2], "hg -R %as serve --stdio", &repo) == 1) { - cmd = hg_serve; - } else { - goto badargs; - } - - repolen = repo ? strlen(repo) : 0; + /* + * check argv for looking okay. we should be invoked with argv + * resembling like this: + * + * hgsh + * -c + * hg -R some/path serve --stdio + * + * the "-c" is added by sshd, because it thinks we are login shell. + */ - if (repolen == 0) { - goto badargs; - } - - if (hg_root) { - if (asprintf(&repo_root, "%s/%s/", hg_root, repo) == -1) { - goto badargs; - } + if (argc != 3) { + goto badargs; + } - /* - * attempt to stop break out from inside the repository tree. could - * do something more clever here, because e.g. we could traverse a - * symlink that looks safe, but really breaks us out of tree. - */ - - if (strstr(repo_root, "/../") != NULL) { - goto badargs; - } - - /* only hg init expects no repo. */ + if (strcmp(argv[1], "-c") != 0) { + goto badargs; + } - if (cmd != hg_init) { - int valid; - - valid = validate_repo(repo_root, "data"); - - if (valid == -1) { + if (sscanf(argv[2], "hg init %as", &repo) == 1) { + cmd = hg_init; + } + else if (sscanf(argv[2], "hg -R %as serve --stdio", &repo) == 1) { + cmd = hg_serve; + } else { goto badargs; - } + } - if (valid == 0) { - valid = validate_repo(repo_root, "store"); + repolen = repo ? strlen(repo) : 0; - if (valid == -1) { - goto badargs; - } - } - - if (valid == 0) { - perror(repo); - exit(EX_DATAERR); - } + if (repolen == 0) { + goto badargs; } - if (chdir(hg_root) == -1) { - perror(hg_root); - exit(EX_SOFTWARE); - } - } + if (hg_root) { + if (asprintf(&repo_root, "%s/%s/", hg_root, repo) == -1) { + goto badargs; + } + + /* + * attempt to stop break out from inside the + * repository tree. could do something more clever + * here, because e.g. we could traverse a symlink that + * looks safe, but really breaks us out of tree. + */ + + if (strstr(repo_root, "/../") != NULL) { + goto badargs; + } - i = 0; + /* only hg init expects no repo. */ + + if (cmd != hg_init) { + int valid; + + valid = validate_repo(repo_root, "data"); + + if (valid == -1) { + goto badargs; + } + + if (valid == 0) { + valid = validate_repo(repo_root, "store"); + + if (valid == -1) { + goto badargs; + } + } - switch (cmd) { - case hg_serve: - nargv[i++] = HG; - nargv[i++] = "-R"; - nargv[i++] = repo; - nargv[i++] = "serve"; - nargv[i++] = "--stdio"; - break; - case hg_init: - nargv[i++] = HG; - nargv[i++] = "init"; - nargv[i++] = repo; - break; - } + if (valid == 0) { + perror(repo); + exit(EX_DATAERR); + } + } + + if (chdir(hg_root) == -1) { + perror(hg_root); + exit(EX_SOFTWARE); + } + } + + i = 0; - nargv[i] = NULL; + switch (cmd) { + case hg_serve: + nargv[i++] = HG; + nargv[i++] = "-R"; + nargv[i++] = repo; + nargv[i++] = "serve"; + nargv[i++] = "--stdio"; + break; + case hg_init: + nargv[i++] = HG; + nargv[i++] = "init"; + nargv[i++] = repo; + break; + } - if (debug) { - print_cmdline(i, nargv); - } + nargv[i] = NULL; - execv(HG, nargv); - perror(HG); - exit(EX_UNAVAILABLE); + if (debug) { + print_cmdline(i, nargv); + } + + execv(HG, nargv); + perror(HG); + exit(EX_UNAVAILABLE); badargs: - /* print useless error message. */ + /* print useless error message. */ - usage("invalid arguments", EX_DATAERR); + usage("invalid arguments", EX_DATAERR); } int main(int argc, char **argv) { - char host[1024]; - char *c; + char host[1024]; + char *c; - if (gethostname(host, sizeof(host)) == -1) { - perror("gethostname"); - exit(EX_OSERR); - } + if (gethostname(host, sizeof(host)) == -1) { + perror("gethostname"); + exit(EX_OSERR); + } - if ((c = strchr(host, '.')) != NULL) { - *c = '\0'; - } + if ((c = strchr(host, '.')) != NULL) { + *c = '\0'; + } - if (getenv("SSH_CLIENT")) { - char *hg_gateway = HG_GATEWAY; - char *hg_host = HG_HOST; + if (getenv("SSH_CLIENT")) { + char *hg_gateway = HG_GATEWAY; + char *hg_host = HG_HOST; - if (hg_gateway && strcmp(host, hg_gateway) == 0) { - forward_through_gateway(argc, argv); - } + if (hg_gateway && strcmp(host, hg_gateway) == 0) { + forward_through_gateway(argc, argv); + } - if (hg_host && strcmp(host, hg_host) != 0) { - usage("invoked on unexpected host", EX_USAGE); - } + if (hg_host && strcmp(host, hg_host) != 0) { + usage("invoked on unexpected host", EX_USAGE); + } - serve_data(argc, argv); - } else if (HG_SHELL) { - run_shell(argc, argv); - } else { - usage("invalid arguments", EX_DATAERR); - } + serve_data(argc, argv); + } else if (HG_SHELL) { + run_shell(argc, argv); + } else { + usage("invalid arguments", EX_DATAERR); + } - return 0; + return 0; }
--- a/contrib/memory.py Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/memory.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''helper extension to measure memory usage @@ -29,7 +29,7 @@ finally: if status is not None: status.close() - ui.write_err(", ".join(["%s: %.1f MiB" % (key, value/1024.0) + ui.write_err(", ".join(["%s: %.1f MiB" % (key, value / 1024.0) for key, value in result.iteritems()]) + "\n") def extsetup(ui):
--- a/contrib/mercurial.el Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/mercurial.el Thu Jan 28 23:13:45 2010 -0600 @@ -5,8 +5,8 @@ ;; Author: Bryan O'Sullivan <bos@serpentine.com> ;; mercurial.el is free software; you can redistribute it and/or -;; modify it under the terms of version 2 of the GNU General Public -;; License as published by the Free Software Foundation. +;; modify it under the terms of the GNU General Public License version +;; 2 or any later version. ;; mercurial.el is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of @@ -784,7 +784,7 @@ (defun hg-help-overview () "This is an overview of the Mercurial SCM mode for Emacs. -You can find the source code, license (GPL v2), and credits for this +You can find the source code, license (GPLv2+), and credits for this code by typing `M-x find-library mercurial RET'." (interactive) (hg-view-output ("Mercurial Help Overview")
--- a/contrib/mercurial.spec Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/mercurial.spec Thu Jan 28 23:13:45 2010 -0600 @@ -2,7 +2,7 @@ Name: mercurial Version: snapshot Release: 0 -License: GPLv2 +License: GPLv2+ Group: Development/Tools URL: http://mercurial.selenic.com/ Source0: http://mercurial.selenic.com/release/%{name}-%{version}.tar.gz
--- a/contrib/mq.el Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/mq.el Thu Jan 28 23:13:45 2010 -0600 @@ -5,8 +5,8 @@ ;; Author: Bryan O'Sullivan <bos@serpentine.com> ;; mq.el is free software; you can redistribute it and/or modify it -;; under the terms of version 2 of the GNU General Public License as -;; published by the Free Software Foundation. +;; under the terms of the GNU General Public License version 2 or any +;; later version. ;; mq.el is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of
--- a/contrib/perf.py Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/perf.py Thu Jan 28 23:13:45 2010 -0600 @@ -36,7 +36,7 @@ except: try: m = cmdutil.match(repo, pats, {}) - timer(lambda: len([b for a,b,c in repo.dirstate.statwalk([], m)])) + timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)])) except: timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
--- a/contrib/shrink-revlog.py Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/shrink-revlog.py Thu Jan 28 23:13:45 2010 -0600 @@ -101,9 +101,9 @@ # argh: have to pass an int to %d, because a float >= 2^32 # blows up under Python 2.5 or earlier ui.write('old file size: %12d bytes (%6.1f MiB)\n' - % (int(oldsize), oldsize/1024/1024)) + % (int(oldsize), oldsize / 1024 / 1024)) ui.write('new file size: %12d bytes (%6.1f MiB)\n' - % (int(newsize), newsize/1024/1024)) + % (int(newsize), newsize / 1024 / 1024)) shrink_percent = (oldsize - newsize) / oldsize * 100 shrink_factor = oldsize / newsize @@ -219,4 +219,4 @@ } if __name__ == "__main__": - print "shrink-revlog.py is now an extension (see hg help extensions)" + print "shrink-revlog.py is now an extension (see hg help extensions)"
--- a/contrib/win32/ReadMe.html Mon Jan 18 19:57:36 2010 +0100 +++ b/contrib/win32/ReadMe.html Thu Jan 28 23:13:45 2010 -0600 @@ -148,8 +148,7 @@ Mercurial is free software; you can redistribute it and/or modify it under the terms of the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GNU - General Public License version 2</a> as published by the Free - Software Foundation. + General Public License version 2</a> or any later version. </p> <p>
--- a/doc/gendoc.py Mon Jan 18 19:57:36 2010 +0100 +++ b/doc/gendoc.py Thu Jan 28 23:13:45 2010 -0600 @@ -19,7 +19,7 @@ i = docstr.find("\n") if i != -1: - desc = docstr[i+2:] + desc = docstr[i + 2:] else: desc = " %s" % shortdesc return (shortdesc, desc) @@ -76,7 +76,8 @@ cmds.sort() for f in cmds: - if f.startswith("debug"): continue + if f.startswith("debug"): + continue d = get_cmd(h[f]) # synopsis ui.write(".. _%s:\n\n" % d['cmd'])
--- a/doc/hg.1.txt Mon Jan 18 19:57:36 2010 +0100 +++ b/doc/hg.1.txt Thu Jan 28 23:13:45 2010 -0600 @@ -95,6 +95,6 @@ ------- Copyright (C) 2005-2010 Matt Mackall. Free use of this software is granted under the terms of the GNU General -Public License version 2. +Public License version 2 or any later version. .. include:: common.txt
--- a/doc/hgignore.5.txt Mon Jan 18 19:57:36 2010 +0100 +++ b/doc/hgignore.5.txt Thu Jan 28 23:13:45 2010 -0600 @@ -106,6 +106,6 @@ This manual page is copyright 2006 Vadim Gelfer. Mercurial is copyright 2005-2010 Matt Mackall. Free use of this software is granted under the terms of the GNU General -Public License version 2. +Public License version 2 or any later version. .. include:: common.txt
--- a/doc/hgrc.5.txt Mon Jan 18 19:57:36 2010 +0100 +++ b/doc/hgrc.5.txt Thu Jan 28 23:13:45 2010 -0600 @@ -305,7 +305,7 @@ email addresses. ``bcc`` Optional. Comma-separated list of blind carbon copy recipients' - email addresses. Cannot be set interactively. + email addresses. ``method`` Optional. Method to use to send email messages. If value is ``smtp`` (default), use SMTP (see the SMTP_ section for configuration). @@ -955,6 +955,6 @@ This manual page is copyright 2005 Bryan O'Sullivan. Mercurial is copyright 2005-2010 Matt Mackall. Free use of this software is granted under the terms of the GNU General -Public License version 2. +Public License version 2 or any later version. .. include:: common.txt
--- a/doc/rst2man.py Mon Jan 18 19:57:36 2010 +0100 +++ b/doc/rst2man.py Thu Jan 28 23:13:45 2010 -0600 @@ -112,7 +112,7 @@ class Table: def __init__(self): self._rows = [] - self._options = ['center', ] + self._options = ['center',] self._tab_char = '\t' self._coldefs = [] def new_row(self): @@ -123,7 +123,7 @@ def append_cell(self, cell_lines): """cell_lines is an array of lines""" start = 0 - if len(cell_lines)>0 and cell_lines[0] == '.sp\n': + if len(cell_lines) > 0 and cell_lines[0] == '.sp\n': start = 1 self._rows[-1].append(cell_lines[start:]) if len(self._coldefs) < len(self._rows[-1]): @@ -223,8 +223,8 @@ 'term' : ('\n.B ', '\n'), 'title_reference' : ('\\fI', '\\fP'), - 'topic-title' : ('.SS ', ), - 'sidebar-title' : ('.SS ', ), + 'topic-title' : ('.SS ',), + 'sidebar-title' : ('.SS ',), 'problematic' : ('\n.nf\n', '\n.fi\n'), } @@ -255,18 +255,18 @@ # ensure we get a ".TH" as viewers require it. self.head.append(self.header()) # filter body - for i in xrange(len(self.body)-1,0,-1): + for i in xrange(len(self.body)-1, 0, -1): # remove superfluous vertical gaps. if self.body[i] == '.sp\n': - if self.body[i-1][:4] in ('.BI ','.IP '): + if self.body[i - 1][:4] in ('.BI ','.IP '): self.body[i] = '.\n' - elif (self.body[i-1][:3] == '.B ' and - self.body[i-2][:4] == '.TP\n'): + elif (self.body[i - 1][:3] == '.B ' and + self.body[i - 2][:4] == '.TP\n'): self.body[i] = '.\n' - elif (self.body[i-1] == '\n' and - self.body[i-2][0] != '.' and - (self.body[i-3][:7] == '.TP\n.B ' - or self.body[i-3][:4] == '\n.B ') + elif (self.body[i - 1] == '\n' and + self.body[i - 2][0] != '.' and + (self.body[i - 3][:7] == '.TP\n.B ' + or self.body[i - 3][:4] == '\n.B ') ): self.body[i] = '.\n' return ''.join(self.head + self.body + self.foot) @@ -451,7 +451,7 @@ depart_caution = depart_admonition def visit_citation(self, node): - num,text = node.astext().split(None,1) + num, text = node.astext().split(None, 1) num = num.strip() self.body.append('.IP [%s] 5\n' % num) @@ -578,19 +578,18 @@ self.defs['indent'][0] % BLOCKQOUTE_INDENT, self._docinfo[name], self.defs['indent'][1], - self.defs['indent'][1], - ) ) + self.defs['indent'][1])) elif not name in skip: if name in self._docinfo_names: label = self._docinfo_names[name] else: label = self.language.labels.get(name, name) - self.body.append("\n%s: %s\n" % (label, self._docinfo[name]) ) + self.body.append("\n%s: %s\n" % (label, self._docinfo[name])) if self._docinfo['copyright']: self.body.append('.SH COPYRIGHT\n%s\n' % self._docinfo['copyright']) - self.body.append( self.comment( - 'Generated by docutils manpage writer.\n' ) ) + self.body.append(self.comment( + 'Generated by docutils manpage writer.\n')) def visit_emphasis(self, node): self.body.append(self.defs['emphasis'][0]) @@ -672,7 +671,7 @@ pass def visit_footnote(self, node): - num,text = node.astext().split(None,1) + num, text = node.astext().split(None, 1) num = num.strip() self.body.append('.IP [%s] 5\n' % self.deunicode(num)) @@ -786,7 +785,7 @@ # man 7 man argues to use ".IP" instead of ".TP" self.body.append('.IP %s %d\n' % ( self._list_char[-1].next(), - self._list_char[-1].get_width(),) ) + self._list_char[-1].get_width(),)) def depart_list_item(self, node): pass @@ -858,7 +857,7 @@ def visit_option(self, node): # each form of the option will be presented separately - if self.context[-1]>0: + if self.context[-1] > 0: self.body.append(', ') if self.context[-3] == '.BI': self.body.append('\\') @@ -877,7 +876,7 @@ def visit_option_argument(self, node): self.context[-3] = '.BI' # bold/italic alternate if node['delimiter'] != ' ': - self.body.append('\\fB%s ' % node['delimiter'] ) + self.body.append('\\fB%s ' % node['delimiter']) elif self.body[len(self.body)-1].endswith('='): # a blank only means no blank in output, just changing font self.body.append(' ')
--- a/hg Mon Jan 18 19:57:36 2010 +0100 +++ b/hg Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # enable importing on demand to reduce startup time try:
--- a/hgext/acl.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/acl.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,8 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. -# +# GNU General Public License version 2 or any later version. '''hooks for controlling repository access
--- a/hgext/bookmarks.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/bookmarks.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008 David Soria Parra <dsp@php.net> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''track a line of development with movable markers
--- a/hgext/bugzilla.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/bugzilla.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''hooks for integrating with the Bugzilla bug tracker @@ -145,7 +145,7 @@ from mercurial import cmdutil, templater, util import re, time -MySQLdb = None +mysqldb = None def buglist(ids): return '(' + ','.join(map(str, ids)) + ')' @@ -165,7 +165,7 @@ self.ui.readconfig(usermap, sections=['usermap']) self.ui.note(_('connecting to %s:%s as %s, password %s\n') % (host, db, user, '*' * len(passwd))) - self.conn = MySQLdb.connect(host=host, user=user, passwd=passwd, + self.conn = mysqldb.connect(host=host, user=user, passwd=passwd, db=db, connect_timeout=timeout) self.cursor = self.conn.cursor() self.longdesc_id = self.get_longdesc_id() @@ -177,7 +177,7 @@ self.ui.note(_('query: %s %s\n') % (args, kwargs)) try: self.cursor.execute(*args, **kwargs) - except MySQLdb.MySQLError: + except mysqldb.MySQLError: self.ui.note(_('failed query: %s %s\n') % (args, kwargs)) raise @@ -297,7 +297,8 @@ def __init__(self, ui): bugzilla_2_16.__init__(self, ui) - self.default_notify = "cd %(bzdir)s && perl -T contrib/sendbugmail.pl %(id)s %(user)s" + self.default_notify = \ + "cd %(bzdir)s && perl -T contrib/sendbugmail.pl %(id)s %(user)s" class bugzilla_3_0(bugzilla_2_18): '''support for bugzilla 3.0 series.''' @@ -369,7 +370,8 @@ break start = m.end() for id in bugzilla._split_re.split(m.group(1)): - if not id: continue + if not id: + continue ids.add(int(id)) if ids: ids = self.filter_real_bug_ids(ids) @@ -389,7 +391,7 @@ c = root.find('/') if c == -1: break - root = root[c+1:] + root = root[c + 1:] count -= 1 return root @@ -417,9 +419,9 @@ bugzilla bug id. only add a comment once per bug, so same change seen multiple times does not fill bug with duplicate data.''' try: - import MySQLdb as mysql - global MySQLdb - MySQLdb = mysql + import mysqldb as mysql + global mysqldb + mysqldb = mysql except ImportError, err: raise util.Abort(_('python mysql support not available: %s') % err) @@ -434,6 +436,6 @@ for id in ids: bz.update(id, ctx) bz.notify(ids, util.email(ctx.user())) - except MySQLdb.MySQLError, err: + except mysqldb.MySQLError, err: raise util.Abort(_('database error: %s') % err[1])
--- a/hgext/children.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/children.py Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,7 @@ # Thomas Arendsen Hein <thomas@intevation.de> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to display child changesets'''
--- a/hgext/churn.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/churn.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2008 Alexander Solovyov <piranha@piranha.org.ua> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to display statistics about repository history''' @@ -169,7 +169,7 @@ '*' * charnum(sum(count))) def charnum(count): - return int(round(count*width/maxcount)) + return int(round(count * width / maxcount)) for name, count in rate: ui.write(format(name, count)) @@ -180,7 +180,8 @@ (churn, [('r', 'rev', [], _('count rate for the specified revision or range')), ('d', 'date', '', _('count rate for revisions matching date spec')), - ('t', 'template', '{author|email}', _('template to group changesets')), + ('t', 'template', '{author|email}', + _('template to group changesets')), ('f', 'dateformat', '', _('strftime-compatible format for grouping by date')), ('c', 'changesets', False, _('count rate by number of changesets')),
--- a/hgext/color.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/color.py Thu Jan 28 23:13:45 2010 -0600 @@ -190,8 +190,8 @@ if opts['missing']: effects = _patch_effects['missing'] # Determine if patch is applied. - elif [ applied for applied in repo.mq.applied - if patchname == applied.name ]: + elif [applied for applied in repo.mq.applied + if patchname == applied.name]: effects = _patch_effects['applied'] else: effects = _patch_effects['unapplied']
--- a/hgext/convert/__init__.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/__init__.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''import revisions from foreign VCS repositories into Mercurial''' @@ -279,7 +279,8 @@ # Main options shared with cvsps-2.1 ('b', 'branches', [], _('only return changes on specified branches')), ('p', 'prefix', '', _('prefix to remove from file names')), - ('r', 'revisions', [], _('only return changes after or between specified tags')), + ('r', 'revisions', [], + _('only return changes after or between specified tags')), ('u', 'update-cache', None, _("update cvs log cache")), ('x', 'new-cache', None, _("create new cvs log cache")), ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
--- a/hgext/convert/bzr.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/bzr.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008, 2009 Marek Kubica <marek@xivilization.net> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # This module is for handling 'bzr', that was formerly known as Bazaar-NG; # it cannot access 'bar' repositories, but they were never used very much @@ -203,7 +203,8 @@ changes.append((frompath, revid)) changes.append((topath, revid)) # add to mode cache - mode = ((entry.executable and 'x') or (entry.kind == 'symlink' and 's') + mode = ((entry.executable and 'x') + or (entry.kind == 'symlink' and 's') or '') self._modecache[(topath, revid)] = mode # register the change as move
--- a/hgext/convert/common.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/common.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import base64, errno import os @@ -24,7 +24,8 @@ s = base64.decodestring(s) return pickle.loads(s) -class MissingTool(Exception): pass +class MissingTool(Exception): + pass def checktool(exe, name=None, abort=True): name = name or exe @@ -32,7 +33,8 @@ exc = abort and util.Abort or MissingTool raise exc(_('cannot find required "%s" tool') % name) -class NoRepo(Exception): pass +class NoRepo(Exception): + pass SKIPREV = 'SKIP' @@ -322,7 +324,7 @@ # Since ARG_MAX is for command line _and_ environment, lower our limit # (and make happy Windows shells while doing this). - self._argmax = self._argmax/2 - 1 + self._argmax = self._argmax / 2 - 1 return self._argmax def limit_arglist(self, arglist, cmd, *args, **kwargs): @@ -367,8 +369,9 @@ try: key, value = line.splitlines()[0].rsplit(' ', 1) except ValueError: - raise util.Abort(_('syntax error in %s(%d): key/value pair expected') - % (self.path, i+1)) + raise util.Abort( + _('syntax error in %s(%d): key/value pair expected') + % (self.path, i + 1)) if key not in self: self.order.append(key) super(mapfile, self).__setitem__(key, value)
--- a/hgext/convert/convcmd.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/convcmd.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from common import NoRepo, MissingTool, SKIPREV, mapfile from cvs import convert_cvs @@ -108,7 +108,8 @@ parents = {} while visit: n = visit.pop(0) - if n in known or n in self.map: continue + if n in known or n in self.map: + continue known.add(n) commit = self.cachecommit(n) parents[n] = []
--- a/hgext/convert/cvs.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/cvs.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os, locale, re, socket, errno from cStringIO import StringIO @@ -46,7 +46,8 @@ # patchset number? maxrev = int(self.rev) except ValueError: - raise util.Abort(_('revision %s is not a patchset number') % self.rev) + raise util.Abort(_('revision %s is not a patchset number') + % self.rev) d = os.getcwd() try: @@ -65,7 +66,7 @@ mergefrom=self.ui.config('convert', 'cvsps.mergefrom', None)) for cs in db: - if maxrev and cs.id>maxrev: + if maxrev and cs.id > maxrev: break id = str(cs.id) cs.author = self.recode(cs.author) @@ -76,7 +77,8 @@ files = {} for f in cs.entries: - files[f.file] = "%s%s" % ('.'.join([str(x) for x in f.revision]), + files[f.file] = "%s%s" % ('.'.join([str(x) + for x in f.revision]), ['', '(DEAD)'][f.dead]) # add current commit to set @@ -186,8 +188,8 @@ self.writep.flush() r = self.readp.readline() if not r.startswith("Valid-requests"): - raise util.Abort(_("unexpected response from CVS server " - "(expected \"Valid-requests\", but got %r)") + raise util.Abort(_('unexpected response from CVS server ' + '(expected "Valid-requests", but got %r)') % r) if "UseUnchanged" in r: self.writep.write("UseUnchanged\n") @@ -208,7 +210,8 @@ while count > 0: data = fp.read(min(count, chunksize)) if not data: - raise util.Abort(_("%d bytes missing from remote file") % count) + raise util.Abort(_("%d bytes missing from remote file") + % count) count -= len(data) output.write(data) return output.getvalue()
--- a/hgext/convert/cvsps.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/cvsps.py Thu Jan 28 23:13:45 2010 -0600 @@ -1,10 +1,9 @@ -# # Mercurial built-in replacement for cvsps. # # Copyright 2008, Frank Kingswood <frank@kingswood-consulting.co.uk> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os import re @@ -403,7 +402,7 @@ # normal branch if revparts[:-2] == e.revision: branchpoints.add(branch) - elif revparts == (1,1,1): # vendor branch + elif revparts == (1, 1, 1): # vendor branch if revparts in e.branches: branchpoints.add(branch) e.branchpoints = branchpoints @@ -633,7 +632,7 @@ branches = {} # changeset index where we saw a branch n = len(changesets) i = 0 - while i<n: + while i < n: c = changesets[i] for f in c.entries: @@ -703,9 +702,12 @@ m = None # if no group found then merge to HEAD if m in branches and c.branch != m: # insert empty changeset for merge - cc = changeset(author=c.author, branch=m, date=c.date, - comment='convert-repo: CVS merge from branch %s' % c.branch, - entries=[], tags=[], parents=[changesets[branches[m]], c]) + cc = changeset( + author=c.author, branch=m, date=c.date, + comment='convert-repo: CVS merge from branch %s' + % c.branch, + entries=[], tags=[], + parents=[changesets[branches[m]], c]) changesets.insert(i + 1, cc) branches[m] = i + 1 @@ -775,7 +777,7 @@ if opts["ancestors"]: if cs.branch not in branches and cs.parents and cs.parents[0].id: - ancestors[cs.branch] = (changesets[cs.parents[0].id-1].branch, + ancestors[cs.branch] = (changesets[cs.parents[0].id - 1].branch, cs.parents[0].id) branches[cs.branch] = cs.id @@ -792,14 +794,15 @@ '%Y/%m/%d %H:%M:%S %1%2')) ui.write('Author: %s\n' % cs.author) ui.write('Branch: %s\n' % (cs.branch or 'HEAD')) - ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags)>1], + ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1], ','.join(cs.tags) or '(none)')) branchpoints = getattr(cs, 'branchpoints', None) if branchpoints: ui.write('Branchpoints: %s \n' % ', '.join(branchpoints)) if opts["parents"] and cs.parents: - if len(cs.parents)>1: - ui.write('Parents: %s\n' % (','.join([str(p.id) for p in cs.parents]))) + if len(cs.parents) > 1: + ui.write('Parents: %s\n' % + (','.join([str(p.id) for p in cs.parents]))) else: ui.write('Parent: %d\n' % cs.parents[0].id) @@ -819,8 +822,10 @@ fn = f.file if fn.startswith(opts["prefix"]): fn = fn[len(opts["prefix"]):] - ui.write('\t%s:%s->%s%s \n' % (fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL', - '.'.join([str(x) for x in f.revision]), ['', '(DEAD)'][f.dead])) + ui.write('\t%s:%s->%s%s \n' % ( + fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL', + '.'.join([str(x) for x in f.revision]), + ['', '(DEAD)'][f.dead])) ui.write('\n') # have we seen the start tag? @@ -830,7 +835,7 @@ off = False # see if we reached the end tag - if len(revisions)>1 and not off: + if len(revisions) > 1 and not off: if revisions[1] == str(cs.id) or \ revisions[1] in cs.tags: break
--- a/hgext/convert/darcs.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/darcs.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from common import NoRepo, checktool, commandline, commit, converter_source from mercurial.i18n import _ @@ -12,15 +12,19 @@ # The naming drift of ElementTree is fun! -try: from xml.etree.cElementTree import ElementTree +try: + from xml.etree.cElementTree import ElementTree except ImportError: - try: from xml.etree.ElementTree import ElementTree + try: + from xml.etree.ElementTree import ElementTree except ImportError: - try: from elementtree.cElementTree import ElementTree + try: + from elementtree.cElementTree import ElementTree except ImportError: - try: from elementtree.ElementTree import ElementTree - except ImportError: ElementTree = None - + try: + from elementtree.ElementTree import ElementTree + except ImportError: + ElementTree = None class darcs_source(converter_source, commandline): def __init__(self, ui, path, rev=None):
--- a/hgext/convert/filemap.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/filemap.py Thu Jan 28 23:13:45 2010 -0600 @@ -2,7 +2,7 @@ # Copyright 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import shlex from mercurial.i18n import _ @@ -12,7 +12,7 @@ def rpairs(name): e = len(name) while e != -1: - yield name[:e], name[e+1:] + yield name[:e], name[e + 1:] e = name.rfind('/', 0, e) yield '.', name
--- a/hgext/convert/git.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/git.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os from mercurial import util @@ -43,13 +43,15 @@ def getheads(self): if not self.rev: - return self.gitcmd('git rev-parse --branches --remotes').read().splitlines() + fh = self.gitcmd('git rev-parse --branches --remotes') + return fh.read().splitlines() else: fh = self.gitcmd("git rev-parse --verify %s" % self.rev) return [fh.read()[:-1]] def catfile(self, rev, type): - if rev == "0" * 40: raise IOError() + if rev == "0" * 40: + raise IOError() fh = self.gitcmd("git cat-file %s %s" % (type, rev)) return fh.read() @@ -86,7 +88,7 @@ def getcommit(self, version): c = self.catfile(version, "commit") # read the commit hash end = c.find("\n\n") - message = c[end+2:] + message = c[end + 2:] message = self.recode(message) l = c[:end].splitlines() parents = [] @@ -105,7 +107,8 @@ committer = " ".join(p[:-2]) if committer[0] == "<": committer = committer[1:-1] committer = self.recode(committer) - if n == "parent": parents.append(v) + if n == "parent": + parents.append(v) if committer and committer != author: message += "\ncommitter: %s\n" % committer @@ -145,7 +148,7 @@ fh.close() else: fh = self.gitcmd('git diff-tree --name-only --root -r %s "%s^%s" --' - % (version, version, i+1)) + % (version, version, i + 1)) changes = [f.rstrip('\n') for f in fh] fh.close()
--- a/hgext/convert/gnuarch.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/gnuarch.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from common import NoRepo, commandline, commit, converter_source from mercurial.i18n import _ @@ -89,7 +89,8 @@ # Get the complete list of revisions for that tree version output, status = self.runlines('revisions', '-r', '-f', treeversion) - self.checkexit(status, 'failed retrieveing revisions for %s' % treeversion) + self.checkexit(status, 'failed retrieveing revisions for %s' + % treeversion) # No new iteration unless a revision has a continuation-of header treeversion = None @@ -116,7 +117,8 @@ # or if we have to 'jump' to a different treeversion given # by the continuation-of header. if self.changes[rev].continuationof: - treeversion = '--'.join(self.changes[rev].continuationof.split('--')[:-1]) + treeversion = '--'.join( + self.changes[rev].continuationof.split('--')[:-1]) break # If we reached a base-0 revision w/o any continuation-of @@ -220,7 +222,7 @@ return data, mode def _exclude(self, name): - exclude = [ '{arch}', '.arch-ids', '.arch-inventory' ] + exclude = ['{arch}', '.arch-ids', '.arch-inventory'] for exc in exclude: if name.find(exc) != -1: return True @@ -285,7 +287,8 @@ # Commit revision origin when dealing with a branch or tag if 'Continuation-of' in catlog: - self.changes[rev].continuationof = self.recode(catlog['Continuation-of']) + self.changes[rev].continuationof = self.recode( + catlog['Continuation-of']) except Exception: raise util.Abort(_('could not parse cat-log of %s') % rev)
--- a/hgext/convert/hg.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/hg.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # Notes for hg->hg conversion: # @@ -74,7 +74,7 @@ def getheads(self): h = self.repo.changelog.heads() - return [ hex(x) for x in h ] + return [hex(x) for x in h] def setbranch(self, branch, pbranches): if not self.clonebranches: @@ -147,8 +147,10 @@ m1node = self.repo.changelog.read(bin(parents[0]))[0] parent = parents[0] - if len(parents) < 2: parents.append(nullid) - if len(parents) < 2: parents.append(nullid) + if len(parents) < 2: + parents.append(nullid) + if len(parents) < 2: + parents.append(nullid) p2 = parents.pop(0) text = commit.desc @@ -161,8 +163,8 @@ while parents: p1 = p2 p2 = parents.pop(0) - ctx = context.memctx(self.repo, (p1, p2), text, files.keys(), getfilectx, - commit.author, commit.date, extra) + ctx = context.memctx(self.repo, (p1, p2), text, files.keys(), + getfilectx, commit.author, commit.date, extra) self.repo.commitctx(ctx) text = "(octopus merge fixup)\n" p2 = hex(self.repo.changelog.tip())
--- a/hgext/convert/monotone.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/monotone.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os, re from mercurial import util @@ -38,16 +38,22 @@ lines = r'(?:.|\n)+' self.dir_re = re.compile(space + "dir" + name) - self.file_re = re.compile(space + "file" + name + "content" + revision) - self.add_file_re = re.compile(space + "add_file" + name + "content" + revision) - self.patch_re = re.compile(space + "patch" + name + "from" + revision + "to" + revision) + self.file_re = re.compile(space + "file" + name + + "content" + revision) + self.add_file_re = re.compile(space + "add_file" + name + + "content" + revision) + self.patch_re = re.compile(space + "patch" + name + + "from" + revision + "to" + revision) self.rename_re = re.compile(space + "rename" + name + "to" + name) self.delete_re = re.compile(space + "delete" + name) - self.tag_re = re.compile(space + "tag" + name + "revision" + revision) - self.cert_re = re.compile(lines + space + "name" + name + "value" + value) + self.tag_re = re.compile(space + "tag" + name + "revision" + + revision) + self.cert_re = re.compile(lines + space + "name" + name + + "value" + value) attr = space + "file" + lines + space + "attr" + space - self.attr_execute_re = re.compile(attr + '"mtn:execute"' + space + '"true"') + self.attr_execute_re = re.compile(attr + '"mtn:execute"' + + space + '"true"') # cached data self.manifest_rev = None
--- a/hgext/convert/p4.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/p4.py Thu Jan 28 23:13:45 2010 -0600 @@ -1,11 +1,9 @@ -# # Perforce source for convert extension. # # Copyright 2009, Frank Kingswood <frank@kingswood-consulting.co.uk> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. -# +# GNU General Public License version 2 or any later version. from mercurial import util from mercurial.i18n import _ @@ -44,8 +42,12 @@ self.encoding = "latin_1" self.depotname = {} # mapping from local name to depot name self.modecache = {} - self.re_type = re.compile("([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)(\+\w+)?$") - self.re_keywords = re.compile(r"\$(Id|Header|Date|DateTime|Change|File|Revision|Author):[^$\n]*\$") + self.re_type = re.compile( + "([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)" + "(\+\w+)?$") + self.re_keywords = re.compile( + r"\$(Id|Header|Date|DateTime|Change|File|Revision|Author)" + r":[^$\n]*\$") self.re_keywords_old = re.compile("\$(Id|Header):[^$\n]*\$") self._parse(ui, path) @@ -120,7 +122,8 @@ date = (int(d["time"]), 0) # timezone not set c = commit(author=self.recode(d["user"]), date=util.datestr(date), - parents=parents, desc=desc, branch='', extra={"p4": change}) + parents=parents, desc=desc, branch='', + extra={"p4": change}) files = [] i = 0
--- a/hgext/convert/subversion.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/subversion.py Thu Jan 28 23:13:45 2010 -0600 @@ -138,7 +138,7 @@ # looking for several svn-specific files and directories in the given # directory. def filecheck(ui, path, proto): - for x in ('locks', 'hooks', 'format', 'db', ): + for x in ('locks', 'hooks', 'format', 'db'): if not os.path.exists(os.path.join(path, x)): return False return True @@ -150,7 +150,7 @@ try: opener = urllib2.build_opener() rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) - data = rsp.read() + data = rsp.read() except urllib2.HTTPError, inst: if inst.code != 404: # Except for 404 we cannot know for sure this is not an svn repo @@ -231,7 +231,7 @@ # deleted branches. at = url.rfind('@') if at >= 0: - latest = int(url[at+1:]) + latest = int(url[at + 1:]) url = url[:at] except ValueError: pass @@ -363,7 +363,8 @@ 'with more than one branch')) revnum = self.revnum(self.heads[0]) if revnum < self.startrev: - raise util.Abort(_('svn: no revision found after start revision %d') + raise util.Abort( + _('svn: no revision found after start revision %d') % self.startrev) return self.heads @@ -389,7 +390,7 @@ uuid, module, revnum = self.revsplit(rev) entries = svn.client.ls(self.baseurl + urllib.quote(module), optrev(revnum), True, self.ctx) - files = [n for n,e in entries.iteritems() + files = [n for n, e in entries.iteritems() if e.kind == svn.core.svn_node_file] copies = {} @@ -564,7 +565,8 @@ except SubversionException: dirent = None if not dirent: - raise SvnPathNotFound(_('%s not found up to revision %d') % (path, stop)) + raise SvnPathNotFound(_('%s not found up to revision %d') + % (path, stop)) # stat() gives us the previous revision on this line of # development, but it might be in *another module*. Fetch the @@ -645,7 +647,8 @@ # We can avoid the reparent calls if the module has # not changed but it probably does not worth the pain. prevmodule = self.reparent('') - fromkind = svn.ra.check_path(self.ra, parentpath.strip('/'), prevnum) + fromkind = svn.ra.check_path(self.ra, parentpath.strip('/'), + prevnum) self.reparent(prevmodule) if fromkind == svn.core.svn_node_file: @@ -657,7 +660,7 @@ oroot = parentpath.strip('/') nroot = path.strip('/') children = self._find_children(oroot, prevnum) - children = [s.replace(oroot,nroot) for s in children] + children = [s.replace(oroot, nroot) for s in children] for child in children: childpath = self.getrelpath("/" + child, pmodule) @@ -738,7 +741,8 @@ # check whether this revision is the start of a branch or part # of a branch renaming orig_paths = sorted(orig_paths.iteritems()) - root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)] + root_paths = [(p, e) for p, e in orig_paths + if self.module.startswith(p)] if root_paths: path, ent = root_paths[-1] if ent.copyfrom_path: @@ -750,8 +754,9 @@ prevmodule, prevnum = self.revsplit(previd)[1:] if prevnum >= self.startrev: parents = [previd] - self.ui.note(_('found parent of branch %s at %d: %s\n') % - (self.module, prevnum, prevmodule)) + self.ui.note( + _('found parent of branch %s at %d: %s\n') % + (self.module, prevnum, prevmodule)) else: self.ui.debug("no copyfrom path, don't know what to do.\n")
--- a/hgext/convert/transport.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/convert/transport.py Thu Jan 28 23:13:45 2010 -0600 @@ -125,4 +125,5 @@ self._baton, pool) def do_update(self, revnum, path, *args, **kwargs): - return self.Reporter(svn.ra.do_update(self.ra, revnum, path, *args, **kwargs)) + return self.Reporter(svn.ra.do_update(self.ra, revnum, path, + *args, **kwargs))
--- a/hgext/extdiff.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/extdiff.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to allow external programs to compare revisions @@ -239,7 +239,8 @@ for cmd, path in ui.configitems('extdiff'): if cmd.startswith('cmd.'): cmd = cmd[4:] - if not path: path = cmd + if not path: + path = cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') diffopts = diffopts and [diffopts] or [] elif cmd.startswith('opts.'):
--- a/hgext/fetch.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/fetch.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''pull, update and merge in one command'''
--- a/hgext/gpg.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/gpg.py Thu Jan 28 23:13:45 2010 -0600 @@ -1,7 +1,7 @@ # Copyright 2005, 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''commands to sign and verify changesets''' @@ -38,8 +38,10 @@ finally: for f in (sigfile, datafile): try: - if f: os.unlink(f) - except: pass + if f: + os.unlink(f) + except: + pass keys = [] key, fingerprint = None, None err = ""
--- a/hgext/graphlog.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/graphlog.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007 Joel Rosdahl <joel@rosdahl.net> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to view revision graphs from a shell
--- a/hgext/hgcia.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/hgcia.py Thu Jan 28 23:13:45 2010 -0600 @@ -1,5 +1,7 @@ # Copyright (C) 2007-8 Brendan Cully <brendan@kublai.com> -# Published under the GNU GPL +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. """hooks for integrating with the CIA.vc notification service
--- a/hgext/hgk.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/hgk.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Chris Mason <mason@suse.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''browse the repository in a graphical way @@ -186,7 +186,7 @@ l[x].changeset() # force reading else: l[x] = 1 - for x in xrange(chunk-1, -1, -1): + for x in xrange(chunk - 1, -1, -1): if l[x] != 0: yield (i + x, full != None and l[x] or None) if i == 0:
--- a/hgext/highlight/__init__.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/highlight/__init__.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008, 2009 Patrick Mezard <pmezard@gmail.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # # The original module was split in an interface and an implementation # file to defer pygments loading and speedup extension setup.
--- a/hgext/highlight/highlight.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/highlight/highlight.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007-2009 Adam Hupp <adam@hupp.org> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # # The original module was split in an interface and an implementation # file to defer pygments loading and speedup extension setup.
--- a/hgext/inotify/__init__.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/__init__.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''accelerate status report using Linux's inotify service''' @@ -60,7 +60,7 @@ if ui.config('inotify', 'debug'): r2 = super(inotifydirstate, self).status( match, False, clean, unknown) - for c,a,b in zip('LMARDUIC', result, r2): + for c, a, b in zip('LMARDUIC', result, r2): for f in a: if f not in b: ui.warn('*** inotify: %s +%s\n' % (c, f))
--- a/hgext/inotify/client.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/client.py Thu Jan 28 23:13:45 2010 -0600 @@ -5,13 +5,14 @@ # Copyright 2009 Nicolas Dumazet <nicdumz@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from mercurial.i18n import _ import common, server import errno, os, socket, struct -class QueryFailed(Exception): pass +class QueryFailed(Exception): + pass def start_server(function): """ @@ -137,8 +138,10 @@ states = 'almrx!' if ignored: raise ValueError('this is insanity') - if clean: states += 'c' - if unknown: states += '?' + if clean: + states += 'c' + if unknown: + states += '?' yield states req = '\0'.join(genquery())
--- a/hgext/inotify/common.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/common.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import cStringIO, socket, struct
--- a/hgext/inotify/linux/__init__.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/linux/__init__.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # This library is free software; you can redistribute it and/or modify # it under the terms of version 2.1 of the GNU Lesser General Public -# License, incorporated herein by reference. +# License, or any later version. '''Low-level interface to the Linux inotify subsystem.
--- a/hgext/inotify/linux/_inotify.c Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/linux/_inotify.c Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ * * This library is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General - * Public License, incorporated herein by reference. + * Public License or any later version. */ #include <Python.h> @@ -17,298 +17,298 @@ static PyObject *init(PyObject *self, PyObject *args) { - PyObject *ret = NULL; - int fd = -1; + PyObject *ret = NULL; + int fd = -1; - if (!PyArg_ParseTuple(args, ":init")) - goto bail; + if (!PyArg_ParseTuple(args, ":init")) + goto bail; - Py_BEGIN_ALLOW_THREADS - fd = inotify_init(); - Py_END_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS; + fd = inotify_init(); + Py_END_ALLOW_THREADS; - if (fd == -1) { - PyErr_SetFromErrno(PyExc_OSError); - goto bail; - } + if (fd == -1) { + PyErr_SetFromErrno(PyExc_OSError); + goto bail; + } - ret = PyInt_FromLong(fd); - if (ret == NULL) - goto bail; + ret = PyInt_FromLong(fd); + if (ret == NULL) + goto bail; - goto done; + goto done; bail: - if (fd != -1) - close(fd); + if (fd != -1) + close(fd); - Py_CLEAR(ret); + Py_CLEAR(ret); done: - return ret; + return ret; } PyDoc_STRVAR( - init_doc, - "init() -> fd\n" - "\n" - "Initialise an inotify instance.\n" - "Return a file descriptor associated with a new inotify event queue."); + init_doc, + "init() -> fd\n" + "\n" + "Initialise an inotify instance.\n" + "Return a file descriptor associated with a new inotify event queue."); static PyObject *add_watch(PyObject *self, PyObject *args) { - PyObject *ret = NULL; - uint32_t mask; - int wd = -1; - char *path; - int fd; + PyObject *ret = NULL; + uint32_t mask; + int wd = -1; + char *path; + int fd; - if (!PyArg_ParseTuple(args, "isI:add_watch", &fd, &path, &mask)) - goto bail; + if (!PyArg_ParseTuple(args, "isI:add_watch", &fd, &path, &mask)) + goto bail; - Py_BEGIN_ALLOW_THREADS - wd = inotify_add_watch(fd, path, mask); - Py_END_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS; + wd = inotify_add_watch(fd, path, mask); + Py_END_ALLOW_THREADS; - if (wd == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); - goto bail; - } + if (wd == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); + goto bail; + } - ret = PyInt_FromLong(wd); - if (ret == NULL) - goto bail; + ret = PyInt_FromLong(wd); + if (ret == NULL) + goto bail; - goto done; + goto done; bail: - if (wd != -1) - inotify_rm_watch(fd, wd); + if (wd != -1) + inotify_rm_watch(fd, wd); - Py_CLEAR(ret); + Py_CLEAR(ret); done: - return ret; + return ret; } PyDoc_STRVAR( - add_watch_doc, - "add_watch(fd, path, mask) -> wd\n" - "\n" - "Add a watch to an inotify instance, or modify an existing watch.\n" - "\n" - " fd: file descriptor returned by init()\n" - " path: path to watch\n" - " mask: mask of events to watch for\n" - "\n" - "Return a unique numeric watch descriptor for the inotify instance\n" - "mapped by the file descriptor."); + add_watch_doc, + "add_watch(fd, path, mask) -> wd\n" + "\n" + "Add a watch to an inotify instance, or modify an existing watch.\n" + "\n" + " fd: file descriptor returned by init()\n" + " path: path to watch\n" + " mask: mask of events to watch for\n" + "\n" + "Return a unique numeric watch descriptor for the inotify instance\n" + "mapped by the file descriptor."); static PyObject *remove_watch(PyObject *self, PyObject *args) { - uint32_t wd; - int fd; - int r; + uint32_t wd; + int fd; + int r; - if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd)) - return NULL; + if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd)) + return NULL; - Py_BEGIN_ALLOW_THREADS - r = inotify_rm_watch(fd, wd); - Py_END_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS; + r = inotify_rm_watch(fd, wd); + Py_END_ALLOW_THREADS; - if (r == -1) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } + if (r == -1) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyDoc_STRVAR( - remove_watch_doc, - "remove_watch(fd, wd)\n" - "\n" - " fd: file descriptor returned by init()\n" - " wd: watch descriptor returned by add_watch()\n" - "\n" - "Remove a watch associated with the watch descriptor wd from the\n" - "inotify instance associated with the file descriptor fd.\n" - "\n" - "Removing a watch causes an IN_IGNORED event to be generated for this\n" - "watch descriptor."); + remove_watch_doc, + "remove_watch(fd, wd)\n" + "\n" + " fd: file descriptor returned by init()\n" + " wd: watch descriptor returned by add_watch()\n" + "\n" + "Remove a watch associated with the watch descriptor wd from the\n" + "inotify instance associated with the file descriptor fd.\n" + "\n" + "Removing a watch causes an IN_IGNORED event to be generated for this\n" + "watch descriptor."); #define bit_name(x) {x, #x} static struct { - int bit; - const char *name; - PyObject *pyname; + int bit; + const char *name; + PyObject *pyname; } bit_names[] = { - bit_name(IN_ACCESS), - bit_name(IN_MODIFY), - bit_name(IN_ATTRIB), - bit_name(IN_CLOSE_WRITE), - bit_name(IN_CLOSE_NOWRITE), - bit_name(IN_OPEN), - bit_name(IN_MOVED_FROM), - bit_name(IN_MOVED_TO), - bit_name(IN_CREATE), - bit_name(IN_DELETE), - bit_name(IN_DELETE_SELF), - bit_name(IN_MOVE_SELF), - bit_name(IN_UNMOUNT), - bit_name(IN_Q_OVERFLOW), - bit_name(IN_IGNORED), - bit_name(IN_ONLYDIR), - bit_name(IN_DONT_FOLLOW), - bit_name(IN_MASK_ADD), - bit_name(IN_ISDIR), - bit_name(IN_ONESHOT), - {0} + bit_name(IN_ACCESS), + bit_name(IN_MODIFY), + bit_name(IN_ATTRIB), + bit_name(IN_CLOSE_WRITE), + bit_name(IN_CLOSE_NOWRITE), + bit_name(IN_OPEN), + bit_name(IN_MOVED_FROM), + bit_name(IN_MOVED_TO), + bit_name(IN_CREATE), + bit_name(IN_DELETE), + bit_name(IN_DELETE_SELF), + bit_name(IN_MOVE_SELF), + bit_name(IN_UNMOUNT), + bit_name(IN_Q_OVERFLOW), + bit_name(IN_IGNORED), + bit_name(IN_ONLYDIR), + bit_name(IN_DONT_FOLLOW), + bit_name(IN_MASK_ADD), + bit_name(IN_ISDIR), + bit_name(IN_ONESHOT), + {0} }; static PyObject *decode_mask(int mask) { - PyObject *ret = PyList_New(0); - int i; + PyObject *ret = PyList_New(0); + int i; - if (ret == NULL) - goto bail; + if (ret == NULL) + goto bail; - for (i = 0; bit_names[i].bit; i++) { - if (mask & bit_names[i].bit) { - if (bit_names[i].pyname == NULL) { - bit_names[i].pyname = PyString_FromString(bit_names[i].name); - if (bit_names[i].pyname == NULL) - goto bail; - } - Py_INCREF(bit_names[i].pyname); - if (PyList_Append(ret, bit_names[i].pyname) == -1) - goto bail; + for (i = 0; bit_names[i].bit; i++) { + if (mask & bit_names[i].bit) { + if (bit_names[i].pyname == NULL) { + bit_names[i].pyname = PyString_FromString(bit_names[i].name); + if (bit_names[i].pyname == NULL) + goto bail; + } + Py_INCREF(bit_names[i].pyname); + if (PyList_Append(ret, bit_names[i].pyname) == -1) + goto bail; + } } - } - goto done; + goto done; bail: - Py_CLEAR(ret); + Py_CLEAR(ret); done: - return ret; + return ret; } static PyObject *pydecode_mask(PyObject *self, PyObject *args) { - int mask; + int mask; - if (!PyArg_ParseTuple(args, "i:decode_mask", &mask)) - return NULL; + if (!PyArg_ParseTuple(args, "i:decode_mask", &mask)) + return NULL; - return decode_mask(mask); + return decode_mask(mask); } PyDoc_STRVAR( - decode_mask_doc, - "decode_mask(mask) -> list_of_strings\n" - "\n" - "Decode an inotify mask value into a list of strings that give the\n" - "name of each bit set in the mask."); + decode_mask_doc, + "decode_mask(mask) -> list_of_strings\n" + "\n" + "Decode an inotify mask value into a list of strings that give the\n" + "name of each bit set in the mask."); static char doc[] = "Low-level inotify interface wrappers."; static void define_const(PyObject *dict, const char *name, uint32_t val) { - PyObject *pyval = PyInt_FromLong(val); - PyObject *pyname = PyString_FromString(name); + PyObject *pyval = PyInt_FromLong(val); + PyObject *pyname = PyString_FromString(name); - if (!pyname || !pyval) - goto bail; + if (!pyname || !pyval) + goto bail; - PyDict_SetItem(dict, pyname, pyval); + PyDict_SetItem(dict, pyname, pyval); bail: - Py_XDECREF(pyname); - Py_XDECREF(pyval); + Py_XDECREF(pyname); + Py_XDECREF(pyval); } static void define_consts(PyObject *dict) { - define_const(dict, "IN_ACCESS", IN_ACCESS); - define_const(dict, "IN_MODIFY", IN_MODIFY); - define_const(dict, "IN_ATTRIB", IN_ATTRIB); - define_const(dict, "IN_CLOSE_WRITE", IN_CLOSE_WRITE); - define_const(dict, "IN_CLOSE_NOWRITE", IN_CLOSE_NOWRITE); - define_const(dict, "IN_OPEN", IN_OPEN); - define_const(dict, "IN_MOVED_FROM", IN_MOVED_FROM); - define_const(dict, "IN_MOVED_TO", IN_MOVED_TO); + define_const(dict, "IN_ACCESS", IN_ACCESS); + define_const(dict, "IN_MODIFY", IN_MODIFY); + define_const(dict, "IN_ATTRIB", IN_ATTRIB); + define_const(dict, "IN_CLOSE_WRITE", IN_CLOSE_WRITE); + define_const(dict, "IN_CLOSE_NOWRITE", IN_CLOSE_NOWRITE); + define_const(dict, "IN_OPEN", IN_OPEN); + define_const(dict, "IN_MOVED_FROM", IN_MOVED_FROM); + define_const(dict, "IN_MOVED_TO", IN_MOVED_TO); - define_const(dict, "IN_CLOSE", IN_CLOSE); - define_const(dict, "IN_MOVE", IN_MOVE); + define_const(dict, "IN_CLOSE", IN_CLOSE); + define_const(dict, "IN_MOVE", IN_MOVE); - define_const(dict, "IN_CREATE", IN_CREATE); - define_const(dict, "IN_DELETE", IN_DELETE); - define_const(dict, "IN_DELETE_SELF", IN_DELETE_SELF); - define_const(dict, "IN_MOVE_SELF", IN_MOVE_SELF); - define_const(dict, "IN_UNMOUNT", IN_UNMOUNT); - define_const(dict, "IN_Q_OVERFLOW", IN_Q_OVERFLOW); - define_const(dict, "IN_IGNORED", IN_IGNORED); + define_const(dict, "IN_CREATE", IN_CREATE); + define_const(dict, "IN_DELETE", IN_DELETE); + define_const(dict, "IN_DELETE_SELF", IN_DELETE_SELF); + define_const(dict, "IN_MOVE_SELF", IN_MOVE_SELF); + define_const(dict, "IN_UNMOUNT", IN_UNMOUNT); + define_const(dict, "IN_Q_OVERFLOW", IN_Q_OVERFLOW); + define_const(dict, "IN_IGNORED", IN_IGNORED); - define_const(dict, "IN_ONLYDIR", IN_ONLYDIR); - define_const(dict, "IN_DONT_FOLLOW", IN_DONT_FOLLOW); - define_const(dict, "IN_MASK_ADD", IN_MASK_ADD); - define_const(dict, "IN_ISDIR", IN_ISDIR); - define_const(dict, "IN_ONESHOT", IN_ONESHOT); - define_const(dict, "IN_ALL_EVENTS", IN_ALL_EVENTS); + define_const(dict, "IN_ONLYDIR", IN_ONLYDIR); + define_const(dict, "IN_DONT_FOLLOW", IN_DONT_FOLLOW); + define_const(dict, "IN_MASK_ADD", IN_MASK_ADD); + define_const(dict, "IN_ISDIR", IN_ISDIR); + define_const(dict, "IN_ONESHOT", IN_ONESHOT); + define_const(dict, "IN_ALL_EVENTS", IN_ALL_EVENTS); } struct event { - PyObject_HEAD - PyObject *wd; - PyObject *mask; - PyObject *cookie; - PyObject *name; + PyObject_HEAD + PyObject *wd; + PyObject *mask; + PyObject *cookie; + PyObject *name; }; static PyObject *event_wd(PyObject *self, void *x) { - struct event *evt = (struct event *) self; - Py_INCREF(evt->wd); - return evt->wd; + struct event *evt = (struct event *)self; + Py_INCREF(evt->wd); + return evt->wd; } static PyObject *event_mask(PyObject *self, void *x) { - struct event *evt = (struct event *) self; - Py_INCREF(evt->mask); - return evt->mask; + struct event *evt = (struct event *)self; + Py_INCREF(evt->mask); + return evt->mask; } static PyObject *event_cookie(PyObject *self, void *x) { - struct event *evt = (struct event *) self; - Py_INCREF(evt->cookie); - return evt->cookie; + struct event *evt = (struct event *)self; + Py_INCREF(evt->cookie); + return evt->cookie; } static PyObject *event_name(PyObject *self, void *x) { - struct event *evt = (struct event *) self; - Py_INCREF(evt->name); - return evt->name; + struct event *evt = (struct event *)self; + Py_INCREF(evt->name); + return evt->name; } static struct PyGetSetDef event_getsets[] = { - {"wd", event_wd, NULL, - "watch descriptor"}, - {"mask", event_mask, NULL, - "event mask"}, - {"cookie", event_cookie, NULL, - "rename cookie, if rename-related event"}, - {"name", event_name, NULL, - "file name"}, - {NULL} + {"wd", event_wd, NULL, + "watch descriptor"}, + {"mask", event_mask, NULL, + "event mask"}, + {"cookie", event_cookie, NULL, + "rename cookie, if rename-related event"}, + {"name", event_name, NULL, + "file name"}, + {NULL} }; PyDoc_STRVAR( @@ -317,284 +317,285 @@ static PyObject *event_new(PyTypeObject *t, PyObject *a, PyObject *k) { - return (*t->tp_alloc)(t, 0); + return (*t->tp_alloc)(t, 0); } static void event_dealloc(struct event *evt) { - Py_XDECREF(evt->wd); - Py_XDECREF(evt->mask); - Py_XDECREF(evt->cookie); - Py_XDECREF(evt->name); + Py_XDECREF(evt->wd); + Py_XDECREF(evt->mask); + Py_XDECREF(evt->cookie); + Py_XDECREF(evt->name); - (*evt->ob_type->tp_free)(evt); + (*evt->ob_type->tp_free)(evt); } static PyObject *event_repr(struct event *evt) { - int wd = PyInt_AsLong(evt->wd); - int cookie = evt->cookie == Py_None ? -1 : PyInt_AsLong(evt->cookie); - PyObject *ret = NULL, *pymasks = NULL, *pymask = NULL; - PyObject *join = NULL; - char *maskstr; + int wd = PyInt_AsLong(evt->wd); + int cookie = evt->cookie == Py_None ? -1 : PyInt_AsLong(evt->cookie); + PyObject *ret = NULL, *pymasks = NULL, *pymask = NULL; + PyObject *join = NULL; + char *maskstr; - join = PyString_FromString("|"); - if (join == NULL) - goto bail; + join = PyString_FromString("|"); + if (join == NULL) + goto bail; - pymasks = decode_mask(PyInt_AsLong(evt->mask)); - if (pymasks == NULL) - goto bail; + pymasks = decode_mask(PyInt_AsLong(evt->mask)); + if (pymasks == NULL) + goto bail; - pymask = _PyString_Join(join, pymasks); - if (pymask == NULL) - goto bail; + pymask = _PyString_Join(join, pymasks); + if (pymask == NULL) + goto bail; - maskstr = PyString_AsString(pymask); + maskstr = PyString_AsString(pymask); + + if (evt->name != Py_None) { + PyObject *pyname = PyString_Repr(evt->name, 1); + char *name = pyname ? PyString_AsString(pyname) : "???"; - if (evt->name != Py_None) { - PyObject *pyname = PyString_Repr(evt->name, 1); - char *name = pyname ? PyString_AsString(pyname) : "???"; - - if (cookie == -1) - ret = PyString_FromFormat("event(wd=%d, mask=%s, name=%s)", - wd, maskstr, name); - else - ret = PyString_FromFormat("event(wd=%d, mask=%s, " - "cookie=0x%x, name=%s)", - wd, maskstr, cookie, name); + if (cookie == -1) + ret = PyString_FromFormat( + "event(wd=%d, mask=%s, name=%s)", + wd, maskstr, name); + else + ret = PyString_FromFormat("event(wd=%d, mask=%s, " + "cookie=0x%x, name=%s)", + wd, maskstr, cookie, name); - Py_XDECREF(pyname); - } else { - if (cookie == -1) - ret = PyString_FromFormat("event(wd=%d, mask=%s)", - wd, maskstr); - else { - ret = PyString_FromFormat("event(wd=%d, mask=%s, cookie=0x%x)", - wd, maskstr, cookie); + Py_XDECREF(pyname); + } else { + if (cookie == -1) + ret = PyString_FromFormat("event(wd=%d, mask=%s)", + wd, maskstr); + else { + ret = PyString_FromFormat( + "event(wd=%d, mask=%s, cookie=0x%x)", + wd, maskstr, cookie); + } } - } - goto done; + goto done; bail: - Py_CLEAR(ret); + Py_CLEAR(ret); done: - Py_XDECREF(pymask); - Py_XDECREF(pymasks); - Py_XDECREF(join); + Py_XDECREF(pymask); + Py_XDECREF(pymasks); + Py_XDECREF(join); - return ret; + return ret; } static PyTypeObject event_type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_inotify.event", /*tp_name*/ - sizeof(struct event), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)event_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - (reprfunc)event_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - event_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - event_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - event_new, /* tp_new */ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "_inotify.event", /*tp_name*/ + sizeof(struct event), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)event_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + (reprfunc)event_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + event_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + event_getsets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + event_new, /* tp_new */ }; PyObject *read_events(PyObject *self, PyObject *args) { - PyObject *ctor_args = NULL; - PyObject *pybufsize = NULL; - PyObject *ret = NULL; - int bufsize = 65536; - char *buf = NULL; - int nread, pos; - int fd; + PyObject *ctor_args = NULL; + PyObject *pybufsize = NULL; + PyObject *ret = NULL; + int bufsize = 65536; + char *buf = NULL; + int nread, pos; + int fd; + + if (!PyArg_ParseTuple(args, "i|O:read", &fd, &pybufsize)) + goto bail; - if (!PyArg_ParseTuple(args, "i|O:read", &fd, &pybufsize)) - goto bail; + if (pybufsize && pybufsize != Py_None) + bufsize = PyInt_AsLong(pybufsize); - if (pybufsize && pybufsize != Py_None) - bufsize = PyInt_AsLong(pybufsize); + ret = PyList_New(0); + if (ret == NULL) + goto bail; - ret = PyList_New(0); - if (ret == NULL) - goto bail; + if (bufsize <= 0) { + int r; - if (bufsize <= 0) { - int r; + Py_BEGIN_ALLOW_THREADS; + r = ioctl(fd, FIONREAD, &bufsize); + Py_END_ALLOW_THREADS; - Py_BEGIN_ALLOW_THREADS - r = ioctl(fd, FIONREAD, &bufsize); - Py_END_ALLOW_THREADS - - if (r == -1) { - PyErr_SetFromErrno(PyExc_OSError); - goto bail; + if (r == -1) { + PyErr_SetFromErrno(PyExc_OSError); + goto bail; + } + if (bufsize == 0) + goto done; } - if (bufsize == 0) - goto done; - } - else { - static long name_max; - static long name_fd = -1; - long min; + else { + static long name_max; + static long name_fd = -1; + long min; - if (name_fd != fd) { - name_fd = fd; - Py_BEGIN_ALLOW_THREADS - name_max = fpathconf(fd, _PC_NAME_MAX); - Py_END_ALLOW_THREADS + if (name_fd != fd) { + name_fd = fd; + Py_BEGIN_ALLOW_THREADS; + name_max = fpathconf(fd, _PC_NAME_MAX); + Py_END_ALLOW_THREADS; + } + + min = sizeof(struct inotify_event) + name_max + 1; + + if (bufsize < min) { + PyErr_Format(PyExc_ValueError, + "bufsize must be at least %d", (int)min); + goto bail; + } } - min = sizeof(struct inotify_event) + name_max + 1; - - if (bufsize < min) { - PyErr_Format(PyExc_ValueError, "bufsize must be at least %d", - (int) min); - goto bail; - } - } - - buf = alloca(bufsize); - - Py_BEGIN_ALLOW_THREADS - nread = read(fd, buf, bufsize); - Py_END_ALLOW_THREADS - - if (nread == -1) { - PyErr_SetFromErrno(PyExc_OSError); - goto bail; - } - - ctor_args = PyTuple_New(0); - - if (ctor_args == NULL) - goto bail; + buf = alloca(bufsize); - pos = 0; - - while (pos < nread) { - struct inotify_event *in = (struct inotify_event *) (buf + pos); - struct event *evt; - PyObject *obj; - - obj = PyObject_CallObject((PyObject *) &event_type, ctor_args); - - if (obj == NULL) - goto bail; - - evt = (struct event *) obj; + Py_BEGIN_ALLOW_THREADS; + nread = read(fd, buf, bufsize); + Py_END_ALLOW_THREADS; - evt->wd = PyInt_FromLong(in->wd); - evt->mask = PyInt_FromLong(in->mask); - if (in->mask & IN_MOVE) - evt->cookie = PyInt_FromLong(in->cookie); - else { - Py_INCREF(Py_None); - evt->cookie = Py_None; - } - if (in->len) - evt->name = PyString_FromString(in->name); - else { - Py_INCREF(Py_None); - evt->name = Py_None; + if (nread == -1) { + PyErr_SetFromErrno(PyExc_OSError); + goto bail; } - if (!evt->wd || !evt->mask || !evt->cookie || !evt->name) - goto mybail; + ctor_args = PyTuple_New(0); + + if (ctor_args == NULL) + goto bail; + + pos = 0; - if (PyList_Append(ret, obj) == -1) - goto mybail; + while (pos < nread) { + struct inotify_event *in = (struct inotify_event *)(buf + pos); + struct event *evt; + PyObject *obj; - pos += sizeof(struct inotify_event) + in->len; - continue; + obj = PyObject_CallObject((PyObject *)&event_type, ctor_args); + + if (obj == NULL) + goto bail; + + evt = (struct event *)obj; - mybail: - Py_CLEAR(evt->wd); - Py_CLEAR(evt->mask); - Py_CLEAR(evt->cookie); - Py_CLEAR(evt->name); - Py_DECREF(obj); + evt->wd = PyInt_FromLong(in->wd); + evt->mask = PyInt_FromLong(in->mask); + if (in->mask & IN_MOVE) + evt->cookie = PyInt_FromLong(in->cookie); + else { + Py_INCREF(Py_None); + evt->cookie = Py_None; + } + if (in->len) + evt->name = PyString_FromString(in->name); + else { + Py_INCREF(Py_None); + evt->name = Py_None; + } + + if (!evt->wd || !evt->mask || !evt->cookie || !evt->name) + goto mybail; - goto bail; - } + if (PyList_Append(ret, obj) == -1) + goto mybail; + + pos += sizeof(struct inotify_event) + in->len; + continue; - goto done; + mybail: + Py_CLEAR(evt->wd); + Py_CLEAR(evt->mask); + Py_CLEAR(evt->cookie); + Py_CLEAR(evt->name); + Py_DECREF(obj); + + goto bail; + } + + goto done; bail: - Py_CLEAR(ret); + Py_CLEAR(ret); done: - Py_XDECREF(ctor_args); + Py_XDECREF(ctor_args); - return ret; + return ret; } PyDoc_STRVAR( - read_doc, - "read(fd, bufsize[=65536]) -> list_of_events\n" - "\n" - "\nRead inotify events from a file descriptor.\n" - "\n" - " fd: file descriptor returned by init()\n" - " bufsize: size of buffer to read into, in bytes\n" - "\n" - "Return a list of event objects.\n" - "\n" - "If bufsize is > 0, block until events are available to be read.\n" - "Otherwise, immediately return all events that can be read without\n" - "blocking."); - + read_doc, + "read(fd, bufsize[=65536]) -> list_of_events\n" + "\n" + "\nRead inotify events from a file descriptor.\n" + "\n" + " fd: file descriptor returned by init()\n" + " bufsize: size of buffer to read into, in bytes\n" + "\n" + "Return a list of event objects.\n" + "\n" + "If bufsize is > 0, block until events are available to be read.\n" + "Otherwise, immediately return all events that can be read without\n" + "blocking."); static PyMethodDef methods[] = { - {"init", init, METH_VARARGS, init_doc}, - {"add_watch", add_watch, METH_VARARGS, add_watch_doc}, - {"remove_watch", remove_watch, METH_VARARGS, remove_watch_doc}, - {"read", read_events, METH_VARARGS, read_doc}, - {"decode_mask", pydecode_mask, METH_VARARGS, decode_mask_doc}, - {NULL}, + {"init", init, METH_VARARGS, init_doc}, + {"add_watch", add_watch, METH_VARARGS, add_watch_doc}, + {"remove_watch", remove_watch, METH_VARARGS, remove_watch_doc}, + {"read", read_events, METH_VARARGS, read_doc}, + {"decode_mask", pydecode_mask, METH_VARARGS, decode_mask_doc}, + {NULL}, }; void init_inotify(void) { - PyObject *mod, *dict; + PyObject *mod, *dict; - if (PyType_Ready(&event_type) == -1) - return; + if (PyType_Ready(&event_type) == -1) + return; - mod = Py_InitModule3("_inotify", methods, doc); + mod = Py_InitModule3("_inotify", methods, doc); - dict = PyModule_GetDict(mod); + dict = PyModule_GetDict(mod); - if (dict) - define_consts(dict); + if (dict) + define_consts(dict); }
--- a/hgext/inotify/linux/watcher.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/linux/watcher.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # This library is free software; you can redistribute it and/or modify # it under the terms of version 2.1 of the GNU Lesser General Public -# License, incorporated herein by reference. +# License, or any later version. '''High-level interfaces to the Linux inotify subsystem.
--- a/hgext/inotify/linuxserver.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/linuxserver.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from mercurial.i18n import _ from mercurial import osutil, util @@ -112,7 +112,8 @@ timeout = None timeobj = None for obj in cls.instances.itervalues(): - if obj.timeout is not None and (timeout is None or obj.timeout < timeout): + if obj.timeout is not None and (timeout is None + or obj.timeout < timeout): timeout, timeobj = obj.timeout, obj try: events = cls.poll.poll(timeout)
--- a/hgext/inotify/server.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/inotify/server.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Nicolas Dumazet <nicdumz@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from mercurial.i18n import _ from mercurial import cmdutil, osutil, util @@ -17,7 +17,8 @@ import sys import tempfile -class AlreadyStartedException(Exception): pass +class AlreadyStartedException(Exception): + pass def join(a, b): if a: @@ -30,7 +31,7 @@ c = path.rfind('/') if c == -1: return '', path - return path[:c], path[c+1:] + return path[:c], path[c + 1:] walk_ignored_errors = (errno.ENOENT, errno.ENAMETOOLONG) @@ -332,8 +333,8 @@ self.sock.bind(self.sockpath) except socket.error, err: if err[0] == errno.EADDRINUSE: - raise AlreadyStartedException( _('cannot start: socket is ' - 'already bound')) + raise AlreadyStartedException(_('cannot start: socket is ' + 'already bound')) if err[0] == "AF_UNIX path too long": if os.path.islink(self.sockpath) and \ not os.path.exists(self.sockpath):
--- a/hgext/interhg.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/interhg.py Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,7 @@ # Edward Lee <edward.lee@engineering.uiuc.edu> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''expand expressions into changelog and summaries
--- a/hgext/keyword.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/keyword.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007-2009 Christian Ebert <blacktrash@gmx.net> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # # $Id$ #
--- a/hgext/mq.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/mq.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Chris Mason <mason@suse.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''manage a stack of patches @@ -376,7 +376,8 @@ try: guards = self.opener(self.guards_path).read().split() except IOError, err: - if err.errno != errno.ENOENT: raise + if err.errno != errno.ENOENT: + raise guards = [] for i, guard in enumerate(guards): bad = self.check_guard(guard) @@ -450,9 +451,12 @@ for i in items: fp.write("%s\n" % i) fp.close() - if self.applied_dirty: write_list(map(str, self.applied), self.status_path) - if self.series_dirty: write_list(self.full_series, self.series_path) - if self.guards_dirty: write_list(self.active_guards, self.guards_path) + if self.applied_dirty: + write_list(map(str, self.applied), self.status_path) + if self.series_dirty: + write_list(self.full_series, self.series_path) + if self.guards_dirty: + write_list(self.active_guards, self.guards_path) def removeundo(self, repo): undo = repo.sjoin('undo') @@ -482,7 +486,7 @@ def mergeone(self, repo, mergeq, head, patch, rev, diffopts): # first try just applying the patch - (err, n) = self.apply(repo, [ patch ], update_status=False, + (err, n) = self.apply(repo, [patch], update_status=False, strict=True, merge=rev) if err == 0: @@ -529,7 +533,7 @@ return bin(self.applied[-1].rev) pp = repo.changelog.parents(rev) if pp[1] != nullid: - arevs = [ x.rev for x in self.applied ] + arevs = [x.rev for x in self.applied] p0 = hex(pp[0]) p1 = hex(pp[1]) if p0 in arevs: @@ -643,10 +647,10 @@ message = ph.message if not message: - message = _("imported patch %s\n") % patchname + message = "imported patch %s\n" % patchname else: if list: - message.append(_("\nimported patch %s") % patchname) + message.append("\nimported patch %s" % patchname) message = '\n'.join(message) if ph.haspatch: @@ -864,7 +868,8 @@ wlock.release() wlock = None r = self.qrepo() - if r: r.add([patchfn]) + if r: + r.add([patchfn]) except: repo.rollback() raise @@ -941,7 +946,7 @@ if not os.path.isfile(self.join(patch)): try: sno = int(patch) - except(ValueError, OverflowError): + except (ValueError, OverflowError): pass else: if -len(self.series) <= sno < len(self.series): @@ -957,8 +962,8 @@ if res: i = self.series.index(res) try: - off = int(patch[minus+1:] or 1) - except(ValueError, OverflowError): + off = int(patch[minus + 1:] or 1) + except (ValueError, OverflowError): pass else: if i - off >= 0: @@ -969,8 +974,8 @@ if res: i = self.series.index(res) try: - off = int(patch[plus+1:] or 1) - except(ValueError, OverflowError): + off = int(patch[plus + 1:] or 1) + except (ValueError, OverflowError): pass else: if i + off < len(self.series): @@ -1106,7 +1111,7 @@ if not update: parents = repo.dirstate.parents() - rr = [ bin(x.rev) for x in self.applied ] + rr = [bin(x.rev) for x in self.applied] for p in parents: if p in rr: self.ui.warn(_("qpop: forcing dirstate update\n")) @@ -1306,7 +1311,8 @@ f = repo.file(dst) src = f.renamed(man[dst]) if src: - copies.setdefault(src[0], []).extend(copies.get(dst, [])) + copies.setdefault(src[0], []).extend( + copies.get(dst, [])) if dst in a: copies[src[0]].append(dst) # we can't copy a file created by the patch itself @@ -1440,8 +1446,8 @@ length = len(self.series) - start if not missing: if self.ui.verbose: - idxwidth = len(str(start+length - 1)) - for i in xrange(start, start+length): + idxwidth = len(str(start + length - 1)) + for i in xrange(start, start + length): patch = self.series[i] if patch in applied: stat = 'A' @@ -1493,7 +1499,7 @@ elif line.startswith('Dirstate:'): l = line.rstrip() l = l[10:].split(' ') - qpp = [ bin(x) for x in l ] + qpp = [bin(x) for x in l] elif datastart != None: l = line.rstrip() se = statusentry(l) @@ -1542,7 +1548,7 @@ self.ui.warn(_("status is already saved\n")) return 1 - ar = [ ':' + x for x in self.full_series ] + ar = [':' + x for x in self.full_series] if not msg: msg = _("hg patches saved state") else: @@ -1694,7 +1700,8 @@ try: if filename == '-': if not patchname: - raise util.Abort(_('need --name to import a patch from -')) + raise util.Abort( + _('need --name to import a patch from -')) text = sys.stdin.read() else: text = url.open(self.ui, filename).read() @@ -1912,7 +1919,8 @@ """commit changes in the queue repository""" q = repo.mq r = q.qrepo() - if not r: raise util.Abort('no queue repository') + if not r: + raise util.Abort('no queue repository') commands.commit(r.ui, r, *pats, **opts) def series(ui, repo, **opts): @@ -1925,7 +1933,7 @@ q = repo.mq t = q.applied and q.series_end(True) or 0 if t: - return q.qseries(repo, start=t-1, length=1, status='A', + return q.qseries(repo, start=t - 1, length=1, status='A', summary=opts.get('summary')) else: ui.write(_("no patches applied\n")) @@ -1950,7 +1958,7 @@ if not l: ui.write(_("no patches applied\n")) return 1 - return q.qseries(repo, start=l-2, length=1, status='A', + return q.qseries(repo, start=l - 2, length=1, status='A', summary=opts.get('summary')) def setupheaderopts(ui, opts): @@ -1984,7 +1992,8 @@ information. """ msg = cmdutil.logmessage(opts) - def getmsg(): return ui.edit(msg, ui.username()) + def getmsg(): + return ui.edit(msg, ui.username()) q = repo.mq opts['msg'] = msg if opts.get('edit'): @@ -2272,7 +2281,8 @@ raise util.Abort(_('%s already exists') % absdest) if name in q.series: - raise util.Abort(_('A patch named %s already exists in the series file') % name) + raise util.Abort( + _('A patch named %s already exists in the series file') % name) if ui.verbose: ui.write('renaming %s to %s\n' % (patch, name)) @@ -2464,7 +2474,7 @@ if i == 0: q.pop(repo, all=True) else: - q.pop(repo, i-1) + q.pop(repo, i - 1) break if popped: try: @@ -2575,8 +2585,8 @@ start = lrev + 1 if start < qbase: # update the cache (excluding the patches) and save it - self._updatebranchcache(partial, lrev+1, qbase) - self._writebranchcache(partial, cl.node(qbase-1), qbase-1) + self._updatebranchcache(partial, lrev + 1, qbase) + self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1) start = qbase # if start = qbase, the cache is as updated as it should be. # if start > qbase, the cache includes (part of) the patches. @@ -2591,7 +2601,8 @@ repo.__class__ = mqrepo def mqimport(orig, ui, repo, *args, **kwargs): - if hasattr(repo, 'abort_if_wdir_patched') and not kwargs.get('no_commit', False): + if (hasattr(repo, 'abort_if_wdir_patched') + and not kwargs.get('no_commit', False)): repo.abort_if_wdir_patched(_('cannot import over an applied patch'), kwargs.get('force')) return orig(ui, repo, *args, **kwargs) @@ -2688,11 +2699,16 @@ (refresh, [('e', 'edit', None, _('edit commit message')), ('g', 'git', None, _('use git extended diff format')), - ('s', 'short', None, _('refresh only files already in the patch and specified files')), - ('U', 'currentuser', None, _('add/update author field in patch with current user')), - ('u', 'user', '', _('add/update author field in patch with given user')), - ('D', 'currentdate', None, _('add/update date field in patch with current date')), - ('d', 'date', '', _('add/update date field in patch with given date')) + ('s', 'short', None, + _('refresh only files already in the patch and specified files')), + ('U', 'currentuser', None, + _('add/update author field in patch with current user')), + ('u', 'user', '', + _('add/update author field in patch with given user')), + ('D', 'currentdate', None, + _('add/update date field in patch with current date')), + ('d', 'date', '', + _('add/update date field in patch with given date')) ] + commands.walkopts + commands.commitopts, _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')), 'qrename|qmv':
--- a/hgext/notify.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/notify.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''hooks for sending email notifications at commit/push time @@ -134,7 +134,7 @@ c = path.find('/') if c == -1: break - path = path[c+1:] + path = path[c + 1:] count -= 1 return path @@ -216,7 +216,7 @@ subject = '%s: %s' % (self.root, s) maxsubject = int(self.ui.config('notify', 'maxsubject', 67)) if maxsubject and len(subject) > maxsubject: - subject = subject[:maxsubject-3] + '...' + subject = subject[:maxsubject - 3] + '...' msg['Subject'] = mail.headencode(self.ui, subject, self.charsets, self.test)
--- a/hgext/pager.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/pager.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008 David Soria Parra <dsp@php.net> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # # To load the extension, add it to your .hgrc file: #
--- a/hgext/parentrevspec.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/parentrevspec.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright (C) 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''interpret suffixes to refer to ancestor revisions @@ -67,7 +67,7 @@ p = cl.parentrevs(rev) if j < len(suffix) and suffix[j].isdigit(): j += 1 - n = int(suffix[i+1:j]) + n = int(suffix[i + 1:j]) if n > 2 or n == 2 and p[1] == -1: raise else: @@ -85,7 +85,7 @@ j += 1 if j == i + 1: raise - n = int(suffix[i+1:j]) + n = int(suffix[i + 1:j]) for k in xrange(n): rev = cl.parentrevs(rev)[0] i = j
--- a/hgext/patchbomb.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/patchbomb.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to send changesets as (a series of) patch emails @@ -35,6 +35,9 @@ cc = cc1, cc2, ... bcc = bcc1, bcc2, ... +Use ``[patchbomb]`` as configuration section name if you need to +override global ``[email]`` address settings. + Then you can use the "hg email" command to mail a series of changesets as a patchbomb. @@ -80,7 +83,7 @@ if not ui.interactive(): if default is not None: return default - raise util.Abort(_("%s Please enter a valid value" % (prompt+rest))) + raise util.Abort(_("%s Please enter a valid value" % (prompt + rest))) if default: prompt += ' [%s]' % default prompt += rest
--- a/hgext/rebase.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/rebase.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008 Stefano Tortarolo <stefano.tortarolo at gmail dot com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to move sets of revisions to a different ancestor
--- a/hgext/record.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/record.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''commands to interactively select changes for commit/qrefresh''' @@ -297,7 +297,8 @@ doc = gettext(record.__doc__) c = doc.find(_('y - record this change')) for l in doc[c:].splitlines(): - if l: ui.write(l.strip(), '\n') + if l: + ui.write(l.strip(), '\n') continue elif r == 0: # yes ret = True @@ -437,8 +438,10 @@ contenders = set() for h in chunks: - try: contenders.update(set(h.files())) - except AttributeError: pass + try: + contenders.update(set(h.files())) + except AttributeError: + pass changed = changes[0] + changes[1] + changes[2] newfiles = [f for f in changed if f in contenders]
--- a/hgext/relink.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/relink.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright (C) 2007 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """recreates hardlinks between repository clones"""
--- a/hgext/schemes.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/schemes.py Thu Jan 28 23:13:45 2010 -0600 @@ -1,7 +1,7 @@ # Copyright 2009, Alexander Solovyov <piranha@piranha.org.ua> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """extend schemes with shortcuts to repository swarms @@ -64,7 +64,7 @@ parts = parts[:-1] else: tail = '' - context = dict((str(i+1), v) for i, v in enumerate(parts)) + context = dict((str(i + 1), v) for i, v in enumerate(parts)) url = ''.join(self.templater.process(self.url, context)) + tail return hg._lookup(url).instance(ui, url, create)
--- a/hgext/share.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/share.py Thu Jan 28 23:13:45 2010 -0600 @@ -1,7 +1,7 @@ # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''share a common history between several working directories'''
--- a/hgext/transplant.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/transplant.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''command to transplant changesets from another branch @@ -489,7 +489,7 @@ def incwalk(repo, incoming, branches, match=util.always): if not branches: - branches=None + branches = None for node in repo.changelog.nodesbetween(incoming, branches)[0]: if match(node): yield node @@ -506,7 +506,7 @@ def checkopts(opts, revs): if opts.get('continue'): - if filter(lambda opt: opts.get(opt), ('branch', 'all', 'merge')): + if opts.get('branch') or opts.get('all') or opts.get('merge'): raise util.Abort(_('--continue is incompatible with ' 'branch, all or merge')) return
--- a/hgext/win32mbcs.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/win32mbcs.py Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,7 @@ # Author: Shun-ichi Goto <shunichi.goto@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # '''allow the use of MBCS paths with problematic encodings
--- a/hgext/win32text.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/win32text.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2007-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''perform automatic newline conversion
--- a/hgext/zeroconf/Zeroconf.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/zeroconf/Zeroconf.py Thu Jan 28 23:13:45 2010 -0600 @@ -1571,3 +1571,5 @@ r.unregisterService(info) print " Unregister done." r.close() + +# no-check-code
--- a/hgext/zeroconf/__init__.py Mon Jan 18 19:57:36 2010 +0100 +++ b/hgext/zeroconf/__init__.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. '''discover and advertise repositories on the local network
--- a/hgwebdir.cgi Mon Jan 18 19:57:36 2010 +0100 +++ b/hgwebdir.cgi Thu Jan 28 23:13:45 2010 -0600 @@ -37,7 +37,7 @@ # [collections] # /prefix/to/strip/off = /root/of/tree/full/of/repos # -# paths example: +# paths example: # # * First two lines mount one repository into one virtual path, like # '/real/path1' into 'virtual/path1'.
--- a/i18n/hggettext Mon Jan 18 19:57:36 2010 +0100 +++ b/i18n/hggettext Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # The normalize function is taken from pygettext which is distributed # with Python under the Python License, which is GPL compatible.
--- a/mercurial/ancestor.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/ancestor.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import heapq
--- a/mercurial/archival.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/archival.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ from node import hex @@ -205,7 +205,8 @@ prefix is name of path to put before every archive member.''' def write(name, mode, islink, getdata): - if matchfn and not matchfn(name): return + if matchfn and not matchfn(name): + return data = getdata() if decode: data = repo.wwritedata(name, data)
--- a/mercurial/base85.c Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/base85.c Thu Jan 28 23:13:45 2010 -0600 @@ -105,18 +105,24 @@ { c = b85dec[(int)*text++] - 1; if (c < 0) - return PyErr_Format(PyExc_ValueError, "Bad base85 character at position %d", i); + return PyErr_Format( + PyExc_ValueError, + "Bad base85 character at position %d", i); acc = acc * 85 + c; } if (i++ < len) { c = b85dec[(int)*text++] - 1; if (c < 0) - return PyErr_Format(PyExc_ValueError, "Bad base85 character at position %d", i); + return PyErr_Format( + PyExc_ValueError, + "Bad base85 character at position %d", i); /* overflow detection: 0xffffffff == "|NsC0", * "|NsC" == 0x03030303 */ if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) - return PyErr_Format(PyExc_ValueError, "Bad base85 sequence at position %d", i); + return PyErr_Format( + PyExc_ValueError, + "Bad base85 sequence at position %d", i); acc += c; }
--- a/mercurial/bdiff.c Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/bdiff.c Thu Jan 28 23:13:45 2010 -0600 @@ -15,11 +15,11 @@ #include <limits.h> #if defined __hpux || defined __SUNPRO_C || defined _AIX -# define inline +#define inline #endif #ifdef __linux -# define inline __inline +#define inline __inline #endif #ifdef _WIN32 @@ -267,19 +267,21 @@ /* normalize the hunk list, try to push each hunk towards the end */ for (curr = l.base; curr != l.head; curr++) { - struct hunk *next = curr+1; + struct hunk *next = curr + 1; int shift = 0; if (next == l.head) break; if (curr->a2 == next->a1) - while (curr->a2+shift < an && curr->b2+shift < bn - && !cmp(a+curr->a2+shift, b+curr->b2+shift)) + while (curr->a2 + shift < an && curr->b2 + shift < bn + && !cmp(a + curr->a2 + shift, + b + curr->b2 + shift)) shift++; else if (curr->b2 == next->b1) - while (curr->b2+shift < bn && curr->a2+shift < an - && !cmp(b+curr->b2+shift, a+curr->a2+shift)) + while (curr->b2 + shift < bn && curr->a2 + shift < an + && !cmp(b + curr->b2 + shift, + a + curr->a2 + shift)) shift++; if (!shift) continue;
--- a/mercurial/bundlerepo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/bundlerepo.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """Repository class for viewing uncompressed bundles. @@ -73,7 +73,8 @@ if rev < 0: return False return rev in self.basemap - def bundlebase(self, rev): return self.basemap[rev] + def bundlebase(self, rev): + return self.basemap[rev] def _chunk(self, rev): # Warning: in case of bundle, the diff is against bundlebase, # not against rev - 1 @@ -98,7 +99,8 @@ def revision(self, node): """return an uncompressed revision of a given""" - if node == nullid: return "" + if node == nullid: + return "" text = None chain = []
--- a/mercurial/byterange.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/byterange.py Thu Jan 28 23:13:45 2010 -0600 @@ -310,7 +310,8 @@ (fb, lb) = range_tup if lb == '': if retrlen is None or retrlen == 0: - raise RangeError('Requested Range Not Satisfiable due to unobtainable file length.') + raise RangeError('Requested Range Not Satisfiable due' + ' to unobtainable file length.') lb = retrlen retrlen = lb - fb if retrlen < 0:
--- a/mercurial/changegroup.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/changegroup.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import util
--- a/mercurial/changelog.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/changelog.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import bin, hex, nullid from i18n import _ @@ -78,7 +78,7 @@ doff = self.offset - self.size self.data.insert(0, "".join(self.data)) del self.data[1:] - s = self.data[0][doff:doff+count] + s = self.data[0][doff:doff + count] self.offset += len(s) ret += s return ret
--- a/mercurial/cmdutil.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/cmdutil.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import hex, nullid, nullrev, short from i18n import _ @@ -93,7 +93,8 @@ limit = int(limit) except ValueError: raise util.Abort(_('limit must be a positive integer')) - if limit <= 0: raise util.Abort(_('limit must be positive')) + if limit <= 0: + raise util.Abort(_('limit must be positive')) else: limit = None return limit @@ -166,7 +167,7 @@ start = revfix(repo, start, 0) end = revfix(repo, end, len(repo) - 1) step = start > end and -1 or 1 - for rev in xrange(start, end+step, step): + for rev in xrange(start, end + step, step): if rev in seen: continue seen.add(rev) @@ -569,21 +570,21 @@ if opts['daemon'] and not opts['daemon_pipefds']: # Signal child process startup with file removal lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') - os.close(lockfd) + os.close(lockfd) try: if not runargs: runargs = util.hgcmd() + sys.argv[1:] runargs.append('--daemon-pipefds=%s' % lockpath) # Don't pass --cwd to the child process, because we've already # changed directory. - for i in xrange(1,len(runargs)): + for i in xrange(1, len(runargs)): if runargs[i].startswith('--cwd='): del runargs[i] break elif runargs[i].startswith('--cwd'): - del runargs[i:i+2] + del runargs[i:i + 2] break - pid = util.spawndetached(runargs) + pid = util.spawndetached(runargs) while os.path.exists(lockpath): time.sleep(0.1) finally: @@ -806,10 +807,11 @@ # causes unexpected behaviours at templating level and makes # it harder to extract it in a standalone function. Its # behaviour cannot be changed so leave it here for now. - def showparents(repo, ctx, templ, **args): + def showparents(**args): + ctx = args['ctx'] parents = [[('rev', p.rev()), ('node', p.hex())] for p in self._meaningful_parentrevs(ctx)] - return showlist(templ, 'parent', parents, **args) + return showlist('parent', parents, **args) props = props.copy() props.update(templatekw.keywords) @@ -902,13 +904,15 @@ if not os.path.split(mapfile)[0]: mapname = (templater.templatepath('map-cmdline.' + mapfile) or templater.templatepath(mapfile)) - if mapname: mapfile = mapname + if mapname: + mapfile = mapname try: t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0]) - if tmpl: t.use_template(tmpl) + if tmpl: + t.use_template(tmpl) return t def finddate(ui, repo, date): @@ -950,13 +954,13 @@ def increasing_windows(start, end, windowsize=8, sizelimit=512): if start < end: while start < end: - yield start, min(windowsize, end-start) + yield start, min(windowsize, end - start) start += windowsize if windowsize < sizelimit: windowsize *= 2 else: while start > end: - yield start, min(windowsize, start-end-1) + yield start, min(windowsize, start - end - 1) start -= windowsize if windowsize < sizelimit: windowsize *= 2 @@ -1013,7 +1017,8 @@ # A zero count may be a directory or deleted file, so # try to find matching entries on the slow path. if follow: - raise util.Abort(_('cannot follow nonexistent file: "%s"') % file_) + raise util.Abort( + _('cannot follow nonexistent file: "%s"') % file_) slowpath = True break else: @@ -1087,7 +1092,7 @@ rev = repo.changelog.rev(repo.lookup(rev)) ff = followfilter() stop = min(revs[0], revs[-1]) - for x in xrange(rev, stop-1, -1): + for x in xrange(rev, stop - 1, -1): if ff.match(x): wanted.discard(x) @@ -1102,7 +1107,7 @@ for i, window in increasing_windows(0, len(revs)): change = util.cachefunc(repo.changectx) - nrevs = [rev for rev in revs[i:i+window] if want(rev)] + nrevs = [rev for rev in revs[i:i + window] if want(rev)] for rev in sorted(nrevs): fns = fncache.get(rev) ctx = change(rev)
--- a/mercurial/commands.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/commands.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import hex, nullid, nullrev, short from lock import release @@ -34,7 +34,7 @@ names = [] m = cmdutil.match(repo, pats, opts) oldbad = m.bad - m.bad = lambda x,y: bad.append(x) or oldbad(x,y) + m.bad = lambda x, y: bad.append(x) or oldbad(x, y) for f in repo.walk(m): exact = m.exact(f) @@ -69,7 +69,7 @@ raise util.Abort(_('similarity must be a number')) if sim < 0 or sim > 100: raise util.Abort(_('similarity must be between 0 and 100')) - return cmdutil.addremove(repo, pats, opts, similarity=sim/100.) + return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0) def annotate(ui, repo, *pats, **opts): """show changeset information by line for each file @@ -98,8 +98,8 @@ ('follow', lambda x: x[0].path()), ] - if (not opts.get('user') and not opts.get('changeset') and not opts.get('date') - and not opts.get('follow')): + if (not opts.get('user') and not opts.get('changeset') + and not opts.get('date') and not opts.get('follow')): opts['number'] = 1 linenumber = opts.get('line_number') is not None @@ -173,7 +173,8 @@ if kind == 'files': raise util.Abort(_('cannot archive plain files to stdout')) dest = sys.stdout - if not prefix: prefix = os.path.basename(repo.root) + '-%h' + if not prefix: + prefix = os.path.basename(repo.root) + '-%h' prefix = cmdutil.make_filename(repo, prefix, node) archival.archive(repo, dest, node, kind, not opts.get('no_decode'), matchfn, prefix) @@ -257,7 +258,8 @@ if op1 != node: hg.clean(repo, op1, show_stats=False) if opts.get('merge'): - ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip())) + ui.status(_('merging with changeset %s\n') + % nice(repo.changelog.tip())) hg.merge(repo, hex(repo.changelog.tip())) else: ui.status(_('the backout changeset is a new head - ' @@ -868,11 +870,14 @@ if showdate: if ent[3] == -1: # Pad or slice to locale representation - locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0))) + locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", + time.localtime(0))) timestr = 'unset' - timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr)) + timestr = (timestr[:locale_len] + + ' ' * (locale_len - len(timestr))) else: - timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])) + timestr = time.strftime("%Y-%m-%d %H:%M:%S ", + time.localtime(ent[3])) if ent[1] & 020000: mode = 'lnk' else: @@ -884,7 +889,7 @@ def debugsub(ui, repo, rev=None): if rev == '': rev = None - for k,v in sorted(repo[rev].substate.items()): + for k, v in sorted(repo[rev].substate.items()): ui.write('path %s\n' % k) ui.write(' source %s\n' % v[0]) ui.write(' revision %s\n' % v[1]) @@ -1428,7 +1433,8 @@ bheads = repo.branchheads(branch, start, closed=closed) if not bheads: if not opts.get('rev'): - ui.warn(_("no open branch heads on branch %s\n") % encodedbranch) + ui.warn(_("no open branch heads on branch %s\n") + % encodedbranch) elif branch != branchrev: ui.warn(_("no changes on branch %s containing %s are " "reachable from %s\n") @@ -1640,7 +1646,8 @@ for title, options in option_lists: opt_output.append(("\n%s" % title, None)) for shortopt, longopt, default, desc in options: - if _("DEPRECATED") in desc and not ui.verbose: continue + if _("DEPRECATED") in desc and not ui.verbose: + continue opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, longopt and " --%s" % longopt), "%s%s" % (desc, @@ -1851,7 +1858,8 @@ patch.patch(tmpname, ui, strip=strip, cwd=repo.root, files=files, eolmode=None) finally: - files = patch.updatedir(ui, repo, files, similarity=sim/100.) + files = patch.updatedir(ui, repo, files, + similarity=sim / 100.0) if not opts.get('no_commit'): m = cmdutil.matchfiles(repo, files or []) n = repo.commit(message, opts.get('user') or user, @@ -1976,7 +1984,7 @@ ret = 1 m = cmdutil.match(repo, pats, opts, default='relglob') - m.bad = lambda x,y: False + m.bad = lambda x, y: False for abs in repo[rev].walk(m): if not rev and abs not in repo.dirstate: continue @@ -2168,7 +2176,8 @@ """ limit = cmdutil.loglimit(opts) dest, revs, checkout = hg.parseurl( - ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) + ui.expandpath(dest or 'default-push', dest or 'default'), + opts.get('rev')) if revs: revs = [repo.lookup(rev) for rev in revs] @@ -2324,7 +2333,8 @@ URLs. If DESTINATION is omitted, a default path will be used. """ dest, revs, checkout = hg.parseurl( - ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) + ui.expandpath(dest or 'default-push', dest or 'default'), + opts.get('rev')) other = hg.repository(cmdutil.remoteui(repo, opts), dest) ui.status(_('pushing to %s\n') % url.hidepassword(dest)) if revs: @@ -2561,7 +2571,7 @@ # walk dirstate. m = cmdutil.match(repo, pats, opts) - m.bad = lambda x,y: False + m.bad = lambda x, y: False for abs in repo.walk(m): names[abs] = m.rel(abs), m.exact(abs) @@ -2634,7 +2644,8 @@ msg = msg(abs) ui.status(msg % rel) for table, hitlist, misslist, backuphit, backupmiss in disptable: - if abs not in table: continue + if abs not in table: + continue # file has changed in dirstate if mfentry: handle(hitlist, backuphit) @@ -2650,7 +2661,8 @@ continue # file has not changed in dirstate if node == parent: - if exact: ui.warn(_('no changes needed to %s\n') % rel) + if exact: + ui.warn(_('no changes needed to %s\n') % rel) continue if pmf is None: # only need parent manifest in this unlikely case, @@ -2782,7 +2794,8 @@ util.set_signal_handler() self.httpd = server.create_server(baseui, repo) - if not ui.verbose: return + if not ui.verbose: + return if self.httpd.prefix: prefix = self.httpd.prefix.strip('/') + '/' @@ -2939,11 +2952,12 @@ _('%d deleted'), _('%d unknown'), _('%d ignored'), _('%d unresolved')] t = [] - for s,l in zip(st, labels): + for s, l in zip(st, labels): if s: t.append(l % len(s)) t = ', '.join(t) + cleanworkdir = False if len(parents) > 1: t += _(' (merge)') @@ -2951,10 +2965,11 @@ t += _(' (new branch)') elif (not st[0] and not st[1] and not st[2]): t += _(' (clean)') + cleanworkdir = True elif pnode not in bheads: t += _(' (new branch head)') - if 'clean' in t: + if cleanworkdir: ui.status(_('commit: %s\n') % t.strip()) else: ui.write(_('commit: %s\n') % t.strip()) @@ -3461,7 +3476,8 @@ [('0', 'print0', None, _('end fields with NUL')), ('', 'all', None, _('print all revisions that match')), ('f', 'follow', None, - _('follow changeset history, or file history across copies and renames')), + _('follow changeset history,' + ' or file history across copies and renames')), ('i', 'ignore-case', None, _('ignore case when matching')), ('l', 'files-with-matches', None, _('print only filenames and revisions that match')), @@ -3497,7 +3513,8 @@ ('b', 'base', '', _('base path')), ('f', 'force', None, _('skip check for outstanding uncommitted changes')), - ('', 'no-commit', None, _("don't commit, just update the working directory")), + ('', 'no-commit', None, + _("don't commit, just update the working directory")), ('', 'exact', None, _('apply patch to the nodes from which it was generated')), ('', 'import-branch', None, @@ -3531,7 +3548,8 @@ "^log|history": (log, [('f', 'follow', None, - _('follow changeset history, or file history across copies and renames')), + _('follow changeset history,' + ' or file history across copies and renames')), ('', 'follow-first', None, _('only follow the first parent of merge changesets')), ('d', 'date', '', _('show revisions matching date spec')), @@ -3543,7 +3561,8 @@ ('u', 'user', [], _('revisions committed by user')), ('b', 'only-branch', [], _('show only changesets within the given named branch')), - ('P', 'prune', [], _('do not display revision or any of its ancestors')), + ('P', 'prune', [], + _('do not display revision or any of its ancestors')), ] + logopts + walkopts, _('[OPTION]... [FILE]')), "manifest": @@ -3630,8 +3649,10 @@ ('', 'daemon-pipefds', '', _('used internally by daemon mode')), ('E', 'errorlog', '', _('name of error log file to write to')), ('p', 'port', 0, _('port to listen on (default: 8000)')), - ('a', 'address', '', _('address to listen on (default: all interfaces)')), - ('', 'prefix', '', _('prefix path to serve from (default: server root)')), + ('a', 'address', '', + _('address to listen on (default: all interfaces)')), + ('', 'prefix', '', + _('prefix path to serve from (default: server root)')), ('n', 'name', '', _('name to show in web pages (default: working directory)')), ('', 'webdir-conf', '', _('name of the webdir config file'
--- a/mercurial/config.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/config.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import error @@ -73,10 +73,10 @@ def parse(self, src, data, sections=None, remap=None, include=None): sectionre = re.compile(r'\[([^\[]+)\]') itemre = re.compile(r'([^=\s][^=]*?)\s*=\s*(.*\S|)') - contre = re.compile(r'\s+(\S.*\S)') + contre = re.compile(r'\s+(\S|\S.*\S)\s*$') emptyre = re.compile(r'(;|#|\s*$)') unsetre = re.compile(r'%unset\s+(\S+)') - includere = re.compile(r'%include\s+(\S.*\S)') + includere = re.compile(r'%include\s+(\S|\S.*\S)\s*$') section = "" item = None line = 0
--- a/mercurial/context.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/context.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import nullid, nullrev, short, hex from i18n import _ @@ -87,20 +87,33 @@ for f in sorted(self._manifest): yield f - def changeset(self): return self._changeset - def manifest(self): return self._manifest - def manifestnode(self): return self._changeset[0] + def changeset(self): + return self._changeset + def manifest(self): + return self._manifest + def manifestnode(self): + return self._changeset[0] - def rev(self): return self._rev - def node(self): return self._node - def hex(self): return hex(self._node) - def user(self): return self._changeset[1] - def date(self): return self._changeset[2] - def files(self): return self._changeset[3] - def description(self): return self._changeset[4] - def branch(self): return self._changeset[5].get("branch") - def extra(self): return self._changeset[5] - def tags(self): return self._repo.nodetags(self._node) + def rev(self): + return self._rev + def node(self): + return self._node + def hex(self): + return hex(self._node) + def user(self): + return self._changeset[1] + def date(self): + return self._changeset[2] + def files(self): + return self._changeset[3] + def description(self): + return self._changeset[4] + def branch(self): + return self._changeset[5].get("branch") + def extra(self): + return self._changeset[5] + def tags(self): + return self._repo.nodetags(self._node) def parents(self): """return contexts for each parent changeset""" @@ -283,10 +296,14 @@ return filectx(self._repo, self._path, fileid=fileid, filelog=self._filelog) - def filerev(self): return self._filerev - def filenode(self): return self._filenode - def flags(self): return self._changectx.flags(self._path) - def filelog(self): return self._filelog + def filerev(self): + return self._filerev + def filenode(self): + return self._filenode + def flags(self): + return self._changectx.flags(self._path) + def filelog(self): + return self._filelog def rev(self): if '_changectx' in self.__dict__: @@ -295,23 +312,38 @@ return self._changectx.rev() return self._filelog.linkrev(self._filerev) - def linkrev(self): return self._filelog.linkrev(self._filerev) - def node(self): return self._changectx.node() - def hex(self): return hex(self.node()) - def user(self): return self._changectx.user() - def date(self): return self._changectx.date() - def files(self): return self._changectx.files() - def description(self): return self._changectx.description() - def branch(self): return self._changectx.branch() - def extra(self): return self._changectx.extra() - def manifest(self): return self._changectx.manifest() - def changectx(self): return self._changectx + def linkrev(self): + return self._filelog.linkrev(self._filerev) + def node(self): + return self._changectx.node() + def hex(self): + return hex(self.node()) + def user(self): + return self._changectx.user() + def date(self): + return self._changectx.date() + def files(self): + return self._changectx.files() + def description(self): + return self._changectx.description() + def branch(self): + return self._changectx.branch() + def extra(self): + return self._changectx.extra() + def manifest(self): + return self._changectx.manifest() + def changectx(self): + return self._changectx - def data(self): return self._filelog.read(self._filenode) - def path(self): return self._path - def size(self): return self._filelog.size(self._filerev) + def data(self): + return self._filelog.read(self._filenode) + def path(self): + return self._path + def size(self): + return self._filelog.size(self._filerev) - def cmp(self, text): return self._filelog.cmp(self._filenode, text) + def cmp(self, text): + return self._filelog.cmp(self._filenode, text) def renamed(self): """check if file was actually renamed in this changeset revision @@ -348,7 +380,7 @@ pl[0] = (r[0], r[1], None) return [filectx(self._repo, p, fileid=n, filelog=l) - for p,n,l in pl if n != nullid] + for p, n, l in pl if n != nullid] def children(self): # hard for renames @@ -493,6 +525,17 @@ return None + def ancestors(self): + seen = set(str(self)) + visit = [self] + while visit: + for parent in visit.pop(0).parents(): + s = str(parent) + if s not in seen: + visit.append(parent) + seen.add(s) + yield parent + class workingctx(changectx): """A workingctx object makes access to data related to the current working directory convenient. @@ -583,22 +626,33 @@ self._parents = [changectx(self._repo, x) for x in p] return self._parents - def manifest(self): return self._manifest - - def user(self): return self._user or self._repo.ui.username() - def date(self): return self._date - def description(self): return self._text + def manifest(self): + return self._manifest + def user(self): + return self._user or self._repo.ui.username() + def date(self): + return self._date + def description(self): + return self._text def files(self): return sorted(self._status[0] + self._status[1] + self._status[2]) - def modified(self): return self._status[0] - def added(self): return self._status[1] - def removed(self): return self._status[2] - def deleted(self): return self._status[3] - def unknown(self): return self._status[4] - def clean(self): return self._status[5] - def branch(self): return self._extra['branch'] - def extra(self): return self._extra + def modified(self): + return self._status[0] + def added(self): + return self._status[1] + def removed(self): + return self._status[2] + def deleted(self): + return self._status[3] + def unknown(self): + return self._status[4] + def clean(self): + return self._status[5] + def branch(self): + return self._extra['branch'] + def extra(self): + return self._extra def tags(self): t = [] @@ -674,7 +728,8 @@ def __str__(self): return "%s@%s" % (self.path(), self._changectx) - def data(self): return self._repo.wread(self._path) + def data(self): + return self._repo.wread(self._path) def renamed(self): rp = self._repo.dirstate.copied(self._path) if not rp: @@ -700,21 +755,24 @@ pl.append((path, filenode(pc, path), fl)) return [filectx(self._repo, p, fileid=n, filelog=l) - for p,n,l in pl if n != nullid] + for p, n, l in pl if n != nullid] def children(self): return [] - def size(self): return os.stat(self._repo.wjoin(self._path)).st_size + def size(self): + return os.stat(self._repo.wjoin(self._path)).st_size def date(self): t, tz = self._changectx.date() try: return (int(os.lstat(self._repo.wjoin(self._path)).st_mtime), tz) except OSError, err: - if err.errno != errno.ENOENT: raise + if err.errno != errno.ENOENT: + raise return (t, tz) - def cmp(self, text): return self._repo.wread(self._path) == text + def cmp(self, text): + return self._repo.wread(self._path) == text class memctx(object): """Use memctx to perform in-memory commits via localrepo.commitctx(). @@ -776,22 +834,37 @@ def __getitem__(self, key): return self.filectx(key) - def p1(self): return self._parents[0] - def p2(self): return self._parents[1] + def p1(self): + return self._parents[0] + def p2(self): + return self._parents[1] - def user(self): return self._user or self._repo.ui.username() - def date(self): return self._date - def description(self): return self._text - def files(self): return self.modified() - def modified(self): return self._status[0] - def added(self): return self._status[1] - def removed(self): return self._status[2] - def deleted(self): return self._status[3] - def unknown(self): return self._status[4] - def clean(self): return self._status[5] - def branch(self): return self._extra['branch'] - def extra(self): return self._extra - def flags(self, f): return self[f].flags() + def user(self): + return self._user or self._repo.ui.username() + def date(self): + return self._date + def description(self): + return self._text + def files(self): + return self.modified() + def modified(self): + return self._status[0] + def added(self): + return self._status[1] + def removed(self): + return self._status[2] + def deleted(self): + return self._status[3] + def unknown(self): + return self._status[4] + def clean(self): + return self._status[5] + def branch(self): + return self._extra['branch'] + def extra(self): + return self._extra + def flags(self, f): + return self[f].flags() def parents(self): """return contexts for each parent changeset""" @@ -821,11 +894,19 @@ if copied: self._copied = (copied, nullid) - def __nonzero__(self): return True - def __str__(self): return "%s@%s" % (self.path(), self._changectx) - def path(self): return self._path - def data(self): return self._data - def flags(self): return self._flags - def isexec(self): return 'x' in self._flags - def islink(self): return 'l' in self._flags - def renamed(self): return self._copied + def __nonzero__(self): + return True + def __str__(self): + return "%s@%s" % (self.path(), self._changectx) + def path(self): + return self._path + def data(self): + return self._data + def flags(self): + return self._flags + def isexec(self): + return 'x' in self._flags + def islink(self): + return 'l' in self._flags + def renamed(self): + return self._copied
--- a/mercurial/copies.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/copies.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import util @@ -28,27 +28,6 @@ f = _dirname(f) return d -def _findoldnames(fctx, limit): - "find files that path was copied from, back to linkrev limit" - old = {} - seen = set() - orig = fctx.path() - visit = [(fctx, 0)] - while visit: - fc, depth = visit.pop() - s = str(fc) - if s in seen: - continue - seen.add(s) - if fc.path() != orig and fc.path() not in old: - old[fc.path()] = (depth, fc.path()) # remember depth - if fc.rev() is not None and fc.rev() < limit: - continue - visit += [(p, depth - 1) for p in fc.parents()] - - # return old names sorted by depth - return [o[1] for o in sorted(old.values())] - def _findlimit(repo, a, b): """Find the earliest revision that's an ancestor of a or b but not both, None if no such revision exists. @@ -138,23 +117,50 @@ fullcopy = {} diverge = {} + def related(f1, f2, limit): + g1, g2 = f1.ancestors(), f2.ancestors() + try: + while 1: + f1r, f2r = f1.rev(), f2.rev() + if f1r > f2r: + f1 = g1.next() + elif f2r > f1r: + f2 = g2.next() + elif f1 == f2: + return f1 # a match + elif f1r == f2r or f1r < limit or f2r < limit: + return False # copy no longer relevant + except StopIteration: + return False + def checkcopies(f, m1, m2): '''check possible copies of f from m1 to m2''' - c1 = ctx(f, m1[f]) - for of in _findoldnames(c1, limit): + of = None + seen = set([f]) + for oc in ctx(f, m1[f]).ancestors(): + ocr = oc.rev() + of = oc.path() + if of in seen: + # check limit late - grab last rename before + if ocr < limit: + break + continue + seen.add(of) + fullcopy[f] = of # remember for dir rename detection - if of in m2: # original file not in other manifest? - # if the original file is unchanged on the other branch, - # no merge needed - if m2[of] != ma.get(of): - c2 = ctx(of, m2[of]) - ca = c1.ancestor(c2) - # related and named changed on only one side? - if ca and (ca.path() == f or ca.path() == c2.path()): - if c1 != ca or c2 != ca: # merge needed? - copy[f] = of - elif of in ma: - diverge.setdefault(of, []).append(f) + if of not in m2: + continue # no match, keep looking + if m2[of] == ma.get(of): + break # no merge needed, quit early + c2 = ctx(of, m2[of]) + cr = related(oc, c2, ca.rev()) + if cr and (cr.path() == f or cr.path == c2.path()): # non-divergent + copy[f] = of + of = None + break + + if of in ma: + diverge.setdefault(of, []).append(f) repo.ui.debug(" searching for copies back to rev %d\n" % limit) @@ -184,8 +190,10 @@ repo.ui.debug(" all copies found (* = to merge, ! = divergent):\n") for f in fullcopy: note = "" - if f in copy: note += "*" - if f in diverge2: note += "!" + if f in copy: + note += "*" + if f in diverge2: + note += "!" repo.ui.debug(" %s -> %s %s\n" % (f, fullcopy[f], note)) del diverge2
--- a/mercurial/demandimport.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/demandimport.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. ''' demandimport - automatic demandloading of modules
--- a/mercurial/diffhelpers.c Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/diffhelpers.c Thu Jan 28 23:13:45 2010 -0600 @@ -33,7 +33,7 @@ hline = PyString_FromStringAndSize(l, sz-1); if (c == ' ' || c == '+') { - PyObject *rline = PyString_FromStringAndSize(l+1, sz-2); + PyObject *rline = PyString_FromStringAndSize(l + 1, sz - 2); PyList_SetItem(b, blen-1, rline); } if (c == ' ' || c == '-') { @@ -74,13 +74,13 @@ if (!PyArg_ParseTuple(args, "OOiiOO", &fp, &hunk, &lena, &lenb, &a, &b)) return NULL; - while(1) { + while (1) { todoa = lena - PyList_Size(a); todob = lenb - PyList_Size(b); num = todoa > todob ? todoa : todob; if (num == 0) break; - for (i = 0 ; i < num ; i++) { + for (i = 0; i < num; i++) { x = PyFile_GetLine(fp, 0); s = PyString_AS_STRING(x); c = *s; @@ -135,10 +135,10 @@ if (alen > blen - bstart) { return Py_BuildValue("l", -1); } - for (i = 0 ; i < alen ; i++) { + for (i = 0; i < alen; i++) { sa = PyString_AS_STRING(PyList_GET_ITEM(a, i)); sb = PyString_AS_STRING(PyList_GET_ITEM(b, i + bstart)); - if (strcmp(sa+1, sb) != 0) + if (strcmp(sa + 1, sb) != 0) return Py_BuildValue("l", -1); } return Py_BuildValue("l", 0);
--- a/mercurial/dirstate.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/dirstate.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import nullid from i18n import _ @@ -87,13 +87,14 @@ elif l > 0 and l < 40: raise util.Abort(_('working directory state appears damaged!')) except IOError, err: - if err.errno != errno.ENOENT: raise + if err.errno != errno.ENOENT: + raise return [nullid, nullid] @propertycache def _dirs(self): dirs = {} - for f,s in self._map.iteritems(): + for f, s in self._map.iteritems(): if s[0] != 'r': _incdirs(dirs, f) return dirs @@ -157,7 +158,8 @@ def getcwd(self): cwd = os.getcwd() - if cwd == self._root: return '' + if cwd == self._root: + return '' # self._root ends with a path separator if self._root is '/' or 'C:\' rootsep = self._root if not util.endswithsep(rootsep): @@ -215,7 +217,8 @@ try: st = self._opener("dirstate").read() except IOError, err: - if err.errno != errno.ENOENT: raise + if err.errno != errno.ENOENT: + raise return if not st: return @@ -440,11 +443,16 @@ def badtype(mode): kind = _('unknown') - if stat.S_ISCHR(mode): kind = _('character device') - elif stat.S_ISBLK(mode): kind = _('block device') - elif stat.S_ISFIFO(mode): kind = _('fifo') - elif stat.S_ISSOCK(mode): kind = _('socket') - elif stat.S_ISDIR(mode): kind = _('directory') + if stat.S_ISCHR(mode): + kind = _('character device') + elif stat.S_ISBLK(mode): + kind = _('block device') + elif stat.S_ISFIFO(mode): + kind = _('fifo') + elif stat.S_ISSOCK(mode): + kind = _('socket') + elif stat.S_ISDIR(mode): + kind = _('directory') return _('unsupported file type (type is %s)') % kind ignore = self._ignore
--- a/mercurial/dispatch.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/dispatch.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import os, sys, atexit, signal, pdb, socket, errno, shlex, time @@ -35,7 +35,8 @@ for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': num = getattr(signal, name, None) - if num: signal.signal(num, catchterm) + if num: + signal.signal(num, catchterm) try: try:
--- a/mercurial/encoding.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/encoding.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import error import sys, unicodedata, locale, os @@ -62,7 +62,7 @@ try: return s.decode(encoding, encodingmode).encode("utf-8") except UnicodeDecodeError, inst: - sub = s[max(0, inst.start-10):inst.start+10] + sub = s[max(0, inst.start - 10):inst.start + 10] raise error.Abort("decoding near '%s': %s!" % (sub, inst)) except LookupError, k: raise error.Abort("%s, please check your locale settings" % k)
--- a/mercurial/error.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/error.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2008 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """Mercurial exceptions.
--- a/mercurial/extensions.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/extensions.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import imp, os import util, cmdutil, help
--- a/mercurial/fancyopts.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/fancyopts.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import getopt @@ -16,7 +16,7 @@ extraargs = [] if '--' in args: stopindex = args.index('--') - extraargs = args[stopindex+1:] + extraargs = args[stopindex + 1:] args = args[:stopindex] opts, parseargs = getopt.getopt(args, options, longoptions) args = [] @@ -77,8 +77,10 @@ # does it take a parameter? if not (default is None or default is True or default is False): - if short: short += ':' - if oname: oname += '=' + if short: + short += ':' + if oname: + oname += '=' if short: shortlist += short if name:
--- a/mercurial/filelog.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/filelog.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import revlog @@ -17,7 +17,7 @@ if not t.startswith('\1\n'): return t s = t.index('\1\n', 2) - return t[s+2:] + return t[s + 2:] def _readmeta(self, node): t = self.revision(node)
--- a/mercurial/filemerge.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/filemerge.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import short from i18n import _ @@ -65,19 +65,19 @@ # then merge tools tools = {} - for k,v in ui.configitems("merge-tools"): + for k, v in ui.configitems("merge-tools"): t = k.split('.')[0] if t not in tools: tools[t] = int(_toolstr(ui, t, "priority", "0")) names = tools.keys() - tools = sorted([(-p,t) for t,p in tools.items()]) + tools = sorted([(-p, t) for t, p in tools.items()]) uimerge = ui.config("ui", "merge") if uimerge: if uimerge not in names: return (uimerge, uimerge) tools.insert(0, (None, uimerge)) # highest priority tools.append((None, "hgmerge")) # the old default, if found - for p,t in tools: + for p, t in tools: if check(t, None, symlink, binary): toolpath = _findtool(ui, t) return (t, '"' + toolpath + '"')
--- a/mercurial/graphmod.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/graphmod.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2007 Joel Rosdahl <joel@rosdahl.net> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """supports walking the history as DAGs suitable for graphical output
--- a/mercurial/hbisect.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hbisect.py Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,7 @@ # Inspired by git bisect, extension skeleton taken from mq.py. # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os from i18n import _
--- a/mercurial/help.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/help.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import gettext, _ import sys, os @@ -13,17 +13,19 @@ def moduledoc(file): '''return the top-level python documentation for the given file - Loosely inspired by pydoc.source_synopsis(), but rewritten to handle \''' - as well as """ and to return the whole text instead of just the synopsis''' + Loosely inspired by pydoc.source_synopsis(), but rewritten to + handle triple quotes and to return the whole text instead of just + the synopsis''' result = [] line = file.readline() while line[:1] == '#' or not line.strip(): line = file.readline() - if not line: break + if not line: + break start = line[:3] - if start == '"""' or start == "'''": + if start == '\"\"\"' or start == "\'\'\'": line = line[3:] while line: if line.rstrip().endswith(start): @@ -83,11 +85,15 @@ (["config"], _("Configuration Files"), loaddoc('config')), (["dates"], _("Date Formats"), loaddoc('dates')), (["patterns"], _("File Name Patterns"), loaddoc('patterns')), - (['environment', 'env'], _('Environment Variables'), loaddoc('environment')), - (['revs', 'revisions'], _('Specifying Single Revisions'), loaddoc('revisions')), - (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'), loaddoc('multirevs')), + (['environment', 'env'], _('Environment Variables'), + loaddoc('environment')), + (['revs', 'revisions'], _('Specifying Single Revisions'), + loaddoc('revisions')), + (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'), + loaddoc('multirevs')), (['diffs'], _('Diff Formats'), loaddoc('diffs')), - (['templating', 'templates'], _('Template Usage'), loaddoc('templates')), + (['templating', 'templates'], _('Template Usage'), + loaddoc('templates')), (['urls'], _('URL Paths'), loaddoc('urls')), (["extensions"], _("Using additional features"), extshelp), )
--- a/mercurial/hg.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hg.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ from lock import release @@ -348,7 +348,8 @@ def clean(repo, node, show_stats=True): """forcibly switch the working directory to node, clobbering changes""" stats = _merge.update(repo, node, False, True, None) - if show_stats: _showstats(repo, stats) + if show_stats: + _showstats(repo, stats) return stats[3] > 0 def merge(repo, node, force=None, remind=True):
--- a/mercurial/hgweb/__init__.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/__init__.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import hgweb_mod, hgwebdir_mod
--- a/mercurial/hgweb/common.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/common.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import errno, mimetypes, os
--- a/mercurial/hgweb/hgweb_mod.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os from mercurial import ui, hg, hook, error, encoding, templater @@ -136,7 +136,7 @@ style = cmd.rfind('-') if style != -1: req.form['style'] = [cmd[:style]] - cmd = cmd[style+1:] + cmd = cmd[style + 1:] # avoid accepting e.g. style parameter as command if hasattr(webcommands, cmd):
--- a/mercurial/hgweb/hgwebdir_mod.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/hgwebdir_mod.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os, re, time from mercurial.i18n import _ @@ -324,7 +324,7 @@ style, mapfile = templater.stylemap(styles) if style == styles[0]: vars['style'] = style - + start = url[-1] == '?' and '&' or '?' sessionvars = webutil.sessionvars(vars, start) staticurl = config('web', 'staticurl') or url + 'static/'
--- a/mercurial/hgweb/protocol.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/protocol.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import cStringIO, zlib, tempfile, errno, os, sys, urllib, copy from mercurial import util, streamclone
--- a/mercurial/hgweb/request.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/request.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import socket, cgi, errno from mercurial import util @@ -25,7 +25,8 @@ 'static': [('cmd', ['static']), ('file', None)] } -def expand(form): +def normalize(form): + # first expand the shortcuts for k in shortcuts.iterkeys(): if k in form: for name, value in shortcuts[k]: @@ -33,6 +34,9 @@ value = form[k] form[name] = value del form[k] + # And strip the values + for k, v in form.iteritems(): + form[k] = [i.strip() for i in v] return form class wsgirequest(object): @@ -47,7 +51,9 @@ self.multiprocess = wsgienv['wsgi.multiprocess'] self.run_once = wsgienv['wsgi.run_once'] self.env = wsgienv - self.form = expand(cgi.parse(self.inp, self.env, keep_blank_values=1)) + self.form = normalize(cgi.parse(self.inp, + self.env, + keep_blank_values=1)) self._start_response = start_response self.server_write = None self.headers = []
--- a/mercurial/hgweb/server.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/server.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer, traceback from mercurial import hg, util, error
--- a/mercurial/hgweb/webcommands.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/webcommands.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os, mimetypes, re, cgi, copy import webutil @@ -228,7 +228,7 @@ start = max(0, pos - revcount + 1) end = min(count, start + revcount) pos = end - 1 - parity = paritygen(web.stripecount, offset=start-end) + parity = paritygen(web.stripecount, offset=start - end) changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx) @@ -334,7 +334,7 @@ emptydirs = [] h = dirs[d] while isinstance(h, dict) and len(h) == 1: - k,v = h.items()[0] + k, v = h.items()[0] if v: emptydirs.append(k) h = v @@ -378,9 +378,9 @@ return tmpl("tags", node=hex(web.repo.changelog.tip()), - entries=lambda **x: entries(False,0, **x), - entriesnotip=lambda **x: entries(True,0, **x), - latestentry=lambda **x: entries(True,1, **x)) + entries=lambda **x: entries(False, 0, **x), + entriesnotip=lambda **x: entries(True, 0, **x), + latestentry=lambda **x: entries(True, 1, **x)) def branches(web, req, tmpl): b = web.repo.branchtags() @@ -437,14 +437,14 @@ b = web.repo.branchtags() l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()] - for r,n,t in sorted(l): + for r, n, t in sorted(l): yield {'parity': parity.next(), 'branch': t, 'node': hex(n), 'date': web.repo[n].date()} def changelist(**map): - parity = paritygen(web.stripecount, offset=start-end) + parity = paritygen(web.stripecount, offset=start - end) l = [] # build a list in forward order for efficiency for i in xrange(start, end): ctx = web.repo[i] @@ -600,7 +600,7 @@ count = fctx.filerev() + 1 start = max(0, fctx.filerev() - revcount + 1) # first rev on this page end = min(count, start + revcount) # last rev on this page - parity = paritygen(web.stripecount, offset=start-end) + parity = paritygen(web.stripecount, offset=start - end) def entries(limit=0, **map): l = []
--- a/mercurial/hgweb/webutil.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/webutil.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os, copy from mercurial import match, patch, util, error @@ -59,7 +59,7 @@ yield {"label": label, "node": node} return f - return (dict(before=gen(navbefore), after=gen(navafter)), ) + return (dict(before=gen(navbefore), after=gen(navafter)),) def _siblings(siblings=[], hiderev=None): siblings = [s for s in siblings if s.node() != nullid]
--- a/mercurial/hgweb/wsgicgi.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hgweb/wsgicgi.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Eric Hopper <hopper@omnifarious.org> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # # This was originally copied from the public domain code at # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
--- a/mercurial/hook.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/hook.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import os, sys
--- a/mercurial/httprepo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/httprepo.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import bin, hex, nullid from i18n import _ @@ -107,9 +107,10 @@ proto.startswith('text/plain') or proto.startswith('application/hg-changegroup')): self.ui.debug("requested URL: '%s'\n" % url.hidepassword(cu)) - raise error.RepoError(_("'%s' does not appear to be an hg repository:\n" - "---%%<--- (%s)\n%s\n---%%<---\n") - % (safeurl, proto, resp.read())) + raise error.RepoError( + _("'%s' does not appear to be an hg repository:\n" + "---%%<--- (%s)\n%s\n---%%<---\n") + % (safeurl, proto, resp.read())) if proto.startswith('application/mercurial-'): try: @@ -171,7 +172,7 @@ n = " ".join(map(hex, nodes)) d = self.do_read("branches", nodes=n) try: - br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] + br = [tuple(map(bin, b.split(" "))) for b in d.splitlines()] return br except: raise error.ResponseError(_("unexpected response:"), d) @@ -183,7 +184,8 @@ n = " ".join(["-".join(map(hex, p)) for p in pairs[i:i + batch]]) d = self.do_read("between", pairs=n) try: - r += [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] + r += [l and map(bin, l.split(" ")) or [] + for l in d.splitlines()] except: raise error.ResponseError(_("unexpected response:"), d) return r
--- a/mercurial/i18n.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/i18n.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import encoding import gettext, sys, os
--- a/mercurial/ignore.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/ignore.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import util, match
--- a/mercurial/keepalive.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/keepalive.py Thu Jan 28 23:13:45 2010 -0600 @@ -120,7 +120,8 @@ DEBUG = None import sys -if sys.version_info < (2, 4): HANDLE_ERRORS = 1 +if sys.version_info < (2, 4): + HANDLE_ERRORS = 1 else: HANDLE_ERRORS = 0 class ConnectionManager: @@ -137,7 +138,8 @@ def add(self, host, connection, ready): self._lock.acquire() try: - if not host in self._hostmap: self._hostmap[host] = [] + if not host in self._hostmap: + self._hostmap[host] = [] self._hostmap[host].append(connection) self._connmap[connection] = host self._readymap[connection] = ready @@ -160,8 +162,10 @@ self._lock.release() def set_ready(self, connection, ready): - try: self._readymap[connection] = ready - except KeyError: pass + try: + self._readymap[connection] = ready + except KeyError: + pass def get_ready_conn(self, host): conn = None @@ -214,7 +218,8 @@ self._cm.set_ready(connection, 1) def _remove_connection(self, host, connection, close=0): - if close: connection.close() + if close: + connection.close() self._cm.remove(connection) #### Transaction Execution @@ -233,7 +238,8 @@ # if this response is non-None, then it worked and we're # done. Break out, skipping the else block. - if r: break + if r: + break # connection is bad - possibly closed by server # discard it and ask for the next free connection @@ -243,8 +249,9 @@ else: # no (working) free connections were found. Create a new one. h = http_class(host) - if DEBUG: DEBUG.info("creating new connection to %s (%d)", - host, id(h)) + if DEBUG: + DEBUG.info("creating new connection to %s (%d)", + host, id(h)) self._cm.add(host, h, 0) self._start_transaction(h, req) r = h.getresponse() @@ -252,9 +259,11 @@ raise urllib2.URLError(err) # if not a persistent connection, don't try to reuse it - if r.will_close: self._cm.remove(h) + if r.will_close: + self._cm.remove(h) - if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason) + if DEBUG: + DEBUG.info("STATUS: %s, %s", r.status, r.reason) r._handler = self r._host = host r._url = req.get_full_url() @@ -293,8 +302,9 @@ # same exception was raised, etc. The tradeoff is # that it's now possible this call will raise # a DIFFERENT exception - if DEBUG: DEBUG.error("unexpected exception - closing " + \ - "connection to %s (%d)", host, id(h)) + if DEBUG: + DEBUG.error("unexpected exception - closing " + "connection to %s (%d)", host, id(h)) self._cm.remove(h) h.close() raise @@ -304,11 +314,13 @@ # bad header back. This is most likely to happen if # the socket has been closed by the server since we # last used the connection. - if DEBUG: DEBUG.info("failed to re-use connection to %s (%d)", - host, id(h)) + if DEBUG: + DEBUG.info("failed to re-use connection to %s (%d)", + host, id(h)) r = None else: - if DEBUG: DEBUG.info("re-using connection to %s (%d)", host, id(h)) + if DEBUG: + DEBUG.info("re-using connection to %s (%d)", host, id(h)) return r @@ -319,7 +331,7 @@ if sys.version_info >= (2, 4): headers.update(req.unredirected_hdrs) headers.update(self.parent.addheaders) - headers = dict((n.lower(), v) for n,v in headers.items()) + headers = dict((n.lower(), v) for n, v in headers.items()) skipheaders = {} for n in ('host', 'accept-encoding'): if n in headers: @@ -477,13 +489,18 @@ i = self._rbuf.find('\n') while i < 0 and not (0 < limit <= len(self._rbuf)): new = self._raw_read(self._rbufsize) - if not new: break + if not new: + break i = new.find('\n') - if i >= 0: i = i + len(self._rbuf) + if i >= 0: + i = i + len(self._rbuf) self._rbuf = self._rbuf + new - if i < 0: i = len(self._rbuf) - else: i = i+1 - if 0 <= limit < len(self._rbuf): i = limit + if i < 0: + i = len(self._rbuf) + else: + i = i + 1 + if 0 <= limit < len(self._rbuf): + i = limit data, self._rbuf = self._rbuf[:i], self._rbuf[i:] return data @@ -492,7 +509,8 @@ list = [] while 1: line = self.readline() - if not line: break + if not line: + break list.append(line) total += len(line) if sizehint and total >= sizehint: @@ -528,9 +546,10 @@ if self.debuglevel > 0: print "send:", repr(str) try: - blocksize=8192 + blocksize = 8192 if hasattr(str,'read') : - if self.debuglevel > 0: print "sendIng a read()able" + if self.debuglevel > 0: + print "sendIng a read()able" data=str.read(blocksize) while data: self.sock.sendall(data) @@ -588,8 +607,10 @@ fo = urllib2.urlopen(url) fo.read() fo.close() - try: status, reason = fo.status, fo.reason - except AttributeError: status, reason = None, None + try: + status, reason = fo.status, fo.reason + except AttributeError: + status, reason = None, None except IOError, e: print " EXCEPTION: %s" % e raise @@ -635,7 +656,8 @@ foo = '' while 1: f = fo.readline() - if f: foo = foo + f + if f: + foo = foo + f else: break fo.close() m = md5.new(foo) @@ -657,14 +679,15 @@ urllib2.install_opener(opener) t2 = fetch(N, url) print ' TIME: %.3f s' % t2 - print ' improvement factor: %.2f' % (t1/t2, ) + print ' improvement factor: %.2f' % (t1 / t2) def fetch(N, url, delay=0): import time lens = [] starttime = time.time() for i in range(N): - if delay and i > 0: time.sleep(delay) + if delay and i > 0: + time.sleep(delay) fo = urllib2.urlopen(url) foo = fo.read() fo.close() @@ -683,7 +706,8 @@ global DEBUG dbbackup = DEBUG class FakeLogger: - def debug(self, msg, *args): print msg % args + def debug(self, msg, *args): + print msg % args info = warning = error = debug DEBUG = FakeLogger() print " fetching the file to establish a connection"
--- a/mercurial/localrepo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/localrepo.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import bin, hex, nullid, nullrev, short from i18n import _ @@ -319,7 +319,7 @@ # TODO: rename this function? tiprev = len(self) - 1 if lrev != tiprev: - self._updatebranchcache(partial, lrev+1, tiprev+1) + self._updatebranchcache(partial, lrev + 1, tiprev + 1) self._writebranchcache(partial, self.changelog.tip(), tiprev) return partial @@ -377,7 +377,8 @@ # invalidate the cache raise ValueError('invalidating branch cache (tip differs)') for l in lines: - if not l: continue + if not l: + continue node, label = l.split(" ", 1) partial.setdefault(label.strip(), []).append(bin(node)) except KeyboardInterrupt: @@ -562,7 +563,8 @@ # abort here if the journal already exists if os.path.exists(self.sjoin("journal")): - raise error.RepoError(_("abandoned transaction found - run hg recover")) + raise error.RepoError( + _("abandoned transaction found - run hg recover")) # save dirstate for rollback try: @@ -587,7 +589,8 @@ try: if os.path.exists(self.sjoin("journal")): self.ui.status(_("rolling back interrupted transaction\n")) - transaction.rollback(self.sopener, self.sjoin("journal"), self.ui.warn) + transaction.rollback(self.sopener, self.sjoin("journal"), + self.ui.warn) self.invalidate() return True else: @@ -603,7 +606,8 @@ lock = self.lock() if os.path.exists(self.sjoin("undo")): self.ui.status(_("rolling back last transaction\n")) - transaction.rollback(self.sopener, self.sjoin("undo"), self.ui.warn) + transaction.rollback(self.sopener, self.sjoin("undo"), + self.ui.warn) util.rename(self.join("undo.dirstate"), self.join("dirstate")) try: branch = self.opener("undo.branch").read() @@ -1339,7 +1343,7 @@ self.ui.debug("request %d: %s\n" % (reqcnt, " ".join(map(short, r)))) for p in xrange(0, len(r), 10): - for b in remote.branches(r[p:p+10]): + for b in remote.branches(r[p:p + 10]): self.ui.debug("received %s:%s\n" % (short(b[0]), short(b[1]))) unknown.append(b) @@ -1609,7 +1613,8 @@ ret = self.prepush(remote, force, revs) if ret[0] is not None: cg, remote_heads = ret - if force: remote_heads = ['force'] + if force: + remote_heads = ['force'] return remote.unbundle(cg, remote_heads, 'push') return ret[1]
--- a/mercurial/lock.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/lock.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import util, error import errno, os, socket, time
--- a/mercurial/mail.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/mail.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import util, encoding
--- a/mercurial/manifest.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/manifest.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import mdiff, parsers, error, revlog @@ -11,8 +11,10 @@ class manifestdict(dict): def __init__(self, mapping=None, flags=None): - if mapping is None: mapping = {} - if flags is None: flags = {} + if mapping is None: + mapping = {} + if flags is None: + flags = {} dict.__init__(self, mapping) self._flags = flags def flags(self, f): @@ -70,7 +72,7 @@ while lo < hi: mid = (lo + hi) // 2 start = mid - while start > 0 and m[start-1] != '\n': + while start > 0 and m[start - 1] != '\n': start -= 1 end = advance(start, '\0') if m[start:end] < s: @@ -85,7 +87,7 @@ if cmp(s, found) == 0: # we know that after the null there are 40 bytes of sha1 end = advance(end + 40, '\n') - return (lo, end+1) + return (lo, end + 1) else: return (lo, lo)
--- a/mercurial/match.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/match.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008, 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import re import util @@ -125,10 +125,11 @@ res = '' group = 0 escape = re.escape - def peek(): return i < n and pat[i] + def peek(): + return i < n and pat[i] while i < n: c = pat[i] - i = i+1 + i += 1 if c not in '*?[{},\\': res += escape(c) elif c == '*':
--- a/mercurial/mdiff.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/mdiff.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import bdiff, mpatch, util @@ -96,7 +96,8 @@ return '\t\n' return '\n' - if not a and not b: return "" + if not a and not b: + return "" epoch = util.datestr((0, 0)) if not opts.text and (util.binary(a) or util.binary(b)): @@ -125,7 +126,8 @@ al = splitnewlines(a) bl = splitnewlines(b) l = list(bunidiff(a, b, al, bl, "a/" + fn1, "b/" + fn2, opts=opts)) - if not l: return "" + if not l: + return "" # difflib uses a space, rather than a tab l[0] = "%s%s" % (l[0][:-2], datetag(ad)) l[1] = "%s%s" % (l[1][:-2], datetag(bd)) @@ -182,7 +184,7 @@ for x in xrange(a2, aend): yield ' ' + l1[x] - header = [ "--- %s\t\n" % header1, "+++ %s\t\n" % header2 ] + header = ["--- %s\t\n" % header1, "+++ %s\t\n" % header2] if opts.showfunc: funcre = re.compile('\w') @@ -203,7 +205,7 @@ # in the file. If it starts later, old and new below will both be # empty and we'll continue to the next match. if i > 0: - s = diff[i-1] + s = diff[i - 1] else: s = [0, 0, 0, 0] delta = [] @@ -246,11 +248,11 @@ delta = hunk[4] else: # create a new hunk - hunk = [ astart, a2, bstart, b2, delta ] + hunk = [astart, a2, bstart, b2, delta] - delta[len(delta):] = [ ' ' + x for x in l1[astart:a1] ] - delta[len(delta):] = [ '-' + x for x in old ] - delta[len(delta):] = [ '+' + x for x in new ] + delta[len(delta):] = [' ' + x for x in l1[astart:a1]] + delta[len(delta):] = ['-' + x for x in old] + delta[len(delta):] = ['+' + x for x in new] if hunk: for x in yieldhunk(hunk, header):
--- a/mercurial/merge.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/merge.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import nullid, nullrev, hex, bin from i18n import _ @@ -135,8 +135,10 @@ _(" conflicting flags for %s\n" "(n)one, e(x)ec or sym(l)ink?") % f, (_("&None"), _("E&xec"), _("Sym&link")), 0) - if r == 1: return "x" # Exec - if r == 2: return "l" # Symlink + if r == 1: + return "x" # Exec + if r == 2: + return "l" # Symlink return "" if m and m != a: # changed from a to m return m
--- a/mercurial/minirst.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/minirst.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """simplified reStructuredText parser. @@ -78,9 +78,9 @@ # | indented literal block | # +---------------------------+ blocks[i]['type'] = 'paragraph' - if blocks[i]['lines'][-1].endswith('::') and i+1 < len(blocks): + if blocks[i]['lines'][-1].endswith('::') and i + 1 < len(blocks): indent = blocks[i]['indent'] - adjustment = blocks[i+1]['indent'] - indent + adjustment = blocks[i + 1]['indent'] - indent if blocks[i]['lines'] == ['::']: # Expanded form: remove block @@ -104,9 +104,9 @@ adjustment -= m.end() # Mark the following indented blocks. - while i+1 < len(blocks) and blocks[i+1]['indent'] > indent: - blocks[i+1]['type'] = 'literal' - blocks[i+1]['indent'] -= adjustment + while i + 1 < len(blocks) and blocks[i + 1]['indent'] > indent: + blocks[i + 1]['type'] = 'literal' + blocks[i + 1]['indent'] -= adjustment i += 1 i += 1 return blocks @@ -133,7 +133,7 @@ item (but only if singleline is True). """ line1 = lines[i] - line2 = i+1 < len(lines) and lines[i+1] or '' + line2 = i + 1 < len(lines) and lines[i + 1] or '' if not itemre.match(line1): return False if singleline: @@ -153,7 +153,7 @@ items.append(dict(type=type, lines=[], indent=blocks[i]['indent'])) items[-1]['lines'].append(line) - blocks[i:i+1] = items + blocks[i:i + 1] = items break i += 1 return blocks @@ -221,7 +221,7 @@ """ i = 1 while i < len(blocks): - if (blocks[i]['type'] == blocks[i-1]['type'] and + if (blocks[i]['type'] == blocks[i - 1]['type'] and blocks[i]['type'] in ('bullet', 'option', 'field', 'definition')): i += 1 else:
--- a/mercurial/mpatch.c Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/mpatch.c Thu Jan 28 23:13:45 2010 -0600 @@ -35,13 +35,13 @@ #endif #ifdef _WIN32 -# ifdef _MSC_VER +#ifdef _MSC_VER /* msvc 6.0 has problems */ -# define inline __inline +#define inline __inline typedef unsigned long uint32_t; -# else -# include <stdint.h> -# endif +#else +#include <stdint.h> +#endif static uint32_t ntohl(uint32_t x) { return ((x & 0x000000ffUL) << 24) | @@ -51,13 +51,13 @@ } #else /* not windows */ -# include <sys/types.h> -# if defined __BEOS__ && !defined __HAIKU__ -# include <ByteOrder.h> -# else -# include <arpa/inet.h> -# endif -# include <inttypes.h> +#include <sys/types.h> +#if defined __BEOS__ && !defined __HAIKU__ +#include <ByteOrder.h> +#else +#include <arpa/inet.h> +#endif +#include <inttypes.h> #endif static char mpatch_doc[] = "Efficient binary patching.";
--- a/mercurial/node.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/node.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import binascii
--- a/mercurial/osutil.c Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/osutil.c Thu Jan 28 23:13:45 2010 -0600 @@ -14,13 +14,13 @@ #include <string.h> #ifdef _WIN32 -# include <windows.h> -# include <io.h> +#include <windows.h> +#include <io.h> #else -# include <dirent.h> -# include <sys/stat.h> -# include <sys/types.h> -# include <unistd.h> +#include <dirent.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> #endif /* some platforms lack the PATH_MAX definition (eg. GNU/Hurd) */ @@ -174,7 +174,7 @@ stp->st_mtime = to_python_time(&fd->ftLastWriteTime); stp->st_ctime = to_python_time(&fd->ftCreationTime); if (kind == _S_IFREG) - stp->st_size = ((__int64)fd->nFileSizeHigh << 32) + stp->st_size = ((__int64)fd->nFileSizeHigh << 32) + fd->nFileSizeLow; return Py_BuildValue("siN", fd->cFileName, kind, py_st); @@ -189,7 +189,7 @@ char *pattern; /* build the path + \* pattern string */ - pattern = malloc(plen+3); /* path + \* + \0 */ + pattern = malloc(plen + 3); /* path + \* + \0 */ if (!pattern) { PyErr_NoMemory(); goto error_nomem; @@ -485,7 +485,7 @@ goto bail; } - fd = _open_osfhandle((intptr_t) handle, flags); + fd = _open_osfhandle((intptr_t)handle, flags); if (fd == -1) { CloseHandle(handle); PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
--- a/mercurial/parsers.c Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/parsers.c Thu Jan 28 23:13:45 2010 -0600 @@ -131,14 +131,14 @@ } #ifdef _WIN32 -# ifdef _MSC_VER +#ifdef _MSC_VER /* msvc 6.0 has problems */ -# define inline __inline +#define inline __inline typedef unsigned long uint32_t; typedef unsigned __int64 uint64_t; -# else -# include <stdint.h> -# endif +#else +#include <stdint.h> +#endif static uint32_t ntohl(uint32_t x) { return ((x & 0x000000ffUL) << 24) | @@ -148,13 +148,13 @@ } #else /* not windows */ -# include <sys/types.h> -# if defined __BEOS__ && !defined __HAIKU__ -# include <ByteOrder.h> -# else -# include <arpa/inet.h> -# endif -# include <inttypes.h> +#include <sys/types.h> +#if defined __BEOS__ && !defined __HAIKU__ +#include <ByteOrder.h> +#else +#include <arpa/inet.h> +#endif +#include <inttypes.h> #endif static PyObject *parse_dirstate(PyObject *self, PyObject *args) @@ -303,16 +303,16 @@ if (n == 0) /* mask out version number for the first entry */ offset_flags &= 0xFFFF; else { - uint32_t offset_high = ntohl(*((uint32_t *) decode)); - offset_flags |= ((uint64_t) offset_high) << 32; + uint32_t offset_high = ntohl(*((uint32_t *)decode)); + offset_flags |= ((uint64_t)offset_high) << 32; } - comp_len = ntohl(*((uint32_t *) (decode + 8))); - uncomp_len = ntohl(*((uint32_t *) (decode + 12))); - base_rev = ntohl(*((uint32_t *) (decode + 16))); - link_rev = ntohl(*((uint32_t *) (decode + 20))); - parent_1 = ntohl(*((uint32_t *) (decode + 24))); - parent_2 = ntohl(*((uint32_t *) (decode + 28))); + comp_len = ntohl(*((uint32_t *)(decode + 8))); + uncomp_len = ntohl(*((uint32_t *)(decode + 12))); + base_rev = ntohl(*((uint32_t *)(decode + 16))); + link_rev = ntohl(*((uint32_t *)(decode + 20))); + parent_1 = ntohl(*((uint32_t *)(decode + 24))); + parent_2 = ntohl(*((uint32_t *)(decode + 28))); c_node_id = decode + 32; entry = _build_idx_entry(nodemap, n, offset_flags,
--- a/mercurial/patch.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/patch.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2007 Chris Mason <chris.mason@oracle.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ from node import hex, nullid, short @@ -78,7 +78,7 @@ if subject.startswith('[PATCH'): pend = subject.find(']') if pend >= 0: - subject = subject[pend+1:].lstrip() + subject = subject[pend + 1:].lstrip() subject = subject.replace('\n\t', ' ') ui.debug('Subject: %s\n' % subject) if user: @@ -472,7 +472,7 @@ search_start = orig_start + self.skew for fuzzlen in xrange(3): - for toponly in [ True, False ]: + for toponly in [True, False]: old = h.old(fuzzlen, toponly) cand = self.findlines(old[0][1:], search_start) @@ -497,7 +497,7 @@ else: msg = _("Hunk #%d succeeded at %d %s" "(offset %d lines).\n") - f(msg % (h.number, l+1, fuzzstr, offset)) + f(msg % (h.number, l + 1, fuzzstr, offset)) return fuzzlen self.printfile(True) self.ui.warn(_("Hunk #%d FAILED at %d\n") % (h.number, orig_start)) @@ -508,7 +508,7 @@ def __init__(self, desc, num, lr, context, create=False, remove=False): self.number = num self.desc = desc - self.hunk = [ desc ] + self.hunk = [desc] self.a = [] self.b = [] self.starta = self.lena = None @@ -621,7 +621,7 @@ if l.startswith('\ '): s = self.b[-1][:-1] self.b[-1] = s - self.hunk[hunki-1] = s + self.hunk[hunki - 1] = s continue if not l: lr.push(l) @@ -650,7 +650,7 @@ elif h.startswith('-'): continue else: - self.hunk.insert(hunki-1, u) + self.hunk.insert(hunki - 1, u) break if not self.a: @@ -689,15 +689,15 @@ top = 0 bot = 0 hlen = len(self.hunk) - for x in xrange(hlen-1): + for x in xrange(hlen - 1): # the hunk starts with the @@ line, so use x+1 - if self.hunk[x+1][0] == ' ': + if self.hunk[x + 1][0] == ' ': top += 1 else: break if not toponly: - for x in xrange(hlen-1): - if self.hunk[hlen-bot-1][0] == ' ': + for x in xrange(hlen - 1): + if self.hunk[hlen - bot - 1][0] == ' ': bot += 1 else: break @@ -1025,11 +1025,13 @@ afile, bfile, first_hunk = values try: if sourcefile: - current_file = patchfile(ui, sourcefile, opener, eolmode=eolmode) + current_file = patchfile(ui, sourcefile, opener, + eolmode=eolmode) else: - current_file, missing = selectfile(afile, bfile, first_hunk, - strip) - current_file = patchfile(ui, current_file, opener, missing, eolmode) + current_file, missing = selectfile(afile, bfile, + first_hunk, strip) + current_file = patchfile(ui, current_file, opener, + missing, eolmode) except PatchError, err: ui.warn(str(err) + '\n') current_file, current_hunk = None, None @@ -1196,7 +1198,8 @@ try: return internalpatch(patchname, ui, strip, cwd, files, eolmode) except NoHunks: - patcher = util.find_exe('gpatch') or util.find_exe('patch') or 'patch' + patcher = (util.find_exe('gpatch') or util.find_exe('patch') + or 'patch') ui.debug('no valid hunks found; trying with %r instead\n' % patcher) if util.needbinarypatch(): @@ -1232,7 +1235,7 @@ l = len(text) i = 0 while i < l: - yield text[i:i+csize] + yield text[i:i + csize] i += csize tohash = gitindex(to) @@ -1460,7 +1463,7 @@ fp.write(chunk) for seqno, rev in enumerate(revs): - single(rev, seqno+1, fp) + single(rev, seqno + 1, fp) def diffstatdata(lines): filename, adds, removes = None, 0, 0 @@ -1495,7 +1498,7 @@ totaladds += adds totalremoves += removes maxname = max(maxname, len(filename)) - maxtotal = max(maxtotal, adds+removes) + maxtotal = max(maxtotal, adds + removes) if isbinary: hasbinary = True
--- a/mercurial/posix.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/posix.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import osutil
--- a/mercurial/pure/base85.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/pure/base85.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright (C) 2009 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import struct @@ -48,7 +48,7 @@ l = len(text) out = [] for i in range(0, len(text), 5): - chunk = text[i:i+5] + chunk = text[i:i + 5] acc = 0 for j, c in enumerate(chunk): try:
--- a/mercurial/pure/bdiff.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/pure/bdiff.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import struct, difflib @@ -33,13 +33,15 @@ a2end = a2 + l2 b2end = b2 + l2 if a1end == a2: - while a1end+shift < a2end and a[a1end+shift] == b[b1end+shift]: + while (a1end + shift < a2end and + a[a1end + shift] == b[b1end + shift]): shift += 1 elif b1end == b2: - while b1end+shift < b2end and a[a1end+shift] == b[b1end+shift]: + while (b1end + shift < b2end and + a[a1end + shift] == b[b1end + shift]): shift += 1 - yield a1, b1, l1+shift - prev = a2+shift, b2+shift, l2-shift + yield a1, b1, l1 + shift + prev = a2 + shift, b2 + shift, l2 - shift yield prev def bdiff(a, b):
--- a/mercurial/pure/diffhelpers.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/pure/diffhelpers.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. def addlines(fp, hunk, lena, lenb, a, b): while True:
--- a/mercurial/pure/mpatch.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/pure/mpatch.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import struct try: @@ -22,7 +22,8 @@ # temporary string buffers. def patches(a, bins): - if not bins: return a + if not bins: + return a plens = [len(x) for x in bins] pl = sum(plens) @@ -30,7 +31,8 @@ tl = bl + bl + pl # enough for the patches and two working texts b1, b2 = 0, bl - if not tl: return a + if not tl: + return a m = StringIO() def move(dest, src, count):
--- a/mercurial/pure/osutil.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/pure/osutil.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import os import stat as _stat @@ -11,13 +11,20 @@ posixfile = open def _mode_to_kind(mode): - if _stat.S_ISREG(mode): return _stat.S_IFREG - if _stat.S_ISDIR(mode): return _stat.S_IFDIR - if _stat.S_ISLNK(mode): return _stat.S_IFLNK - if _stat.S_ISBLK(mode): return _stat.S_IFBLK - if _stat.S_ISCHR(mode): return _stat.S_IFCHR - if _stat.S_ISFIFO(mode): return _stat.S_IFIFO - if _stat.S_ISSOCK(mode): return _stat.S_IFSOCK + if _stat.S_ISREG(mode): + return _stat.S_IFREG + if _stat.S_ISDIR(mode): + return _stat.S_IFDIR + if _stat.S_ISLNK(mode): + return _stat.S_IFLNK + if _stat.S_ISBLK(mode): + return _stat.S_IFBLK + if _stat.S_ISCHR(mode): + return _stat.S_IFCHR + if _stat.S_ISFIFO(mode): + return _stat.S_IFIFO + if _stat.S_ISSOCK(mode): + return _stat.S_IFSOCK return mode def listdir(path, stat=False, skip=None):
--- a/mercurial/pure/parsers.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/pure/parsers.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from mercurial.node import bin, nullid, nullrev from mercurial import util
--- a/mercurial/repair.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/repair.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2007 Matt Mackall # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import changegroup from node import nullrev, short
--- a/mercurial/repo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/repo.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import error
--- a/mercurial/revlog.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/revlog.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """Storage back-end for Mercurial. @@ -127,7 +127,7 @@ self.dataf = dataf self.s = struct.calcsize(indexformatng) self.datasize = size - self.l = size/self.s + self.l = size / self.s self.index = [None] * self.l self.map = {nullid: nullrev} self.allmap = 0 @@ -902,7 +902,7 @@ try: # hex(node)[:...] l = len(id) // 2 # grab an even number of digits - bin_id = bin(id[:l*2]) + bin_id = bin(id[:l * 2]) nl = [n for n in self.nodemap if n[:l] == bin_id] nl = [n for n in nl if hex(n).startswith(id)] if len(nl) > 0: @@ -1403,7 +1403,7 @@ return (dd, di) def files(self): - res = [ self.indexfile ] + res = [self.indexfile] if not self._inline: res.append(self.datafile) return res
--- a/mercurial/simplemerge.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/simplemerge.py Thu Jan 28 23:13:45 2010 -0600 @@ -50,7 +50,7 @@ def compare_range(a, astart, aend, b, bstart, bend): """Compare a[astart:aend] == b[bstart:bend], without slicing. """ - if (aend-astart) != (bend-bstart): + if (aend - astart) != (bend - bstart): return False for ia, ib in zip(xrange(astart, aend), xrange(bstart, bend)): if a[ia] != b[ib]: @@ -303,7 +303,7 @@ region_ib) if reg is not None: yield reg - yield 'same', region_ia, region_len+region_ia + yield 'same', region_ia, region_len + region_ia next_a = region_ia + region_len next_b = region_ib + region_len reg = self.mismatch_region(next_a, amatch, next_b, bmatch) @@ -336,7 +336,7 @@ # there is an unconflicted block at i; how long does it # extend? until whichever one ends earlier. - i = intersect((abase, abase+alen), (bbase, bbase+blen)) + i = intersect((abase, abase + alen), (bbase, bbase + blen)) if i: intbase = i[0] intend = i[1]
--- a/mercurial/sshrepo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/sshrepo.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import bin, hex from i18n import _ @@ -90,9 +90,11 @@ def readerr(self): while 1: size = util.fstat(self.pipee).st_size - if size == 0: break + if size == 0: + break l = self.pipee.readline() - if not l: break + if not l: + break self.ui.status(_("remote: "), l) def abort(self, exception): @@ -190,7 +192,7 @@ n = " ".join(map(hex, nodes)) d = self.call("branches", nodes=n) try: - br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] + br = [tuple(map(bin, b.split(" "))) for b in d.splitlines()] return br except: self.abort(error.ResponseError(_("unexpected response:"), d)) @@ -199,7 +201,7 @@ n = " ".join(["-".join(map(hex, p)) for p in pairs]) d = self.call("between", pairs=n) try: - p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] + p = [l and map(bin, l.split(" ")) or [] for l in d.splitlines()] return p except: self.abort(error.ResponseError(_("unexpected response:"), d))
--- a/mercurial/sshserver.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/sshserver.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ from node import bin, hex @@ -42,7 +42,8 @@ def serve_forever(self): try: - while self.serve_one(): pass + while self.serve_one(): + pass finally: if self.lock is not None: self.lock.release() @@ -52,7 +53,8 @@ cmd = self.fin.readline()[:-1] if cmd: impl = getattr(self, 'do_' + cmd, None) - if impl: impl() + if impl: + impl() else: self.respond("") return cmd != ''
--- a/mercurial/statichttprepo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/statichttprepo.py Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import changelog, byterange, url, error
--- a/mercurial/store.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/store.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2008 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import osutil, util @@ -32,7 +32,7 @@ def _buildencodefun(): e = '_' win_reserved = [ord(x) for x in '\\:*?"<>|'] - cmap = dict([ (chr(x), chr(x)) for x in xrange(127) ]) + cmap = dict([(chr(x), chr(x)) for x in xrange(127)]) for x in (range(32) + range(126, 256) + win_reserved): cmap[chr(x)] = "~%02x" % x for x in range(ord("A"), ord("Z")+1) + [ord(e)]: @@ -45,7 +45,7 @@ while i < len(s): for l in xrange(1, 4): try: - yield dmap[s[i:i+l]] + yield dmap[s[i:i + l]] i += l break except KeyError: @@ -59,7 +59,7 @@ def _build_lower_encodefun(): win_reserved = [ord(x) for x in '\\:*?"<>|'] - cmap = dict([ (chr(x), chr(x)) for x in xrange(127) ]) + cmap = dict([(chr(x), chr(x)) for x in xrange(127)]) for x in (range(32) + range(126, 256) + win_reserved): cmap[chr(x)] = "~%02x" % x for x in range(ord("A"), ord("Z")+1):
--- a/mercurial/streamclone.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/streamclone.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import util, error from i18n import _
--- a/mercurial/strutil.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/strutil.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. def findall(haystack, needle, start=0, end=None): if end is None:
--- a/mercurial/subrepo.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/subrepo.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,9 +3,9 @@ # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. -import errno, os, re +import errno, os, re, xml.dom.minidom from i18n import _ import config, util, node, error hg = None @@ -265,8 +265,8 @@ cmd = [util.shellquote(arg) for arg in cmd] cmd = util.quotecommand(' '.join(cmd)) env = dict(os.environ) - for k in ('LANGUAGE', 'LANG', 'LC_ALL', 'LC_MESSAGES'): - env[k] = 'en_US.UTF-8' + # Avoid localized output, preserve current locale for everything else. + env['LC_MESSAGES'] = 'C' write, read, err = util.popen3(cmd, env=env, newlines=True) retdata = read.read() err = err.read().strip() @@ -275,35 +275,52 @@ return retdata def _wcrev(self): - info = self._svncommand(['info']) - mat = re.search('Revision: ([\d]+)\n', info) - if not mat: + output = self._svncommand(['info', '--xml']) + doc = xml.dom.minidom.parseString(output) + entries = doc.getElementsByTagName('entry') + if not entries: return 0 - return mat.groups()[0] + return int(entries[0].getAttribute('revision') or 0) - def _url(self): - info = self._svncommand(['info']) - mat = re.search('URL: ([^\n]+)\n', info) - if not mat: - return 0 - return mat.groups()[0] - - def _wcclean(self): - status = self._svncommand(['status']) - status = '\n'.join([s for s in status.splitlines() if s[0] != '?']) - if status.strip(): - return False - return True + def _wcchanged(self): + """Return (changes, extchanges) where changes is True + if the working directory was changed, and extchanges is + True if any of these changes concern an external entry. + """ + output = self._svncommand(['status', '--xml']) + externals, changes = [], [] + doc = xml.dom.minidom.parseString(output) + for e in doc.getElementsByTagName('entry'): + s = e.getElementsByTagName('wc-status') + if not s: + continue + item = s[0].getAttribute('item') + props = s[0].getAttribute('props') + path = e.getAttribute('path') + if item == 'external': + externals.append(path) + if (item not in ('', 'normal', 'unversioned', 'external') + or props not in ('', 'none')): + changes.append(path) + for path in changes: + for ext in externals: + if path == ext or path.startswith(ext + os.sep): + return True, True + return bool(changes), False def dirty(self): - if self._wcrev() == self._state[1] and self._wcclean(): + if self._wcrev() == self._state[1] and not self._wcchanged()[0]: return False return True def commit(self, text, user, date): # user and date are out of our hands since svn is centralized - if self._wcclean(): + changed, extchanged = self._wcchanged() + if not changed: return self._wcrev() + if extchanged: + # Do not try to commit externals + raise util.Abort(_('cannot commit svn externals')) commitinfo = self._svncommand(['commit', '-m', text]) self._ui.status(commitinfo) newrev = re.search('Committed revision ([\d]+).', commitinfo)
--- a/mercurial/tags.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/tags.py Thu Jan 28 23:13:45 2010 -0600 @@ -4,7 +4,7 @@ # Copyright 2009 Greg Ward <greg@gerg.ca> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # Currently this module only deals with reading and caching tags. # Eventually, it could take care of updating (adding/removing/moving)
--- a/mercurial/templatefilters.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templatefilters.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2008 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import cgi, re, os, time, urllib, textwrap import util, encoding @@ -64,7 +64,8 @@ m = para_re.search(text, start) if not m: w = len(text) - while w > start and text[w-1].isspace(): w -= 1 + while w > start and text[w - 1].isspace(): + w -= 1 yield text[start:w], text[w:] break yield text[start:m.start(0)], m.group(1) @@ -91,17 +92,21 @@ def domain(author): '''get domain of author, or empty string if none.''' f = author.find('@') - if f == -1: return '' - author = author[f+1:] + if f == -1: + return '' + author = author[f + 1:] f = author.find('>') - if f >= 0: author = author[:f] + if f >= 0: + author = author[:f] return author def person(author): '''get name of author, or else username.''' - if not '@' in author: return author + if not '@' in author: + return author f = author.find('<') - if f == -1: return util.shortuser(author) + if f == -1: + return util.shortuser(author) return author[:f].rstrip() def indent(text, prefix):
--- a/mercurial/templatekw.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templatekw.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,12 +3,12 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import hex import encoding, patch, util, error -def showlist(templ, name, values, plural=None, **args): +def showlist(name, values, plural=None, **args): '''expand set of values. name is name of key in template map. values is list of strings or dicts. @@ -28,7 +28,9 @@ expand 'end_foos'. ''' - if plural: names = plural + templ = args['templ'] + if plural: + names = plural else: names = name + 's' if not values: noname = 'no_' + names @@ -143,11 +145,11 @@ def showauthor(repo, ctx, templ, **args): return ctx.user() -def showbranches(repo, ctx, templ, **args): - branch = ctx.branch() +def showbranches(**args): + branch = args['ctx'].branch() if branch != 'default': branch = encoding.tolocal(branch) - return showlist(templ, 'branch', [branch], plural='branches', **args) + return showlist('branch', [branch], plural='branches', **args) def showdate(repo, ctx, templ, **args): return ctx.date() @@ -164,46 +166,51 @@ removes += i[2] return '%s: +%s/-%s' % (files, adds, removes) -def showextras(repo, ctx, templ, **args): - for key, value in sorted(ctx.extra().items()): +def showextras(**args): + templ = args['templ'] + for key, value in sorted(args['ctx'].extra().items()): args = args.copy() args.update(dict(key=key, value=value)) yield templ('extra', **args) -def showfileadds(repo, ctx, templ, revcache, **args): - return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args) +def showfileadds(**args): + repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] + return showlist('file_add', getfiles(repo, ctx, revcache)[1], **args) -def showfilecopies(repo, ctx, templ, cache, revcache, **args): - copies = revcache.get('copies') +def showfilecopies(**args): + cache, ctx= args['cache'], args['ctx'] + copies = args['revcache'].get('copies') if copies is None: if 'getrenamed' not in cache: - cache['getrenamed'] = getrenamedfn(repo) + cache['getrenamed'] = getrenamedfn(args['repo']) copies = [] getrenamed = cache['getrenamed'] for fn in ctx.files(): rename = getrenamed(fn, ctx.rev()) if rename: copies.append((fn, rename[0])) - + c = [{'name': x[0], 'source': x[1]} for x in copies] - return showlist(templ, 'file_copy', c, plural='file_copies', **args) + return showlist('file_copy', c, plural='file_copies', **args) # showfilecopiesswitch() displays file copies only if copy records are # provided before calling the templater, usually with a --copies # command line switch. -def showfilecopiesswitch(repo, ctx, templ, cache, revcache, **args): - copies = revcache.get('copies') or [] +def showfilecopiesswitch(**args): + copies = args['revcache'].get('copies') or [] c = [{'name': x[0], 'source': x[1]} for x in copies] - return showlist(templ, 'file_copy', c, plural='file_copies', **args) + return showlist('file_copy', c, plural='file_copies', **args) -def showfiledels(repo, ctx, templ, revcache, **args): - return showlist(templ, 'file_del', getfiles(repo, ctx, revcache)[2], **args) +def showfiledels(**args): + repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] + return showlist('file_del', getfiles(repo, ctx, revcache)[2], **args) -def showfilemods(repo, ctx, templ, revcache, **args): - return showlist(templ, 'file_mod', getfiles(repo, ctx, revcache)[0], **args) +def showfilemods(**args): + repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] + return showlist('file_mod', getfiles(repo, ctx, revcache)[0], **args) -def showfiles(repo, ctx, templ, **args): - return showlist(templ, 'file', ctx.files(), **args) +def showfiles(**args): + return showlist('file', args['ctx'].files(), **args) def showlatesttag(repo, ctx, templ, cache, **args): return getlatesttags(repo, ctx, cache)[2] @@ -211,7 +218,8 @@ def showlatesttagdistance(repo, ctx, templ, cache, **args): return getlatesttags(repo, ctx, cache)[1] -def showmanifest(repo, ctx, templ, **args): +def showmanifest(**args): + repo, ctx, templ = args['repo'], args['ctx'], args['templ'] args = args.copy() args.update(dict(rev=repo.manifest.rev(ctx.changeset()[0]), node=hex(ctx.changeset()[0]))) @@ -223,9 +231,17 @@ def showrev(repo, ctx, templ, **args): return ctx.rev() -def showtags(repo, ctx, templ, **args): - return showlist(templ, 'tag', ctx.tags(), **args) +def showtags(**args): + return showlist('tag', args['ctx'].tags(), **args) +# keywords are callables like: +# fn(repo, ctx, templ, cache, revcache, **args) +# with: +# repo - current repository instance +# ctx - the changectx being displayed +# templ - the templater instance +# cache - a cache dictionary for the whole templater run +# revcache - a cache dictionary for the current revision keywords = { 'author': showauthor, 'branches': showbranches,
--- a/mercurial/templater.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templater.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import re, sys, os @@ -77,7 +77,7 @@ raise SyntaxError(_("error expanding '%s%%%s'") % (key, format)) lm = map.copy() for i in v: - if isinstance(i, dict): + if isinstance(i, dict): lm.update(i) yield self.process(format, lm) else: @@ -244,7 +244,6 @@ styles = [styles] for style in styles: - if not style: continue locations = [os.path.join(style, 'map'), 'map-' + style]
--- a/mercurial/templates/coal/map Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templates/coal/map Thu Jan 28 23:13:45 2010 -0600 @@ -181,7 +181,7 @@ <td><a href="{url}{sessionvars%urlparameter}">{name|escape}</a></td> <td>{description}</td> <td>{contact|obfuscate}</td> - <td class="age">{lastchange|age} ago</td> + <td class="age">{lastchange|age}</td> <td class="indexlinks">{archives%indexarchiveentry}</td> </tr>\n' indexarchiveentry = '<a href="{url}archive/{node|short}{extension|urlescape}"> ↓{type|escape}</a>'
--- a/mercurial/templates/gitweb/graph.tmpl Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templates/gitweb/graph.tmpl Thu Jan 28 23:13:45 2010 -0600 @@ -63,7 +63,7 @@ var revlink = '<li style="_STYLE"><span class="desc">'; revlink += '<a class="list" href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID"><b>_DESC</b></a>'; revlink += '</span> _TAGS'; -revlink += '<span class="info">_DATE ago, by _USER</span></li>'; +revlink += '<span class="info">_DATE, by _USER</span></li>'; graph.vertex = function(x, y, color, parity, cur) {
--- a/mercurial/templates/monoblue/graph.tmpl Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templates/monoblue/graph.tmpl Thu Jan 28 23:13:45 2010 -0600 @@ -60,7 +60,7 @@ var revlink = '<li style="_STYLE"><span class="desc">'; revlink += '<a href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID">_DESC</a>'; - revlink += '</span>_TAGS<span class="info">_DATE ago, by _USER</span></li>'; + revlink += '</span>_TAGS<span class="info">_DATE, by _USER</span></li>'; graph.vertex = function(x, y, color, parity, cur) {
--- a/mercurial/templates/paper/graph.tmpl Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templates/paper/graph.tmpl Thu Jan 28 23:13:45 2010 -0600 @@ -71,7 +71,7 @@ var revlink = '<li style="_STYLE"><span class="desc">'; revlink += '<a href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID">_DESC</a>'; -revlink += '</span>_TAGS<span class="info">_DATE ago, by _USER</span></li>'; +revlink += '</span>_TAGS<span class="info">_DATE, by _USER</span></li>'; graph.vertex = function(x, y, color, parity, cur) {
--- a/mercurial/templates/spartan/graph.tmpl Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templates/spartan/graph.tmpl Thu Jan 28 23:13:45 2010 -0600 @@ -55,7 +55,7 @@ var revlink = '<li style="_STYLE"><span class="desc">'; revlink += '<a href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID">_DESC</a>'; -revlink += '</span><span class="info">_DATE ago, by _USER</span></li>'; +revlink += '</span><span class="info">_DATE, by _USER</span></li>'; graph.vertex = function(x, y, color, parity, cur) {
--- a/mercurial/templates/spartan/map Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/templates/spartan/map Thu Jan 28 23:13:45 2010 -0600 @@ -168,7 +168,7 @@ <td><a href="{url}{sessionvars%urlparameter}">{name|escape}</a></td> <td>{description}</td> <td>{contact|obfuscate}</td> - <td class="age">{lastchange|age} ago</td> + <td class="age">{lastchange|age}</td> <td class="indexlinks"> <a href="{url}rss-log">RSS</a> <a href="{url}atom-log">Atom</a>
--- a/mercurial/transaction.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/transaction.py Thu Jan 28 23:13:45 2010 -0600 @@ -9,7 +9,7 @@ # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import os, errno @@ -73,8 +73,8 @@ @active def add(self, file, offset, data=None): - if file in self.map: return - + if file in self.map: + return if self._queue: self._queue[-1].append((file, offset, data)) return @@ -147,7 +147,8 @@ self.report(_("transaction abort!\n")) try: - _playback(self.journal, self.report, self.opener, self.entries, False) + _playback(self.journal, self.report, self.opener, + self.entries, False) self.report(_("rollback completed\n")) except: self.report(_("rollback failed - please run hg recover\n"))
--- a/mercurial/ui.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/ui.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import errno, getpass, os, socket, sys, tempfile, traceback @@ -198,7 +198,8 @@ def shortuser(self, user): """Return a short representation of a user name or email address.""" - if not self.verbose: user = util.shortuser(user) + if not self.verbose: + user = util.shortuser(user) return user def _path(self, loc): @@ -236,12 +237,14 @@ def write_err(self, *args): try: - if not sys.stdout.closed: sys.stdout.flush() + if not sys.stdout.closed: + sys.stdout.flush() for a in args: sys.stderr.write(str(a)) # stderr may be buffered under win32 when redirected to files, # including stdout. - if not sys.stderr.closed: sys.stderr.flush() + if not sys.stderr.closed: + sys.stderr.flush() except IOError, inst: if inst.errno != errno.EPIPE: raise @@ -311,21 +314,24 @@ return resps.index(r.lower()) self.write(_("unrecognized response\n")) - def getpass(self, prompt=None, default=None): - if not self.interactive(): return default + if not self.interactive(): + return default try: return getpass.getpass(prompt or _('password: ')) except EOFError: raise util.Abort(_('response expected')) def status(self, *msg): - if not self.quiet: self.write(*msg) + if not self.quiet: + self.write(*msg) def warn(self, *msg): self.write_err(*msg) def note(self, *msg): - if self.verbose: self.write(*msg) + if self.verbose: + self.write(*msg) def debug(self, *msg): - if self.debugflag: self.write(*msg) + if self.debugflag: + self.write(*msg) def edit(self, text, user): (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt", text=True)
--- a/mercurial/url.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/url.py Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. import urllib, urllib2, urlparse, httplib, os, re, socket, cStringIO from i18n import _ @@ -30,18 +30,18 @@ if a == -1: user, passwd = None, None else: - userpass, netloc = netloc[:a], netloc[a+1:] + userpass, netloc = netloc[:a], netloc[a + 1:] c = userpass.find(':') if c == -1: user, passwd = urllib.unquote(userpass), None else: user = urllib.unquote(userpass[:c]) - passwd = urllib.unquote(userpass[c+1:]) + passwd = urllib.unquote(userpass[c + 1:]) c = netloc.find(':') if c == -1: host, port = netloc, None else: - host, port = netloc[:c], netloc[c+1:] + host, port = netloc[:c], netloc[c + 1:] return host, port, user, passwd def netlocunsplit(host, port, user=None, passwd=None): @@ -89,7 +89,8 @@ 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): + 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) @@ -148,7 +149,8 @@ bestauth = None for auth in config.itervalues(): prefix = auth.get('prefix') - if not prefix: continue + if not prefix: + continue p = prefix.split('://', 1) if len(p) > 1: schemes, prefix = [p[0]], p[1] @@ -180,7 +182,7 @@ proxypasswd = ui.config("http_proxy", "passwd") # see if we should use a proxy for this url - no_list = [ "localhost", "127.0.0.1" ] + no_list = ["localhost", "127.0.0.1"] no_list.extend([p.lower() for p in ui.configlist("http_proxy", "no")]) no_list.extend([p.strip().lower() for @@ -436,7 +438,8 @@ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) if _generic_proxytunnel(self): - self.sock = _ssl_wrap_socket(self.sock, self.cert_file, self.key_file) + self.sock = _ssl_wrap_socket(self.sock, self.cert_file, + self.key_file) else: BetterHTTPS.connect(self)
--- a/mercurial/util.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/util.py Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """Mercurial utility functions and platform specfic implementations. @@ -182,16 +182,21 @@ code = os.system(cmd) if sys.platform == 'OpenVMS' and code & 1: code = 0 - if code: raise Abort(_("command '%s' failed: %s") % - (cmd, explain_exit(code))) + if code: + raise Abort(_("command '%s' failed: %s") % + (cmd, explain_exit(code))) return open(outname, 'rb').read() finally: try: - if inname: os.unlink(inname) - except: pass + if inname: + os.unlink(inname) + except: + pass try: - if outname: os.unlink(outname) - except: pass + if outname: + os.unlink(outname) + except: + pass filtertable = { 'tempfile:': tempfilter, @@ -242,8 +247,11 @@ Abort = error.Abort -def always(fn): return True -def never(fn): return False +def always(fn): + return True + +def never(fn): + return False def pathto(root, n1, n2): '''return the relative path from one place to another. @@ -256,7 +264,8 @@ relative to root. n2 should always be relative to root. ''' - if not n1: return localpath(n2) + if not n1: + return localpath(n2) if os.path.isabs(n1): if os.path.splitdrive(root)[0] != os.path.splitdrive(n1)[0]: return os.path.join(root, localpath(n2)) @@ -912,11 +921,15 @@ assert size >= 0 assert limit is None or limit >= 0 while True: - if limit is None: nbytes = size - else: nbytes = min(limit, size) + if limit is None: + nbytes = size + else: + nbytes = min(limit, size) s = nbytes and f.read(nbytes) - if not s: break - if limit: limit -= len(s) + if not s: + break + if limit: + limit -= len(s) yield s def makedate(): @@ -1084,7 +1097,7 @@ user = user[:f] f = user.find('<') if f >= 0: - user = user[f+1:] + user = user[f + 1:] f = user.find(' ') if f >= 0: user = user[:f] @@ -1096,15 +1109,16 @@ def email(author): '''get email of author.''' r = author.find('>') - if r == -1: r = None - return author[author.find('<')+1:r] + if r == -1: + r = None + return author[author.find('<') + 1:r] def ellipsis(text, maxlength=400): """Trim string to at most maxlength (default: 400) characters.""" if len(text) <= maxlength: return text else: - return "%s..." % (text[:maxlength-3]) + return "%s..." % (text[:maxlength - 3]) def walkrepos(path, followsym=False, seen_dirs=None, recurse=False): '''yield every hg repository under path, recursively.''' @@ -1173,7 +1187,8 @@ if 'HGRCPATH' in os.environ: _rcpath = [] for p in os.environ['HGRCPATH'].split(os.pathsep): - if not p: continue + if not p: + continue p = expandpath(p) if os.path.isdir(p): for f, kind in osutil.listdir(p): @@ -1189,15 +1204,15 @@ '''return byte count formatted as readable string, with units''' units = ( - (100, 1<<30, _('%.0f GB')), - (10, 1<<30, _('%.1f GB')), - (1, 1<<30, _('%.2f GB')), - (100, 1<<20, _('%.0f MB')), - (10, 1<<20, _('%.1f MB')), - (1, 1<<20, _('%.2f MB')), - (100, 1<<10, _('%.0f KB')), - (10, 1<<10, _('%.1f KB')), - (1, 1<<10, _('%.2f KB')), + (100, 1 << 30, _('%.0f GB')), + (10, 1 << 30, _('%.1f GB')), + (1, 1 << 30, _('%.2f GB')), + (100, 1 << 20, _('%.0f MB')), + (10, 1 << 20, _('%.1f MB')), + (1, 1 << 20, _('%.2f MB')), + (100, 1 << 10, _('%.0f KB')), + (10, 1 << 10, _('%.1f KB')), + (1, 1 << 10, _('%.2f KB')), (1, 1, _('%.0f bytes')), ) @@ -1219,7 +1234,7 @@ # root. On POSIX they are rooted at the file system root. if os.name == 'nt': droot = os.path.splitdrive(os.getcwd())[0] + '/' - path = os.path.join(droot, path[i+1:]) + path = os.path.join(droot, path[i + 1:]) else: path = path[i:] else:
--- a/mercurial/verify.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/verify.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from node import nullid, short from i18n import _ @@ -155,7 +155,8 @@ ui.status(_("crosschecking files in changesets and manifests\n")) if havemf: - for c,m in sorted([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]): + for c, m in sorted([(c, m) for m in mflinkrevs + for c in mflinkrevs[m]]): err(c, _("changeset refers to unknown manifest %s") % short(m)) mflinkrevs = None # del is bad here due to scope issues @@ -259,7 +260,7 @@ # cross-check if f in filenodes: - fns = [(lr, n) for n,lr in filenodes[f].iteritems()] + fns = [(lr, n) for n, lr in filenodes[f].iteritems()] for lr, node in sorted(fns): err(lr, _("%s in manifests not found") % short(node), f)
--- a/mercurial/win32.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/win32.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """Utility functions that use win32 API.
--- a/mercurial/windows.py Mon Jan 18 19:57:36 2010 +0100 +++ b/mercurial/windows.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. from i18n import _ import osutil, error @@ -47,7 +47,8 @@ self.fp.write(s[start:end]) start = end except IOError, inst: - if inst.errno != 0: raise + if inst.errno != 0: + raise self.close() raise IOError(errno.EPIPE, 'Broken pipe') @@ -55,7 +56,8 @@ try: return self.fp.flush() except IOError, inst: - if inst.errno != errno.EINVAL: raise + if inst.errno != errno.EINVAL: + raise self.close() raise IOError(errno.EPIPE, 'Broken pipe') @@ -333,7 +335,7 @@ hStdOutput = None hStdError = None wShowWindow = subprocess.SW_HIDE - + args = subprocess.list2cmdline(args) # Not running the command in shell mode makes python26 hang when # writing to hgweb output socket.
--- a/setup.py Mon Jan 18 19:57:36 2010 +0100 +++ b/setup.py Thu Jan 28 23:13:45 2010 -0600 @@ -240,7 +240,7 @@ ] packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert', - 'hgext.highlight', 'hgext.zeroconf', ] + 'hgext.highlight', 'hgext.zeroconf'] if sys.platform == 'linux2' and os.uname()[2] > '2.6': # The inotify extension is only usable with Linux 2.6 kernels. @@ -257,7 +257,7 @@ def ordinarypath(p): return p and p[0] != '.' and p[-1] != '~' -for root in ('templates', ): +for root in ('templates',): for curdir, dirs, files in os.walk(os.path.join('mercurial', root)): curdir = curdir.split(os.sep, 1)[1] dirs[:] = filter(ordinarypath, dirs) @@ -273,7 +273,7 @@ author_email='mpm@selenic.com', url='http://mercurial.selenic.com/', description='Scalable distributed SCM', - license='GNU GPL', + license='GNU GPLv2+', scripts=scripts, packages=packages, ext_modules=extmodules,
--- a/tests/coverage.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/coverage.py Thu Jan 28 23:13:45 2010 -0600 @@ -106,20 +106,20 @@ self.excluded = excluded self.suite_spots = suite_spots self.excluding_suite = 0 - + def doRecursive(self, node): for n in node.getChildNodes(): self.dispatch(n) visitStmt = visitModule = doRecursive - + def doCode(self, node): if hasattr(node, 'decorators') and node.decorators: self.dispatch(node.decorators) self.recordAndDispatch(node.code) else: self.doSuite(node, node.code) - + visitFunction = visitClass = doCode def getFirstLine(self, node): @@ -139,26 +139,26 @@ for n in node.getChildNodes(): lineno = max(lineno, self.getLastLine(n)) return lineno - + def doStatement(self, node): self.recordLine(self.getFirstLine(node)) visitAssert = visitAssign = visitAssTuple = visitPrint = \ visitPrintnl = visitRaise = visitSubscript = visitDecorators = \ doStatement - + def visitPass(self, node): - # Pass statements have weird interactions with docstrings. If this - # pass statement is part of one of those pairs, claim that the statement - # is on the later of the two lines. + # Pass statements have weird interactions with docstrings. If + # this pass statement is part of one of those pairs, claim + # that the statement is on the later of the two lines. l = node.lineno if l: - lines = self.suite_spots.get(l, [l,l]) + lines = self.suite_spots.get(l, [l, l]) self.statements[lines[1]] = 1 - + def visitDiscard(self, node): # Discard nodes are statements that execute an expression, but then - # discard the results. This includes function calls, so we can't + # discard the results. This includes function calls, so we can't # ignore them all. But if the expression is a constant, the statement # won't be "executed", so don't count it now. if node.expr.__class__.__name__ != 'Const': @@ -172,7 +172,7 @@ return self.recordLine(self.getFirstLine(node)) else: return 0 - + def recordLine(self, lineno): # Returns a bool, whether the line is included or excluded. if lineno: @@ -196,9 +196,9 @@ self.statements[lineno] = 1 return 1 return 0 - + default = recordNodeLine - + def recordAndDispatch(self, node): self.recordNodeLine(node) self.dispatch(node) @@ -209,7 +209,7 @@ self.excluding_suite = 1 self.recordAndDispatch(body) self.excluding_suite = exsuite - + def doPlainWordSuite(self, prevsuite, suite): # Finding the exclude lines for else's is tricky, because they aren't # present in the compiler parse tree. Look at the previous suite, @@ -217,17 +217,17 @@ # first line are excluded, then we exclude the else. lastprev = self.getLastLine(prevsuite) firstelse = self.getFirstLine(suite) - for l in range(lastprev+1, firstelse): + for l in range(lastprev + 1, firstelse): if self.suite_spots.has_key(l): self.doSuite(None, suite, exclude=self.excluded.has_key(l)) break else: self.doSuite(None, suite) - + def doElse(self, prevsuite, node): if node.else_: self.doPlainWordSuite(prevsuite, node.else_) - + def visitFor(self, node): self.doSuite(node, node.body) self.doElse(node.body, node) @@ -250,21 +250,21 @@ if not a: # It's a plain "except:". Find the previous suite. if i > 0: - prev = node.handlers[i-1][2] + prev = node.handlers[i - 1][2] else: prev = node.body self.doPlainWordSuite(prev, h) else: self.doSuite(a, h) self.doElse(node.handlers[-1][2], node) - + def visitTryFinally(self, node): self.doSuite(node, node.body) self.doPlainWordSuite(node.body, node.final) - + def visitWith(self, node): self.doSuite(node, node.body) - + def visitGlobal(self, node): # "global" statements don't execute like others (they don't call the # trace function), so don't record their line numbers. @@ -285,7 +285,7 @@ # A dictionary with an entry for (Python source file name, line number # in that file) if that line has been executed. c = {} - + # A map from canonical Python source file name to a dictionary in # which there's an entry for each line number that has been # executed. @@ -313,19 +313,18 @@ self.relative_dir = self.abs_file(os.curdir)+os.sep self.exclude('# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]') - # t(f, x, y). This method is passed to sys.settrace as a trace function. - # See [van Rossum 2001-07-20b, 9.2] for an explanation of sys.settrace and + # t(f, x, y). This method is passed to sys.settrace as a trace function. + # See [van Rossum 2001-07-20b, 9.2] for an explanation of sys.settrace and # the arguments and return value of the trace function. # See [van Rossum 2001-07-20a, 3.2] for a description of frame and code # objects. - - def t(self, f, w, unused): #pragma: no cover + def t(self, f, w, unused): #pragma: no cover if w == 'line': self.c[(f.f_code.co_filename, f.f_lineno)] = 1 #-for c in self.cstack: #- c[(f.f_code.co_filename, f.f_lineno)] = 1 return self.t - + def help(self, error=None): #pragma: no cover if error: print error @@ -363,7 +362,8 @@ elif o[2:] + '=' in long_opts: settings[o[2:]+'='] = a else: #pragma: no cover - pass # Can't get here, because getopt won't return anything unknown. + # Can't get here, because getopt won't return anything unknown. + pass if settings.get('help'): help_fn() @@ -377,14 +377,14 @@ args_needed = (settings.get('execute') or settings.get('annotate') or settings.get('report')) - action = (settings.get('erase') + action = (settings.get('erase') or settings.get('collect') or args_needed) if not action: help_fn("You must specify at least one of -e, -x, -c, -r, or -a.") if not args_needed and args: help_fn("Unexpected arguments: %s" % " ".join(args)) - + self.parallel_mode = settings.get('parallel-mode') self.get_ready() @@ -402,7 +402,7 @@ self.collect() if not args: args = self.cexecuted.keys() - + ignore_errors = settings.get('ignore-errors') show_missing = settings.get('show-missing') directory = settings.get('directory=') @@ -412,7 +412,7 @@ omit = [self.abs_file(p) for p in omit.split(',')] else: omit = [] - + if settings.get('report'): self.report(args, show_missing, ignore_errors, omit_prefixes=omit) if settings.get('annotate'): @@ -422,7 +422,7 @@ self.usecache = usecache if cache_file and not self.cache: self.cache_default = cache_file - + def get_ready(self, parallel_mode=False): if self.usecache and not self.cache: self.cache = os.environ.get(self.cache_env, self.cache_default) @@ -430,7 +430,7 @@ self.cache += "." + gethostname() + "." + str(os.getpid()) self.restore() self.analysis_cache = {} - + def start(self, parallel_mode=False): self.get_ready() if self.nesting == 0: #pragma: no cover @@ -438,7 +438,7 @@ if hasattr(threading, 'settrace'): threading.settrace(self.t) self.nesting += 1 - + def stop(self): self.nesting -= 1 if self.nesting == 0: #pragma: no cover @@ -462,7 +462,7 @@ def begin_recursive(self): self.cstack.append(self.c) self.xstack.append(self.exclude_re) - + def end_recursive(self): self.c = self.cstack.pop() self.exclude_re = self.xstack.pop() @@ -568,7 +568,7 @@ self.canonical_filename_cache[filename] = cf return self.canonical_filename_cache[filename] - # canonicalize_filenames(). Copy results from "c" to "cexecuted", + # canonicalize_filenames(). Copy results from "c" to "cexecuted", # canonicalizing filenames on the way. Clear the "c" map. def canonicalize_filenames(self): @@ -598,7 +598,6 @@ # in the source code, (3) a list of lines of excluded statements, # and (4), a map of line numbers to multi-line line number ranges, for # statements that cross lines. - def analyze_morf(self, morf): if self.analysis_cache.has_key(morf): return self.analysis_cache[morf] @@ -636,26 +635,27 @@ if len(tree) == 3 and type(tree[2]) == type(1): return tree[2] tree = tree[1] - + def last_line_of_tree(self, tree): while True: if len(tree) == 3 and type(tree[2]) == type(1): return tree[2] tree = tree[-1] - + def find_docstring_pass_pair(self, tree, spots): for i in range(1, len(tree)): - if self.is_string_constant(tree[i]) and self.is_pass_stmt(tree[i+1]): + if (self.is_string_constant(tree[i]) and + self.is_pass_stmt(tree[i + 1]): first_line = self.first_line_of_tree(tree[i]) - last_line = self.last_line_of_tree(tree[i+1]) + last_line = self.last_line_of_tree(tree[i + 1]) self.record_multiline(spots, first_line, last_line) - + def is_string_constant(self, tree): try: return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.expr_stmt except: return False - + def is_pass_stmt(self, tree): try: return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.pass_stmt @@ -663,9 +663,9 @@ return False def record_multiline(self, spots, i, j): - for l in range(i, j+1): + for l in range(i, j + 1): spots[l] = (i, j) - + def get_suite_spots(self, tree, spots): """ Analyze a parse tree to find suite introducers which span a number of lines. @@ -675,16 +675,16 @@ if tree[i][0] == symbol.suite: # Found a suite, look back for the colon and keyword. lineno_colon = lineno_word = None - for j in range(i-1, 0, -1): + for j in range(i - 1, 0, -1): if tree[j][0] == token.COLON: # Colons are never executed themselves: we want the # line number of the last token before the colon. - lineno_colon = self.last_line_of_tree(tree[j-1]) + lineno_colon = self.last_line_of_tree(tree[j - 1]) elif tree[j][0] == token.NAME: if tree[j][1] == 'elif': - # Find the line number of the first non-terminal - # after the keyword. - t = tree[j+1] + # Find the line number of the first + # non-terminal after the keyword. + t = tree[j + 1] while t and token.ISNONTERMINAL(t[0]): t = t[1] if t: @@ -694,7 +694,7 @@ break elif tree[j][0] == symbol.except_clause: # "except" clauses look like: - # ('except_clause', ('NAME', 'except', lineno), ...) + # ('except_clause', ('NAME', 'except', lineno),...) if tree[j][1][0] == token.NAME: lineno_word = tree[j][1][2] break @@ -703,11 +703,11 @@ # between the two with the two line numbers. self.record_multiline(spots, lineno_word, lineno_colon) - # "pass" statements are tricky: different versions of Python - # treat them differently, especially in the common case of a - # function with a doc string and a single pass statement. + # "pass" statements are tricky: different versions + # of Python treat them differently, especially in + # the common case of a function with a doc string + # and a single pass statement. self.find_docstring_pass_pair(tree[i], spots) - elif tree[i][0] == symbol.simple_stmt: first_line = self.first_line_of_tree(tree[i]) last_line = self.last_line_of_tree(tree[i]) @@ -724,7 +724,7 @@ lines = text.split('\n') for i in range(len(lines)): if reExclude.search(lines[i]): - excluded[i+1] = 1 + excluded[i + 1] = 1 # Parse the code and analyze the parse tree to find out which statements # are multiline, and where suites begin and end. @@ -732,7 +732,7 @@ tree = parser.suite(text+'\n\n').totuple(1) self.get_suite_spots(tree, suite_spots) #print "Suite spots:", suite_spots - + # Use the compiler module to parse the text and find the executable # statements. We add newlines to be impervious to final partial lines. statements = {} @@ -831,7 +831,8 @@ def morf_name_compare(self, x, y): return cmp(self.morf_name(x), self.morf_name(y)) - def report(self, morfs, show_missing=1, ignore_errors=0, file=None, omit_prefixes=[]): + def report(self, morfs, show_missing=1, ignore_errors=0, file=None, + omit_prefixes=[]): if not isinstance(morfs, types.ListType): morfs = [morfs] # On windows, the shell doesn't expand wildcards. Do it here. @@ -842,7 +843,7 @@ else: globbed.append(morf) morfs = globbed - + morfs = self.filter_by_prefix(morfs, omit_prefixes) morfs.sort(self.morf_name_compare) @@ -856,8 +857,8 @@ fmt_coverage = fmt_coverage + " %s" if not file: file = sys.stdout - print >>file, header - print >>file, "-" * len(header) + print >> file, header + print >> file, "-" * len(header) total_statements = 0 total_executed = 0 for morf in morfs: @@ -903,14 +904,16 @@ for morf in morfs: try: filename, statements, excluded, missing, _ = self.analysis2(morf) - self.annotate_file(filename, statements, excluded, missing, directory) + self.annotate_file(filename, statements, excluded, missing, + directory) except KeyboardInterrupt: raise except: if not ignore_errors: raise - - def annotate_file(self, filename, statements, excluded, missing, directory=None): + + def annotate_file(self, filename, statements, excluded, missing, + directory=None): source = open(filename, 'r') if directory: dest_file = os.path.join(directory, @@ -937,7 +940,7 @@ if self.blank_re.match(line): dest.write(' ') elif self.else_re.match(line): - # Special logic for lines containing only 'else:'. + # Special logic for lines containing only 'else:'. # See [GDR 2001-12-04b, 3.2]. if i >= len(statements) and j >= len(missing): dest.write('! ') @@ -961,40 +964,40 @@ the_coverage = coverage() # Module functions call methods in the singleton object. -def use_cache(*args, **kw): +def use_cache(*args, **kw): return the_coverage.use_cache(*args, **kw) -def start(*args, **kw): +def start(*args, **kw): return the_coverage.start(*args, **kw) -def stop(*args, **kw): +def stop(*args, **kw): return the_coverage.stop(*args, **kw) -def erase(*args, **kw): +def erase(*args, **kw): return the_coverage.erase(*args, **kw) -def begin_recursive(*args, **kw): +def begin_recursive(*args, **kw): return the_coverage.begin_recursive(*args, **kw) -def end_recursive(*args, **kw): +def end_recursive(*args, **kw): return the_coverage.end_recursive(*args, **kw) -def exclude(*args, **kw): +def exclude(*args, **kw): return the_coverage.exclude(*args, **kw) -def analysis(*args, **kw): +def analysis(*args, **kw): return the_coverage.analysis(*args, **kw) -def analysis2(*args, **kw): +def analysis2(*args, **kw): return the_coverage.analysis2(*args, **kw) -def report(*args, **kw): +def report(*args, **kw): return the_coverage.report(*args, **kw) -def annotate(*args, **kw): +def annotate(*args, **kw): return the_coverage.annotate(*args, **kw) -def annotate_file(*args, **kw): +def annotate_file(*args, **kw): return the_coverage.annotate_file(*args, **kw) # Save coverage data when Python exits. (The atexit module wasn't @@ -1008,7 +1011,7 @@ def main(): the_coverage.command_line(sys.argv[1:]) - + # Command-line interface. if __name__ == '__main__': main() @@ -1072,7 +1075,7 @@ # Thanks, Allen. # # 2005-12-02 NMB Call threading.settrace so that all threads are measured. -# Thanks Martin Fuzzey. Add a file argument to report so that reports can be +# Thanks Martin Fuzzey. Add a file argument to report so that reports can be # captured to a different destination. # # 2005-12-03 NMB coverage.py can now measure itself.
--- a/tests/printenv.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/printenv.py Thu Jan 28 23:13:45 2010 -0600 @@ -48,7 +48,8 @@ out.write("%s hook: " % name) for v in env: - out.write("%s=%s " % (v, os.environ[v].replace(os.environ["HGTMP"], '$HGTMP'))) + out.write("%s=%s " % + (v, os.environ[v].replace(os.environ["HGTMP"], '$HGTMP'))) out.write("\n") out.close()
--- a/tests/printrepr.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/printrepr.py Thu Jan 28 23:13:45 2010 -0600 @@ -3,7 +3,7 @@ # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. """prints repr(sys.stdin) but preserves newlines in input"""
--- a/tests/readlink.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/readlink.py Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,8 @@ try: print f, '->', os.readlink(f) except OSError, err: - if err.errno != errno.EINVAL: raise + if err.errno != errno.EINVAL: + raise print f, 'not a symlink' sys.exit(0)
--- a/tests/run-tests.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/run-tests.py Thu Jan 28 23:13:45 2010 -0600 @@ -5,7 +5,7 @@ # Copyright 2006 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms of the -# GNU General Public License version 2, incorporated herein by reference. +# GNU General Public License version 2 or any later version. # Modifying this script is tricky because it has many modes: # - serial (default) vs parallel (-jN, N > 1) @@ -231,7 +231,7 @@ if last: lines.append(last) return lines - lines.append(text[i:n+1]) + lines.append(text[i:n + 1]) i = n + 1 def parsehghaveoutput(lines): @@ -660,7 +660,8 @@ jobs = [[] for j in xrange(options.jobs)] while tests: for job in jobs: - if not tests: break + if not tests: + break job.append(tests.pop()) fps = {} for j, job in enumerate(jobs):
--- a/tests/test-command-template Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-command-template Thu Jan 28 23:13:45 2010 -0600 @@ -195,4 +195,13 @@ EOF hg -R latesttag tip +echo '# test recursive showlist template (issue1989)' +cat > style1989 <<EOF +changeset = '{file_mods}{manifest}{extras}' +file_mod = 'M|{author|person}\n' +manifest = '{rev},{author}\n' +extra = '{key}: {author}\n' +EOF +hg -R latesttag log -r tip --style=style1989 + echo '# done'
--- a/tests/test-command-template.out Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-command-template.out Thu Jan 28 23:13:45 2010 -0600 @@ -1066,4 +1066,8 @@ 0: null+1 # style path expansion (issue1948) test 10:dee8f28249af +# test recursive showlist template (issue1989) +M|test +10,test +branch: test # done
--- a/tests/test-convert-cvs Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-convert-cvs Thu Jan 28 23:13:45 2010 -0600 @@ -23,7 +23,7 @@ def cvschangesets(ui,repo,hooktype,changesets): print "%s hook: %d changesets"%(hooktype,len(changesets)) EOF -hookpath=$PWD +hookpath=`pwd` echo "[hooks]" >> $HGRCPATH echo "cvslog=python:$hookpath/cvshooks.py:cvslog" >> $HGRCPATH @@ -32,7 +32,7 @@ echo % create cvs repository mkdir cvsrepo cd cvsrepo -CVSROOT=$PWD +CVSROOT=`pwd` export CVSROOT CVS_OPTIONS=-f export CVS_OPTIONS
--- a/tests/test-convert-p4-filetypes Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-convert-p4-filetypes Thu Jan 28 23:13:45 2010 -0600 @@ -6,7 +6,7 @@ echo "convert = " >> $HGRCPATH echo % create p4 depot -P4ROOT=$PWD/depot; export P4ROOT +P4ROOT=`pwd`/depot; export P4ROOT P4AUDIT=$P4ROOT/audit; export P4AUDIT P4JOURNAL=$P4ROOT/journal; export P4JOURNAL P4LOG=$P4ROOT/log; export P4LOG
--- a/tests/test-encode Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-encode Thu Jan 28 23:13:45 2010 -0600 @@ -4,11 +4,11 @@ cat > .hg/hgrc <<EOF [encode] -not.gz = tr a-z A-Z +not.gz = tr [:lower:] [:upper:] *.gz = gzip -d [decode] -not.gz = tr A-Z a-z +not.gz = tr [:upper:] [:lower:] *.gz = gzip EOF
--- a/tests/test-gendoc Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-gendoc Thu Jan 28 23:13:45 2010 -0600 @@ -1,13 +1,13 @@ #!/bin/sh "$TESTDIR/hghave" rst2html || exit 80 -RST2HTML=$(which rst2html 2> /dev/null || which rst2html.py) +RST2HTML=`which rst2html 2> /dev/null || which rst2html.py` HGENCODING=UTF-8 export HGENCODING for PO in C $TESTDIR/../i18n/*.po; do - LOCALE=$(basename $PO .po) + LOCALE=`basename $PO .po` echo echo "% extracting documentation from $LOCALE" echo ".. -*- coding: utf-8 -*-" > gendoc-$LOCALE.txt
--- a/tests/test-hgrc Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-hgrc Thu Jan 28 23:13:45 2010 -0600 @@ -19,5 +19,9 @@ echo ' x = y' >> $HGRCPATH hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|" +python -c "print '[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n'" \ + > $HGRCPATH +hg showconfig foo + echo '%include /no-such-file' > $HGRCPATH hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
--- a/tests/test-hgrc.out Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-hgrc.out Thu Jan 28 23:13:45 2010 -0600 @@ -7,4 +7,6 @@ bundle.mainreporoot=.../foobar paths.default=.../foo%bar hg: config error at $HGRCPATH:2: ' x = y' +foo.bar=a\nb\nc\nde\nfg +foo.baz=bif cb hg: config error at $HGRCPATH:1: cannot include /no-such-file (No such file or directory)
--- a/tests/test-hgweb-auth.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-hgweb-auth.py Thu Jan 28 23:13:45 2010 -0600 @@ -16,7 +16,8 @@ return ui def dumpdict(dict): - return '{' + ', '.join(['%s: %s' % (k, dict[k]) for k in sorted(dict.iterkeys())]) + '}' + return '{' + ', '.join(['%s: %s' % (k, dict[k]) + for k in sorted(dict.iterkeys())]) + '}' def test(auth): print 'CFG:', dumpdict(auth) @@ -56,6 +57,8 @@ test({'x.prefix': 'example.org', 'x.schemes': 'http https'}) print '\n*** Test prefix matching\n' -test({'x.prefix': 'http://example.org/foo', 'y.prefix': 'http://example.org/bar'}) -test({'x.prefix': 'http://example.org/foo', 'y.prefix': 'http://example.org/foo/bar'}) +test({'x.prefix': 'http://example.org/foo', + 'y.prefix': 'http://example.org/bar'}) +test({'x.prefix': 'http://example.org/foo', + 'y.prefix': 'http://example.org/foo/bar'}) test({'x.prefix': '*', 'y.prefix': 'https://example.org/bar'})
--- a/tests/test-hgweb-commands.out Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-hgweb-commands.out Thu Jan 28 23:13:45 2010 -0600 @@ -775,7 +775,7 @@ var revlink = '<li style="_STYLE"><span class="desc">'; revlink += '<a class="list" href="/rev/_NODEID?style=gitweb" title="_NODEID"><b>_DESC</b></a>'; revlink += '</span> _TAGS'; -revlink += '<span class="info">_DATE ago, by _USER</span></li>'; +revlink += '<span class="info">_DATE, by _USER</span></li>'; graph.vertex = function(x, y, color, parity, cur) {
--- a/tests/test-hgweb-empty.out Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-hgweb-empty.out Thu Jan 28 23:13:45 2010 -0600 @@ -235,7 +235,7 @@ var revlink = '<li style="_STYLE"><span class="desc">'; revlink += '<a href="/rev/_NODEID" title="_NODEID">_DESC</a>'; -revlink += '</span>_TAGS<span class="info">_DATE ago, by _USER</span></li>'; +revlink += '</span>_TAGS<span class="info">_DATE, by _USER</span></li>'; graph.vertex = function(x, y, color, parity, cur) {
--- a/tests/test-merge-tools Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-merge-tools Thu Jan 28 23:13:45 2010 -0600 @@ -83,7 +83,7 @@ domerge -r 2 --config merge-tools.true.executable=nonexistingmergetool echo "# or true.executable with bogus path:" -domerge -r 2 --config merge-tools.true.executable=/bin/nonexistingmergetool +domerge -r 2 --config merge-tools.true.executable=/nonexisting/mergetool echo "# but true.executable set to cat found in PATH works:" echo "true.executable=cat" >> .hg/hgrc @@ -103,7 +103,7 @@ domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistingmergetool echo "# merge-patterns specifies executable with bogus path and gets warning:" -domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/bin/nonexistingmergetool +domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexisting/mergetool echo echo ui.merge overrules priority
--- a/tests/test-merge-tools.out Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-merge-tools.out Thu Jan 28 23:13:45 2010 -0600 @@ -116,7 +116,7 @@ false.whatever= true.priority=1 # hg update -C 1 -# hg merge -r 2 --config merge-tools.true.executable=/bin/nonexistingmergetool +# hg merge -r 2 --config merge-tools.true.executable=/nonexisting/mergetool merging f merging f failed! 0 files updated, 0 files merged, 0 files removed, 1 files unresolved @@ -218,7 +218,7 @@ true.priority=1 true.executable=cat # hg update -C 1 -# hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/bin/nonexistingmergetool +# hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexisting/mergetool couldn't find merge tool true specified for f merging f merging f failed!
--- a/tests/test-minirst.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-minirst.py Thu Jan 28 23:13:45 2010 -0600 @@ -15,10 +15,7 @@ A small indented paragraph. It is followed by some lines containing random whitespace. - - - -The third and final paragraph. + \n \n \nThe third and final paragraph. """ debugformat('paragraphs', paragraphs, 60)
--- a/tests/test-mq-git Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-mq-git Thu Jan 28 23:13:45 2010 -0600 @@ -76,4 +76,4 @@ hg cp a c hg qrefresh -d '0 0' cat .hg/patches/regular -cd .. \ No newline at end of file +cd ..
--- a/tests/test-mq-qrefresh Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-mq-qrefresh Thu Jan 28 23:13:45 2010 -0600 @@ -166,4 +166,4 @@ hg mv a b hg qrefresh hg qdiff --nodates -cd .. \ No newline at end of file +cd ..
--- a/tests/test-parse-date Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-parse-date Thu Jan 28 23:13:45 2010 -0600 @@ -84,4 +84,4 @@ hg log -d '< 02/01 ' --template '{date|date}\n' hg log -d ' > 02/01 ' --template '{date|date}\n' -hg log -d ' < 02/01 ' --template '{date|date}\n' \ No newline at end of file +hg log -d ' < 02/01 ' --template '{date|date}\n'
--- a/tests/test-patch-offset Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-patch-offset Thu Jan 28 23:13:45 2010 -0600 @@ -63,5 +63,5 @@ echo % compare imported changes against reference file python ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A -diff -u aref a +diff aref a
--- a/tests/test-simplemerge.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-simplemerge.py Thu Jan 28 23:13:45 2010 -0600 @@ -89,7 +89,8 @@ """) -MERGED_RESULT = split_lines(""" The Way that can be told of is not the eternal Way; +MERGED_RESULT = split_lines("""\ + The Way that can be told of is not the eternal Way; The name that can be named is not the eternal name. The Nameless is the origin of Heaven and Earth; The Named is the mother of all things. @@ -125,7 +126,7 @@ [(0, 2, 0, 2, 0, 2), - (2,2, 2,2, 2,2)]) + (2, 2, 2, 2, 2, 2)]) self.assertEquals(list(m3.merge_regions()), [('unchanged', 0, 2)]) @@ -141,8 +142,8 @@ # todo: should use a sentinal at end as from get_matching_blocks # to match without zz self.assertEquals(list(m3.find_sync_regions()), - [(0,1, 2,3, 0,1), - (1,1, 3,3, 1,1),]) + [(0, 1, 2, 3, 0, 1), + (1, 1, 3, 3, 1, 1),]) self.assertEquals(list(m3.merge_regions()), [('a', 0, 2), @@ -159,7 +160,7 @@ # todo: should use a sentinal at end as from get_matching_blocks # to match without zz self.assertEquals(list(m3.find_sync_regions()), - [(0,0, 2,2, 0,0)]) + [(0, 0, 2, 2, 0, 0)]) self.assertEquals(list(m3.merge_regions()), [('a', 0, 2)]) @@ -177,9 +178,9 @@ [(0, 1), (1, 2)]) self.assertEquals(list(m3.find_sync_regions()), - [(0,1, 0,1, 0,1), - (1,2, 2,3, 1,2), - (2,2, 3,3, 2,2),]) + [(0, 1, 0, 1, 0, 1), + (1, 2, 2, 3, 1, 2), + (2, 2, 3, 3, 2, 2),]) self.assertEquals(list(m3.merge_regions()), [('unchanged', 0, 1), @@ -253,14 +254,14 @@ [(0, 1), (1, 2)]) self.assertEquals(list(m3.find_sync_regions()), - [(0,1, 0,1, 0,1), - (1,2, 2,3, 2,3), - (2,2, 3,3, 3,3),]) + [(0, 1, 0, 1, 0, 1), + (1, 2, 2, 3, 2, 3), + (2, 2, 3, 3, 3, 3),]) self.assertEquals(list(m3.merge_regions()), - [('unchanged', 0,1), - ('conflict', 1,1, 1,2, 1,2), - ('unchanged', 1,2)]) + [('unchanged', 0, 1), + ('conflict', 1, 1, 1, 2, 1, 2), + ('unchanged', 1, 2)]) self.assertEquals(list(m3.merge_groups()), [('unchanged', ['aaa\n']), @@ -293,9 +294,9 @@ [(0, 1), (2, 3)]) self.assertEquals(list(m3.find_sync_regions()), - [(0,1, 0,1, 0,1), - (2,3, 2,3, 2,3), - (3,3, 3,3, 3,3),]) + [(0, 1, 0, 1, 0, 1), + (2, 3, 2, 3, 2, 3), + (3, 3, 3, 3, 3, 3),]) def test_replace_multi(self): """Replacement with regions of different size.""" @@ -308,9 +309,9 @@ self.assertEquals(list(m3.find_sync_regions()), - [(0,1, 0,1, 0,1), - (3,4, 4,5, 5,6), - (4,4, 5,5, 6,6),]) + [(0, 1, 0, 1, 0, 1), + (3, 4, 4, 5, 5, 6), + (4, 4, 5, 5, 6, 6)]) def test_merge_poem(self): """Test case from diff3 manual"""
--- a/tests/test-subrepo-svn Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-subrepo-svn Thu Jan 28 23:13:45 2010 -0600 @@ -19,13 +19,23 @@ echo % create subversion repo SVNREPO="file://$escapedwd/svn-repo" -WCROOT="$(pwd)/svn-wc" +WCROOT="`pwd`/svn-wc" svnadmin create svn-repo svn co $SVNREPO svn-wc cd svn-wc -echo alpha > alpha -svn add alpha +mkdir src +echo alpha > src/alpha +svn add src +mkdir externals +echo other > externals/other +svn add externals svn ci -m 'Add alpha' +svn up +cat > extdef <<EOF +externals -r1 $SVNREPO/externals +EOF +svn propset -F extdef svn:externals src +svn ci -m 'Setting externals' cd .. echo % create hg repo @@ -39,8 +49,8 @@ hg ci -Am0 echo % add first svn sub -echo "s = [svn]$SVNREPO" >> .hgsub -svn co --quiet $SVNREPO s +echo "s = [svn]$SVNREPO/src" >> .hgsub +svn co --quiet $SVNREPO/src s hg add .hgsub hg ci -m1 echo % debugsub @@ -60,14 +70,32 @@ echo echo % add a commit from svn -cd "$WCROOT" +cd "$WCROOT"/src svn up echo xyz >> alpha +svn propset svn:mime-type 'text/xml' alpha svn ci -m 'amend a from svn' -cd ../sub/t +cd ../../sub/t + echo % this commit from hg will fail echo zzz >> s/alpha hg ci -m 'amend alpha from hg' +svn revert -q s/alpha + +echo % this commit fails because of meta changes +svn propset svn:mime-type 'text/html' s/alpha +hg ci -m 'amend alpha from hg' +svn revert -q s/alpha + +echo % this commit fails because of externals changes +echo zzz > s/externals/other +hg ci -m 'amend externals from hg' +svn revert -q s/externals/other + +echo % this commit fails because of externals meta changes +svn propset svn:mime-type 'text/html' s/externals/other +hg ci -m 'amend externals from hg' +svn revert -q s/externals/other echo echo % clone
--- a/tests/test-subrepo-svn.out Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/test-subrepo-svn.out Thu Jan 28 23:13:45 2010 -0600 @@ -1,9 +1,20 @@ % create subversion repo Checked out revision 0. -A alpha -Adding alpha -Transmitting file data . +A src +A src/alpha +A externals +A externals/other +Adding externals +Adding externals/other +Adding src +Adding src/alpha +Transmitting file data .. Committed revision 1. +At revision 1. +property 'svn:externals' set on 'src' +Sending src + +Committed revision 2. % create hg repo % first revision, no sub adding a @@ -11,38 +22,66 @@ committing subrepository s % debugsub path s - source file:///root/svn-repo - revision 1 + source file:///root/svn-repo/src + revision 2 % change file in svn and hg, commit committing subrepository s Sending s/alpha Transmitting file data . -Committed revision 2. -At revision 2. +Committed revision 3. + +Fetching external item into 's/externals' +External at revision 1. + +At revision 3. path s - source file:///root/svn-repo - revision 2 + source file:///root/svn-repo/src + revision 3 % should be empty despite change to s/a % add a commit from svn U alpha -Updated to revision 2. -Sending alpha + +Fetching external item into 'externals' +A externals/other +Updated external to revision 1. + +Updated to revision 3. +property 'svn:mime-type' set on 'alpha' +Sending src/alpha Transmitting file data . -Committed revision 3. +Committed revision 4. % this commit from hg will fail committing subrepository s abort: svn: Commit failed (details follow): -svn: File '/alpha' is out of date +svn: File '/src/alpha' is out of date +% this commit fails because of meta changes +property 'svn:mime-type' set on 's/alpha' +committing subrepository s +abort: svn: Commit failed (details follow): +svn: File '/src/alpha' is out of date +% this commit fails because of externals changes +committing subrepository s +abort: cannot commit svn externals +% this commit fails because of externals meta changes +property 'svn:mime-type' set on 's/externals/other' +committing subrepository s +abort: cannot commit svn externals % clone updating to branch default A s/alpha -Checked out revision 2. + U s + +Fetching external item into 's/externals' +A s/externals/other +Checked out external at revision 1. + +Checked out revision 3. 3 files updated, 0 files merged, 0 files removed, 0 files unresolved % debugsub in clone path s - source file:///root/svn-repo - revision 2 + source file:///root/svn-repo/src + revision 3
--- a/tests/tinyproxy.py Mon Jan 18 19:57:36 2010 +0100 +++ b/tests/tinyproxy.py Thu Jan 28 23:13:45 2010 -0600 @@ -25,14 +25,15 @@ (ip, port) = self.client_address if hasattr(self, 'allowed_clients') and ip not in self.allowed_clients: self.raw_requestline = self.rfile.readline() - if self.parse_request(): self.send_error(403) + if self.parse_request(): + self.send_error(403) else: self.__base_handle() def _connect_to(self, netloc, soc): i = netloc.find(':') if i >= 0: - host_port = netloc[:i], int(netloc[i+1:]) + host_port = netloc[:i], int(netloc[i + 1:]) else: host_port = netloc, 80 print "\t" "connect to %s:%d" % host_port @@ -91,7 +92,8 @@ while 1: count += 1 (ins, _, exs) = select.select(iw, ow, iw, 3) - if exs: break + if exs: + break if ins: for i in ins: if i is soc: @@ -104,12 +106,13 @@ count = 0 else: print "\t" "idle", count - if count == max_idling: break + if count == max_idling: + break do_HEAD = do_GET do_POST = do_GET do_PUT = do_GET - do_DELETE=do_GET + do_DELETE = do_GET class ThreadingHTTPServer (SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): pass