Mercurial > hg
changeset 6476:ea230fb1c0e2
merge with main
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sat, 05 Apr 2008 00:04:50 +0200 |
parents | 93e4bb8ca275 (diff) 9c426da6b03b (current diff) |
children | 301d2441fae2 |
files | |
diffstat | 16 files changed, 197 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Fri Apr 04 16:39:44 2008 +0200 +++ b/hgext/mq.py Sat Apr 05 00:04:50 2008 +0200 @@ -662,14 +662,14 @@ finally: del wlock - def strip(self, repo, rev, update=True, backup="all"): + def strip(self, repo, rev, update=True, backup="all", force=None): wlock = lock = None try: wlock = repo.wlock() lock = repo.lock() if update: - self.check_localchanges(repo, refresh=False) + self.check_localchanges(repo, force=force, refresh=False) urev = self.qparents(repo, rev) hg.clean(repo, urev) repo.dirstate.write() @@ -2043,7 +2043,7 @@ elif opts['nobackup']: backup = 'none' update = repo.dirstate.parents()[0] != revlog.nullid - repo.mq.strip(repo, rev, backup=backup, update=update) + repo.mq.strip(repo, rev, backup=backup, update=update, force=opts['force']) return 0 def select(ui, repo, *args, **opts): @@ -2352,7 +2352,8 @@ _('hg qseries [-ms]')), "^strip": (strip, - [('b', 'backup', None, _('bundle unrelated changesets')), + [('f', 'force', None, _('force removal with local changes')), + ('b', 'backup', None, _('bundle unrelated changesets')), ('n', 'nobackup', None, _('no backups'))], _('hg strip [-f] [-b] [-n] REV')), "qtop": (top, [] + seriesopts, _('hg qtop [-s]')),
--- a/hgext/win32text.py Fri Apr 04 16:39:44 2008 +0200 +++ b/hgext/win32text.py Sat Apr 05 00:04:50 2008 +0200 @@ -22,7 +22,6 @@ # [hooks] # pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf -from mercurial import util from mercurial.i18n import gettext as _ from mercurial.node import bin, short import re @@ -47,15 +46,19 @@ def dumbencode(s, cmd): return s.replace('\r\n', '\n') +def clevertest(s, cmd): + if '\0' in s: return False + return True + def cleverdecode(s, cmd, **kwargs): - if util.binary(s): - return s - return dumbdecode(s, cmd, **kwargs) + if clevertest(s, cmd): + return dumbdecode(s, cmd, **kwargs) + return s def cleverencode(s, cmd): - if util.binary(s): - return s - return dumbencode(s, cmd) + if clevertest(s, cmd): + return dumbencode(s, cmd) + return s _filters = { 'dumbdecode:': dumbdecode, @@ -72,7 +75,7 @@ if f not in c: continue data = c[f].data() - if not util.binary(data) and '\r\n' in data: + if '\0' not in data and '\r\n' in data: if not halt: ui.warn(_('Attempt to commit or push text file(s) ' 'using CRLF line endings\n'))
--- a/mercurial/commands.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/commands.py Sat Apr 05 00:04:50 2008 +0200 @@ -1047,6 +1047,9 @@ self.colstart = colstart self.colend = colend + def __hash__(self): + return hash((self.linenum, self.line)) + def __eq__(self, other): return self.line == other.line @@ -3037,7 +3040,7 @@ _('ignore changes in the amount of white space')), ('B', 'ignore-blank-lines', None, _('ignore changes whose lines are all blank')), - ('U', 'unified', 3, + ('U', 'unified', '', _('number of lines of context to show')) ] + walkopts, _('hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
--- a/mercurial/context.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/context.py Sat Apr 05 00:04:50 2008 +0200 @@ -34,6 +34,12 @@ def __repr__(self): return "<changectx %s>" % str(self) + def __hash__(self): + try: + return hash(self._rev) + except AttributeError: + return id(self) + def __eq__(self, other): try: return self._rev == other._rev @@ -210,6 +216,12 @@ def __repr__(self): return "<filectx %s>" % str(self) + def __hash__(self): + try: + return hash((self._path, self._fileid)) + except AttributeError: + return id(self) + def __eq__(self, other): try: return (self._path == other._path
--- a/mercurial/keepalive.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/keepalive.py Sat Apr 05 00:04:50 2008 +0200 @@ -19,6 +19,8 @@ # Modified by Benoit Boissinot: # - fix for digest auth (inspired from urllib2.py @ Python v2.4) +# Modified by Dirkjan Ochtman: +# - import md5 function from a local util module """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. @@ -450,7 +452,7 @@ keepalive_handler.close_all() def continuity(url): - import md5 + from util import md5 format = '%25s: %s' # first fetch the file with the normal http handler
--- a/mercurial/mdiff.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/mdiff.py Sat Apr 05 00:04:50 2008 +0200 @@ -5,7 +5,8 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import bdiff, mpatch, re, struct, util, md5 +from i18n import _ +import bdiff, mpatch, re, struct, util def splitnewlines(text): '''like str.splitlines, but only split on newlines.''' @@ -47,6 +48,12 @@ v = self.defaults[k] setattr(self, k, v) + try: + self.context = int(self.context) + except ValueError: + raise util.Abort(_('diff context lines count must be ' + 'an integer, not %r') % self.context) + defaultopts = diffopts() def wsclean(opts, text): @@ -73,7 +80,7 @@ if not opts.text and (util.binary(a) or util.binary(b)): def h(v): # md5 is used instead of sha1 because md5 is supposedly faster - return md5.new(v).digest() + return util.md5(v).digest() if a and b and len(a) == len(b) and h(a) == h(b): return "" l = ['Binary file %s has changed\n' % fn1]
--- a/mercurial/patch.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/patch.py Sat Apr 05 00:04:50 2008 +0200 @@ -9,7 +9,7 @@ from i18n import _ from node import hex, nullid, short import base85, cmdutil, mdiff, util, context, revlog, diffhelpers, copies -import cStringIO, email.Parser, os, popen2, re, sha, errno +import cStringIO, email.Parser, os, popen2, re, errno import sys, tempfile, zlib class PatchError(Exception): @@ -1055,9 +1055,9 @@ return err def diffopts(ui, opts={}, untrusted=False): - def get(key, name=None): + def get(key, name=None, getter=ui.configbool): return (opts.get(key) or - ui.configbool('diff', name or key, None, untrusted=untrusted)) + getter('diff', name or key, None, untrusted=untrusted)) return mdiff.diffopts( text=opts.get('text'), git=get('git'), @@ -1066,7 +1066,7 @@ ignorews=get('ignore_all_space', 'ignorews'), ignorewsamount=get('ignore_space_change', 'ignorewsamount'), ignoreblanklines=get('ignore_blank_lines', 'ignoreblanklines'), - context=get('unified')) + context=get('unified', getter=ui.config)) def updatedir(ui, repo, patches): '''Update dirstate after patch application according to metadata''' @@ -1120,7 +1120,7 @@ if not text: return '0' * 40 l = len(text) - s = sha.new('blob %d\0' % l) + s = util.sha1('blob %d\0' % l) s.update(text) return s.hexdigest()
--- a/mercurial/revlog.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/revlog.py Sat Apr 05 00:04:50 2008 +0200 @@ -13,13 +13,13 @@ from node import bin, hex, nullid, nullrev, short from i18n import _ import changegroup, errno, ancestor, mdiff -import sha, struct, util, zlib +import struct, util, zlib _pack = struct.pack _unpack = struct.unpack _compress = zlib.compress _decompress = zlib.decompress -_sha = sha.new +_sha = util.sha1 # revlog flags REVLOGV0 = 0
--- a/mercurial/util.py Fri Apr 04 16:39:44 2008 +0200 +++ b/mercurial/util.py Sat Apr 05 00:04:50 2008 +0200 @@ -17,12 +17,38 @@ import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil import urlparse +# Python compatibility + try: set = set frozenset = frozenset except NameError: from sets import Set as set, ImmutableSet as frozenset +_md5 = None +def md5(s): + global _md5 + if _md5 is None: + try: + import hashlib + _md5 = hashlib.md5 + except ImportError: + import md5 + _md5 = md5.md5 + return _md5(s) + +_sha1 = None +def sha1(s): + global _sha1 + if _sha1 is None: + try: + import hashlib + _sha1 = hashlib.sha1 + except ImportError: + import sha + _sha1 = sha.sha + return _sha1(s) + try: _encoding = os.environ.get("HGENCODING") if sys.platform == 'darwin' and not _encoding:
--- a/templates/coal/fileannotate.tmpl Fri Apr 04 16:39:44 2008 +0200 +++ b/templates/coal/fileannotate.tmpl Sat Apr 05 00:04:50 2008 +0200 @@ -29,7 +29,7 @@ <div class="main"> <h2>{repo|escape}</h2> -<h3>Annotate {file|escape} @ {diff}:{node|short}</h2> +<h3>annotate {file|escape} @ {rev}:{node|short}</h2> <form class="search" action="{url}log"> {sessionvars%hiddenformentry}
--- a/tests/md5sum.py Fri Apr 04 16:39:44 2008 +0200 +++ b/tests/md5sum.py Sat Apr 05 00:04:50 2008 +0200 @@ -7,7 +7,11 @@ # GPL-compatible. import sys -import md5 + +try: + from hashlib import md5 +except ImportError: + from md5 import md5 for filename in sys.argv[1:]: try: @@ -16,7 +20,7 @@ sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) sys.exit(1) - m = md5.new() + m = md5() try: while 1: data = fp.read(8192)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-diff-unified Sat Apr 05 00:04:50 2008 +0200 @@ -0,0 +1,49 @@ +#!/bin/sh + +hg init repo +cd repo +cat > a <<EOF +c +c +a +a +b +a +a +c +c +EOF +hg ci -Am adda +cat > a <<EOF +c +c +a +a +dd +a +a +c +c +EOF + +echo '% default context' +hg diff --nodates + +echo '% invalid --unified' +hg diff --nodates -U foo + +echo '% --unified=2' +hg diff --nodates -U 2 + +echo '% diff.unified=2' +hg --config diff.unified=2 diff --nodates + +echo '% diff.unified=2 --unified=1' +hg diff --nodates -U 1 + +echo '% invalid diff.unified' +hg --config diff.unified=foo diff --nodates + +exit 0 + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-diff-unified.out Sat Apr 05 00:04:50 2008 +0200 @@ -0,0 +1,49 @@ +adding a +% default context +diff -r cf9f4ba66af2 a +--- a/a ++++ b/a +@@ -2,7 +2,7 @@ + c + a + a +-b ++dd + a + a + c +% invalid --unified +abort: diff context lines count must be an integer, not 'foo' +% --unified=2 +diff -r cf9f4ba66af2 a +--- a/a ++++ b/a +@@ -3,5 +3,5 @@ + a + a +-b ++dd + a + a +% diff.unified=2 +diff -r cf9f4ba66af2 a +--- a/a ++++ b/a +@@ -3,5 +3,5 @@ + a + a +-b ++dd + a + a +% diff.unified=2 --unified=1 +diff -r cf9f4ba66af2 a +--- a/a ++++ b/a +@@ -4,3 +4,3 @@ + a +-b ++dd + a +% invalid diff.unified +abort: diff context lines count must be an integer, not 'foo'
--- a/tests/test-help.out Fri Apr 04 16:39:44 2008 +0200 +++ b/tests/test-help.out Sat Apr 05 00:04:50 2008 +0200 @@ -205,7 +205,7 @@ -w --ignore-all-space ignore white space when comparing lines -b --ignore-space-change ignore changes in the amount of white space -B --ignore-blank-lines ignore changes whose lines are all blank - -U --unified number of lines of context to show (default: 3) + -U --unified number of lines of context to show -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns
--- a/tests/test-mq Fri Apr 04 16:39:44 2008 +0200 +++ b/tests/test-mq Sat Apr 05 00:04:50 2008 +0200 @@ -266,6 +266,14 @@ hg strip tip 2>&1 | sed 's/\(saving bundle to \).*/\1/' hg unbundle .hg/strip-backup/* +echo % strip with local changes, should complain +hg up +echo y>y +hg add y +hg strip tip | sed 's/\(saving bundle to \).*/\1/' +echo % --force strip with local changes +hg strip -f tip 2>&1 | sed 's/\(saving bundle to \).*/\1/' + echo '% cd b; hg qrefresh' hg init refresh cd refresh
--- a/tests/test-mq.out Fri Apr 04 16:39:44 2008 +0200 +++ b/tests/test-mq.out Sat Apr 05 00:04:50 2008 +0200 @@ -250,6 +250,12 @@ adding file changes added 1 changesets with 1 changes to 1 files (run 'hg update' to get a working copy) +% strip with local changes, should complain +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +abort: local changes found +% --force strip with local changes +0 files updated, 0 files merged, 2 files removed, 0 files unresolved +saving bundle to % cd b; hg qrefresh adding a foo