merge.
--- a/doc/hg.1.txt Sat Aug 12 16:04:49 2006 -0700
+++ b/doc/hg.1.txt Sat Aug 12 16:05:09 2006 -0700
@@ -216,6 +216,6 @@
COPYING
-------
-Copyright \(C) 2005 Matt Mackall.
+Copyright \(C) 2005, 2006 Matt Mackall.
Free use of this software is granted under the terms of the GNU General
Public License (GPL).
--- a/doc/hgmerge.1.txt Sat Aug 12 16:04:49 2006 -0700
+++ b/doc/hgmerge.1.txt Sat Aug 12 16:05:09 2006 -0700
@@ -30,6 +30,6 @@
COPYING
-------
-Copyright \(C) 2005 Matt Mackall.
+Copyright \(C) 2005, 2006 Matt Mackall.
Free use of this software is granted under the terms of the GNU General
Public License (GPL).
--- a/doc/hgrc.5.txt Sat Aug 12 16:04:49 2006 -0700
+++ b/doc/hgrc.5.txt Sat Aug 12 16:05:09 2006 -0700
@@ -306,7 +306,7 @@
smtp::
Configuration for extensions that need to send email messages.
host;;
- Optional. Host name of mail server. Default: "mail".
+ Host name of mail server, e.g. "mail.example.com".
port;;
Optional. Port to connect to on mail server. Default: 25.
tls;;
--- a/doc/ja/hg.1.ja.txt Sat Aug 12 16:04:49 2006 -0700
+++ b/doc/ja/hg.1.ja.txt Sat Aug 12 16:05:09 2006 -0700
@@ -862,6 +862,6 @@
著作権情報
-----
-Copyright (C) 2005 Matt Mackall.
+Copyright (C) 2005, 2006 Matt Mackall.
このソフトウェアの自由な使用は GNU 一般公有使用許諾 (GPL) のもとで
認められます。
--- a/doc/ja/hgmerge.1.ja.txt Sat Aug 12 16:04:49 2006 -0700
+++ b/doc/ja/hgmerge.1.ja.txt Sat Aug 12 16:05:09 2006 -0700
@@ -32,6 +32,6 @@
著作権情報
----
-Copyright (C) 2005 Matt Mackall.
+Copyright (C) 2005, 2006 Matt Mackall.
このソフトウェアの自由な使用は GNU 一般公有使用許諾 (GPL) のもとで
認められます。
--- a/hgext/fetch.py Sat Aug 12 16:04:49 2006 -0700
+++ b/hgext/fetch.py Sat Aug 12 16:05:09 2006 -0700
@@ -24,13 +24,13 @@
if modheads == 0:
return 0
if modheads == 1:
- return hg.update(repo, repo.changelog.tip(), wlock=wlock)
+ return hg.clean(repo, repo.changelog.tip(), wlock=wlock)
newheads = repo.heads(parent)
newchildren = [n for n in repo.heads(parent) if n != parent]
newparent = parent
if newchildren:
newparent = newchildren[0]
- hg.update(repo, newparent, wlock=wlock)
+ hg.clean(repo, newparent, wlock=wlock)
newheads = [n for n in repo.heads() if n != newparent]
err = False
if newheads:
--- a/hgext/hgk.py Sat Aug 12 16:04:49 2006 -0700
+++ b/hgext/hgk.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# Minimal support for git commands on an hg repository
#
-# Copyright 2005 Chris Mason <mason@suse.com>
+# 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, incorporated herein by reference.
--- a/hgext/mq.py Sat Aug 12 16:04:49 2006 -0700
+++ b/hgext/mq.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,6 @@
-
# queue.py - patch queues for mercurial
#
-# Copyright 2005 Chris Mason <mason@suse.com>
+# 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, incorporated herein by reference.
@@ -31,9 +30,9 @@
'''
from mercurial.demandload import *
+from mercurial.i18n import gettext as _
demandload(globals(), "os sys re struct traceback errno bz2")
-from mercurial.i18n import gettext as _
-from mercurial import ui, hg, revlog, commands, util
+demandload(globals(), "mercurial:commands,hg,revlog,ui,util")
commands.norepo += " qclone qversion"
@@ -176,11 +175,11 @@
if exactneg:
return False, exactneg[0]
pos = [g for g in patchguards if g[0] == '+']
- nonpos = [g for g in pos if g[1:] not in guards]
+ exactpos = [g for g in pos if g[1:] in guards]
if pos:
- if not nonpos:
- return True, ''
- return False, nonpos
+ if exactpos:
+ return True, exactpos[0]
+ return False, pos
return True, ''
def explain_pushable(self, idx, all_patches=False):
@@ -561,7 +560,7 @@
r = self.qrepo()
if r: r.add([patch])
if commitfiles:
- self.refresh(repo, msg=None, short=True)
+ self.refresh(repo, short=True)
def strip(self, repo, rev, update=True, backup="all", wlock=None):
def limitheads(chlog, stop):
@@ -725,6 +724,8 @@
# 2) a unique substring of the patch name was given
# 3) patchname[-+]num to indicate an offset in the series file
def lookup(self, patch, strict=False):
+ patch = patch and str(patch)
+
def partial_name(s):
if s in self.series:
return s
@@ -919,7 +920,7 @@
qp = self.qparents(repo, top)
commands.dodiff(sys.stdout, self.ui, repo, qp, None, files)
- def refresh(self, repo, msg=None, short=False):
+ def refresh(self, repo, msg='', short=False):
if len(self.applied) == 0:
self.ui.write("No patches applied\n")
return
@@ -1739,7 +1740,7 @@
this sets "stable" guard. mq will skip foo.patch (because it has
nagative match) but push bar.patch (because it has posative
- match). patch is pushed only if all posative guards match and no
+ match). patch is pushed if any posative guards match and no
nagative guards match.
with no arguments, default is to print current active guards.
@@ -1749,19 +1750,36 @@
when no guards active, patches with posative guards are skipped,
patches with nagative guards are pushed.
+ qselect can change guards of applied patches. it does not pop
+ guarded patches by default. use --pop to pop back to last applied
+ patch that is not guarded. use --reapply (implies --pop) to push
+ back to current patch afterwards, but skip guarded patches.
+
use -s/--series to print list of all guards in series file (no
other arguments needed). use -v for more information.'''
q = repo.mq
guards = q.active()
if args or opts['none']:
+ old_unapplied = q.unapplied(repo)
+ old_guarded = [i for i in xrange(len(q.applied)) if
+ not q.pushable(i)[0]]
q.set_active(args)
q.save_dirty()
if not args:
ui.status(_('guards deactivated\n'))
- if q.series:
- ui.status(_('%d of %d unapplied patches active\n') %
- (len(q.unapplied(repo)), len(q.series)))
+ if not opts['pop'] and not opts['reapply']:
+ unapplied = q.unapplied(repo)
+ guarded = [i for i in xrange(len(q.applied))
+ if not q.pushable(i)[0]]
+ if len(unapplied) != len(old_unapplied):
+ ui.status(_('number of unguarded, unapplied patches has '
+ 'changed from %d to %d\n') %
+ (len(old_unapplied), len(unapplied)))
+ if len(guarded) != len(old_guarded):
+ ui.status(_('number of guarded, applied patches has changed '
+ 'from %d to %d\n') %
+ (len(old_guarded), len(guarded)))
elif opts['series']:
guards = {}
noguards = 0
@@ -1789,9 +1807,51 @@
ui.write(g, '\n')
else:
ui.write(_('no active guards\n'))
+ reapply = opts['reapply'] and q.applied and q.appliedname(-1)
+ popped = False
+ if opts['pop'] or opts['reapply']:
+ for i in xrange(len(q.applied)):
+ pushable, reason = q.pushable(i)
+ if not pushable:
+ ui.status(_('popping guarded patches\n'))
+ popped = True
+ if i == 0:
+ q.pop(repo, all=True)
+ else:
+ q.pop(repo, i-1)
+ break
+ if popped:
+ try:
+ if reapply:
+ ui.status(_('reapplying unguarded patches\n'))
+ q.push(repo, reapply)
+ finally:
+ q.save_dirty()
def reposetup(ui, repo):
class mqrepo(repo.__class__):
+ def abort_if_wdir_patched(self, errmsg, force=False):
+ if self.mq.applied and not force:
+ parent = revlog.hex(self.dirstate.parents()[0])
+ if parent in [s.rev for s in self.mq.applied]:
+ raise util.Abort(errmsg)
+
+ def commit(self, *args, **opts):
+ if len(args) >= 6:
+ force = args[5]
+ else:
+ force = opts.get('force')
+ self.abort_if_wdir_patched(
+ _('cannot commit over an applied mq patch'),
+ force)
+
+ return super(mqrepo, self).commit(*args, **opts)
+
+ def push(self, remote, force=False, revs=None):
+ if self.mq.applied and not force:
+ raise util.Abort(_('source has mq patches applied'))
+ return super(mqrepo, self).push(remote, force, revs)
+
def tags(self):
if self.tagscache:
return self.tagscache
@@ -1813,8 +1873,9 @@
return tagscache
- repo.__class__ = mqrepo
- repo.mq = queue(ui, repo.join(""))
+ if repo.local():
+ repo.__class__ = mqrepo
+ repo.mq = queue(ui, repo.join(""))
cmdtable = {
"qapplied": (applied, [], 'hg qapplied [PATCH]'),
@@ -1906,8 +1967,11 @@
'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'),
"qselect": (select,
[('n', 'none', None, _('disable all guards')),
- ('s', 'series', None, _('list all guards in series file'))],
- 'hg qselect [GUARDS]'),
+ ('s', 'series', None, _('list all guards in series file')),
+ ('', 'pop', None,
+ _('pop to before first guarded applied patch')),
+ ('', 'reapply', None, _('pop, then reapply patches'))],
+ 'hg qselect [OPTION...] [GUARD...]'),
"qseries":
(series,
[('m', 'missing', None, 'print patches not in series'),
@@ -1922,4 +1986,3 @@
"qtop": (top, [], 'hg qtop'),
"qunapplied": (unapplied, [], 'hg qunapplied [PATCH]'),
}
-
--- a/mercurial/archival.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/archival.py Sat Aug 12 16:05:09 2006 -0700
@@ -163,11 +163,12 @@
change = repo.changelog.read(node)
mn = change[0]
archiver = archivers[kind](dest, prefix, mtime or change[2][0])
- mf = repo.manifest.read(mn).items()
- mf.sort()
+ m = repo.manifest.read(mn)
+ items = m.items()
+ items.sort()
write('.hg_archival.txt', 0644,
'repo: %s\nnode: %s\n' % (hex(repo.changelog.node(0)), hex(node)))
- for filename, filenode in mf:
- write(filename, mf.execf(filename) and 0755 or 0644,
+ for filename, filenode in items:
+ write(filename, m.execf(filename) and 0755 or 0644,
repo.file(filename).read(filenode))
archiver.done()
--- a/mercurial/bdiff.c Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/bdiff.c Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
/*
bdiff.c - efficient binary diff extension for Mercurial
- Copyright 2005 Matt Mackall <mpm@selenic.com>
+ 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, incorporated herein by reference.
--- a/mercurial/changelog.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/changelog.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# changelog.py - changelog class for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/commands.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/commands.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# commands.py - command processing for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
@@ -10,9 +10,9 @@
from i18n import gettext as _
demandload(globals(), "os re sys signal shutil imp urllib pdb")
demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo")
-demandload(globals(), "fnmatch mdiff random signal tempfile time")
+demandload(globals(), "fnmatch mdiff difflib patch random signal tempfile time")
demandload(globals(), "traceback errno socket version struct atexit sets bz2")
-demandload(globals(), "archival cStringIO changegroup email.Parser")
+demandload(globals(), "archival cStringIO changegroup")
demandload(globals(), "hgweb.server sshserver")
class UnknownCommand(Exception):
@@ -633,7 +633,7 @@
ui.write(_("Mercurial Distributed SCM (version %s)\n")
% version.get_version())
ui.status(_(
- "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n"
+ "\nCopyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>\n"
"This is free software; see the source for copying conditions. "
"There is NO\nwarranty; "
"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
@@ -1644,42 +1644,56 @@
self.linenum = linenum
self.colstart = colstart
self.colend = colend
+
def __eq__(self, other):
return self.line == other.line
- def __hash__(self):
- return hash(self.line)
matches = {}
+ copies = {}
def grepbody(fn, rev, body):
- matches[rev].setdefault(fn, {})
+ matches[rev].setdefault(fn, [])
m = matches[rev][fn]
for lnum, cstart, cend, line in matchlines(body):
s = linestate(line, lnum, cstart, cend)
- m[s] = s
-
- # FIXME: prev isn't used, why ?
+ m.append(s)
+
+ def difflinestates(a, b):
+ sm = difflib.SequenceMatcher(None, a, b)
+ for tag, alo, ahi, blo, bhi in sm.get_opcodes():
+ if tag == 'insert':
+ for i in range(blo, bhi):
+ yield ('+', b[i])
+ elif tag == 'delete':
+ for i in range(alo, ahi):
+ yield ('-', a[i])
+ elif tag == 'replace':
+ for i in range(alo, ahi):
+ yield ('-', a[i])
+ for i in range(blo, bhi):
+ yield ('+', b[i])
+
prev = {}
ucache = {}
def display(fn, rev, states, prevstates):
- diff = list(sets.Set(states).symmetric_difference(sets.Set(prevstates)))
- diff.sort(lambda x, y: cmp(x.linenum, y.linenum))
counts = {'-': 0, '+': 0}
filerevmatches = {}
- for l in diff:
+ if incrementing or not opts['all']:
+ a, b = prevstates, states
+ else:
+ a, b = states, prevstates
+ for change, l in difflinestates(a, b):
if incrementing or not opts['all']:
- change = ((l in prevstates) and '-') or '+'
r = rev
else:
- change = ((l in states) and '-') or '+'
r = prev[fn]
- cols = [fn, str(rev)]
+ cols = [fn, str(r)]
if opts['line_number']:
cols.append(str(l.linenum))
if opts['all']:
cols.append(change)
if opts['user']:
- cols.append(trimuser(ui, getchange(rev)[1], rev,
- ucache))
+ cols.append(trimuser(ui, getchange(r)[1], rev,
+ ucache))
if opts['files_with_matches']:
c = (fn, rev)
if c in filerevmatches:
@@ -1696,10 +1710,12 @@
changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts)
count = 0
incrementing = False
+ follow = opts.get('follow')
for st, rev, fns in changeiter:
if st == 'window':
incrementing = rev
matches.clear()
+ copies.clear()
elif st == 'add':
change = repo.changelog.read(repo.lookup(str(rev)))
mf = repo.manifest.read(change[0])
@@ -1708,22 +1724,34 @@
if fn in skip:
continue
fstate.setdefault(fn, {})
+ copies.setdefault(rev, {})
try:
grepbody(fn, rev, getfile(fn).read(mf[fn]))
+ if follow:
+ copied = getfile(fn).renamed(mf[fn])
+ if copied:
+ copies[rev][fn] = copied[0]
except KeyError:
pass
elif st == 'iter':
states = matches[rev].items()
states.sort()
for fn, m in states:
+ copy = copies[rev].get(fn)
if fn in skip:
+ if copy:
+ skip[copy] = True
continue
if incrementing or not opts['all'] or fstate[fn]:
pos, neg = display(fn, rev, m, fstate[fn])
count += pos + neg
if pos and not opts['all']:
skip[fn] = True
+ if copy:
+ skip[copy] = True
fstate[fn] = m
+ if copy:
+ fstate[copy] = m
prev[fn] = rev
if not incrementing:
@@ -1732,7 +1760,8 @@
for fn, state in fstate:
if fn in skip:
continue
- display(fn, rev, {}, state)
+ if fn not in copies[prev[fn]]:
+ display(fn, rev, {}, state)
return (count == 0 and 1) or 0
def heads(ui, repo, **opts):
@@ -1814,81 +1843,23 @@
d = opts["base"]
strip = opts["strip"]
- mailre = re.compile(r'(?:From |[\w-]+:)')
-
- # attempt to detect the start of a patch
- # (this heuristic is borrowed from quilt)
- diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |' +
- 'retrieving revision [0-9]+(\.[0-9]+)*$|' +
- '(---|\*\*\*)[ \t])', re.MULTILINE)
-
- for patch in patches:
- pf = os.path.join(d, patch)
-
- message = None
- user = None
- date = None
- hgpatch = False
-
- p = email.Parser.Parser()
+ wlock = repo.wlock()
+ lock = repo.lock()
+
+ for p in patches:
+ pf = os.path.join(d, p)
+
if pf == '-':
- msg = p.parse(sys.stdin)
ui.status(_("applying patch from stdin\n"))
+ tmpname, message, user, date = patch.extract(ui, sys.stdin)
else:
- msg = p.parse(file(pf))
- ui.status(_("applying %s\n") % patch)
-
- fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
- tmpfp = os.fdopen(fd, 'w')
+ ui.status(_("applying %s\n") % p)
+ tmpname, message, user, date = patch.extract(ui, file(pf))
+
+ if tmpname is None:
+ raise util.Abort(_('no diffs found'))
+
try:
- message = msg['Subject']
- if message:
- message = message.replace('\n\t', ' ')
- ui.debug('Subject: %s\n' % message)
- user = msg['From']
- if user:
- ui.debug('From: %s\n' % user)
- diffs_seen = 0
- ok_types = ('text/plain', 'text/x-diff', 'text/x-patch')
- for part in msg.walk():
- content_type = part.get_content_type()
- ui.debug('Content-Type: %s\n' % content_type)
- if content_type not in ok_types:
- continue
- payload = part.get_payload(decode=True)
- m = diffre.search(payload)
- if m:
- ui.debug(_('found patch at byte %d\n') % m.start(0))
- diffs_seen += 1
- hgpatch = False
- fp = cStringIO.StringIO()
- if message:
- fp.write(message)
- fp.write('\n')
- for line in payload[:m.start(0)].splitlines():
- if line.startswith('# HG changeset patch'):
- ui.debug(_('patch generated by hg export\n'))
- hgpatch = True
- # drop earlier commit message content
- fp.seek(0)
- fp.truncate()
- elif hgpatch:
- if line.startswith('# User '):
- user = line[7:]
- ui.debug('From: %s\n' % user)
- elif line.startswith("# Date "):
- date = line[7:]
- if not line.startswith('# '):
- fp.write(line)
- fp.write('\n')
- message = fp.getvalue()
- if tmpfp:
- tmpfp.write(payload)
- if not payload.endswith('\n'):
- tmpfp.write('\n')
- elif not diffs_seen and message and content_type == 'text/plain':
- message += '\n' + payload
-
if opts['message']:
# pickup the cmdline msg
message = opts['message']
@@ -1900,18 +1871,46 @@
message = None
ui.debug(_('message:\n%s\n') % message)
- tmpfp.close()
- if not diffs_seen:
- raise util.Abort(_('no diffs found'))
-
- files = util.patch(strip, tmpname, ui, cwd=repo.root)
+ files = patch.patch(strip, tmpname, ui, cwd=repo.root)
+ removes = []
if len(files) > 0:
- cfiles = files
+ cfiles = files.keys()
+ copies = []
+ copts = {'after': False, 'force': False}
cwd = repo.getcwd()
if cwd:
- cfiles = [util.pathto(cwd, f) for f in files]
- addremove_lock(ui, repo, cfiles, {})
- repo.commit(files, message, user, date)
+ cfiles = [util.pathto(cwd, f) for f in files.keys()]
+ for f in files:
+ ctype, gp = files[f]
+ if ctype == 'RENAME':
+ copies.append((gp.oldpath, gp.path, gp.copymod))
+ removes.append(gp.oldpath)
+ elif ctype == 'COPY':
+ copies.append((gp.oldpath, gp.path, gp.copymod))
+ elif ctype == 'DELETE':
+ removes.append(gp.path)
+ for src, dst, after in copies:
+ absdst = os.path.join(repo.root, dst)
+ if not after and os.path.exists(absdst):
+ raise util.Abort(_('patch creates existing file %s') % dst)
+ if cwd:
+ src, dst = [util.pathto(cwd, f) for f in (src, dst)]
+ copts['after'] = after
+ errs, copied = docopy(ui, repo, (src, dst), copts, wlock=wlock)
+ if errs:
+ raise util.Abort(errs)
+ if removes:
+ repo.remove(removes, True, wlock=wlock)
+ for f in files:
+ ctype, gp = files[f]
+ if gp and gp.mode:
+ x = gp.mode & 0100 != 0
+ dst = os.path.join(repo.root, gp.path)
+ util.set_exec(dst, x)
+ addremove_lock(ui, repo, cfiles, {}, wlock=wlock)
+ files = files.keys()
+ files.extend([r for r in removes if r not in files])
+ repo.commit(files, message, user, date, wlock=wlock, lock=lock)
finally:
os.unlink(tmpname)
@@ -3091,6 +3090,8 @@
(grep,
[('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')),
('i', 'ignore-case', None, _('ignore case when matching')),
('l', 'files-with-matches', None,
_('print only filenames and revs that match')),
@@ -3545,6 +3546,7 @@
mod = sys.modules[name]
if hasattr(mod, 'reposetup'):
mod.reposetup(u, repo)
+ hg.repo_setup_hooks.append(mod.reposetup)
except hg.RepoError:
if cmd not in optionalrepo.split():
raise
--- a/mercurial/context.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/context.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# context.py - changeset and file context objects for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# Copyright 2006 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
--- a/mercurial/dirstate.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/dirstate.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
"""
dirstate.py - working directory tracking for mercurial
-Copyright 2005 Matt Mackall <mpm@selenic.com>
+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, incorporated herein by reference.
--- a/mercurial/filelog.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/filelog.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# filelog.py - file history class for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/hg.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/hg.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,7 @@
# hg.py - repository classes for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
@@ -48,9 +49,14 @@
return False
return repo.local()
+repo_setup_hooks = []
+
def repository(ui, path=None, create=False):
"""return a repository object for the specified path"""
- return _lookup(path).instance(ui, path, create)
+ repo = _lookup(path).instance(ui, path, create)
+ for hook in repo_setup_hooks:
+ hook(ui, repo)
+ return repo
def defaultdest(source):
'''return default destination of clone if none is given'''
--- a/mercurial/hgweb/common.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/hgweb/common.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
# hgweb/common.py - Utility functions needed by hgweb_mod and hgwebdir_mod
#
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/hgweb/hgweb_mod.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/hgweb/hgweb_mod.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
# hgweb/hgweb_mod.py - Web interface for a repository.
#
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
@@ -398,7 +398,7 @@
parent=self.siblings(fl.parents(n), fl.rev, file=f),
child=self.siblings(fl.children(n), fl.rev, file=f),
rename=self.renamelink(fl, n),
- permissions=self.repo.manifest.read(mfn).execf[f])
+ permissions=self.repo.manifest.read(mfn).execf(f))
def fileannotate(self, f, node):
bcache = {}
@@ -452,7 +452,7 @@
rename=self.renamelink(fl, n),
parent=self.siblings(fl.parents(n), fl.rev, file=f),
child=self.siblings(fl.children(n), fl.rev, file=f),
- permissions=self.repo.manifest.read(mfn).execf[f])
+ permissions=self.repo.manifest.read(mfn).execf(f))
def manifest(self, mnode, path):
man = self.repo.manifest
@@ -495,7 +495,7 @@
"filenode": hex(fnode),
"parity": self.stripes(parity),
"basename": f,
- "permissions": mf.execf[full]}
+ "permissions": mf.execf(full)}
parity += 1
def dirlist(**map):
--- a/mercurial/hgweb/hgwebdir_mod.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
# hgweb/hgwebdir_mod.py - Web interface for a directory of repositories.
#
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/hgweb/request.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/hgweb/request.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
# hgweb/request.py - An http request from either CGI or the standalone server.
#
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/hgweb/server.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/hgweb/server.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
# hgweb/server.py - The standalone hg web server.
#
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/httprangereader.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/httprangereader.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# httprangereader.py - just what it says
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/httprepo.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/httprepo.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,7 @@
# httprepo.py - HTTP repository proxy classes for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/i18n.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/i18n.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
"""
i18n.py - internationalization support for mercurial
-Copyright 2005 Matt Mackall <mpm@selenic.com>
+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, incorporated herein by reference.
--- a/mercurial/localrepo.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/localrepo.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# localrepo.py - read/write repository class for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
@@ -502,7 +502,6 @@
except IOError:
try:
del m1[f]
- del m1[f]
if update_dirstate:
self.dirstate.forget([f])
except:
--- a/mercurial/lock.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/lock.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# lock.py - simple locking scheme for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/manifest.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/manifest.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# manifest.py - manifest revision class for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
@@ -11,7 +11,9 @@
demandload(globals(), "array bisect struct")
class manifestdict(dict):
- def __init__(self, mapping={}, flags={}):
+ def __init__(self, mapping=None, flags=None):
+ if mapping is None: mapping = {}
+ if flags is None: flags = {}
dict.__init__(self, mapping)
self._flags = flags
def flags(self, f):
@@ -27,8 +29,9 @@
fl = entry[40:-1]
if fl: self._flags[f] = fl
def set(self, f, execf=False, linkf=False):
- if execf: self._flags[f] = "x"
- if linkf: self._flags[f] = "x"
+ if linkf: self._flags[f] = "l"
+ elif execf: self._flags[f] = "x"
+ else: self._flags[f] = ""
def copy(self):
return manifestdict(dict.copy(self), dict.copy(self._flags))
--- a/mercurial/mdiff.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/mdiff.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# mdiff.py - diff and patch routines for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/mpatch.c Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/mpatch.c Sat Aug 12 16:05:09 2006 -0700
@@ -14,7 +14,7 @@
allocation of intermediate Python objects. Working memory is about 2x
the total number of hunks.
- Copyright 2005 Matt Mackall <mpm@selenic.com>
+ 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, incorporated herein by reference.
--- a/mercurial/node.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/node.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,7 +1,7 @@
"""
node.py - basic nodeid manipulation for mercurial
-Copyright 2005 Matt Mackall <mpm@selenic.com>
+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, incorporated herein by reference.
--- a/mercurial/packagescan.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/packagescan.py Sat Aug 12 16:05:09 2006 -0700
@@ -2,7 +2,7 @@
# Used for the py2exe distutil.
# This module must be the first mercurial module imported in setup.py
#
-# Copyright 2005 Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
+# Copyright 2005, 2006 Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/patch.py Sat Aug 12 16:05:09 2006 -0700
@@ -0,0 +1,251 @@
+# patch.py - patch file parsing routines
+#
+# Copyright 2006 Brendan Cully <brendan@kublai.com>
+#
+# This software may be used and distributed according to the terms
+# of the GNU General Public License, incorporated herein by reference.
+
+from demandload import demandload
+from i18n import gettext as _
+demandload(globals(), "util")
+demandload(globals(), "cStringIO email.Parser os re shutil tempfile")
+
+def extract(ui, fileobj):
+ '''extract patch from data read from fileobj.
+
+ patch can be normal patch or contained in email message.
+
+ return tuple (filename, message, user, date). any item in returned
+ tuple can be None. if filename is None, fileobj did not contain
+ patch. caller must unlink filename when done.'''
+
+ # attempt to detect the start of a patch
+ # (this heuristic is borrowed from quilt)
+ diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |' +
+ 'retrieving revision [0-9]+(\.[0-9]+)*$|' +
+ '(---|\*\*\*)[ \t])', re.MULTILINE)
+
+ fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
+ tmpfp = os.fdopen(fd, 'w')
+ try:
+ hgpatch = False
+
+ msg = email.Parser.Parser().parse(fileobj)
+
+ message = msg['Subject']
+ user = msg['From']
+ # should try to parse msg['Date']
+ date = None
+
+ if message:
+ message = message.replace('\n\t', ' ')
+ ui.debug('Subject: %s\n' % message)
+ if user:
+ ui.debug('From: %s\n' % user)
+ diffs_seen = 0
+ ok_types = ('text/plain', 'text/x-diff', 'text/x-patch')
+
+ for part in msg.walk():
+ content_type = part.get_content_type()
+ ui.debug('Content-Type: %s\n' % content_type)
+ if content_type not in ok_types:
+ continue
+ payload = part.get_payload(decode=True)
+ m = diffre.search(payload)
+ if m:
+ ui.debug(_('found patch at byte %d\n') % m.start(0))
+ diffs_seen += 1
+ cfp = cStringIO.StringIO()
+ if message:
+ cfp.write(message)
+ cfp.write('\n')
+ for line in payload[:m.start(0)].splitlines():
+ if line.startswith('# HG changeset patch'):
+ ui.debug(_('patch generated by hg export\n'))
+ hgpatch = True
+ # drop earlier commit message content
+ cfp.seek(0)
+ cfp.truncate()
+ elif hgpatch:
+ if line.startswith('# User '):
+ user = line[7:]
+ ui.debug('From: %s\n' % user)
+ elif line.startswith("# Date "):
+ date = line[7:]
+ if not line.startswith('# '):
+ cfp.write(line)
+ cfp.write('\n')
+ message = cfp.getvalue()
+ if tmpfp:
+ tmpfp.write(payload)
+ if not payload.endswith('\n'):
+ tmpfp.write('\n')
+ elif not diffs_seen and message and content_type == 'text/plain':
+ message += '\n' + payload
+ except:
+ tmpfp.close()
+ os.unlink(tmpname)
+ raise
+
+ tmpfp.close()
+ if not diffs_seen:
+ os.unlink(tmpname)
+ return None, message, user, date
+ return tmpname, message, user, date
+
+def readgitpatch(patchname):
+ """extract git-style metadata about patches from <patchname>"""
+ class gitpatch:
+ "op is one of ADD, DELETE, RENAME, MODIFY or COPY"
+ def __init__(self, path):
+ self.path = path
+ self.oldpath = None
+ self.mode = None
+ self.op = 'MODIFY'
+ self.copymod = False
+ self.lineno = 0
+
+ # Filter patch for git information
+ gitre = re.compile('diff --git a/(.*) b/(.*)')
+ pf = file(patchname)
+ gp = None
+ gitpatches = []
+ # Can have a git patch with only metadata, causing patch to complain
+ dopatch = False
+
+ lineno = 0
+ for line in pf:
+ lineno += 1
+ if line.startswith('diff --git'):
+ m = gitre.match(line)
+ if m:
+ if gp:
+ gitpatches.append(gp)
+ src, dst = m.group(1,2)
+ gp = gitpatch(dst)
+ gp.lineno = lineno
+ elif gp:
+ if line.startswith('--- '):
+ if gp.op in ('COPY', 'RENAME'):
+ gp.copymod = True
+ dopatch = 'filter'
+ gitpatches.append(gp)
+ gp = None
+ if not dopatch:
+ dopatch = True
+ continue
+ if line.startswith('rename from '):
+ gp.op = 'RENAME'
+ gp.oldpath = line[12:].rstrip()
+ elif line.startswith('rename to '):
+ gp.path = line[10:].rstrip()
+ elif line.startswith('copy from '):
+ gp.op = 'COPY'
+ gp.oldpath = line[10:].rstrip()
+ elif line.startswith('copy to '):
+ gp.path = line[8:].rstrip()
+ elif line.startswith('deleted file'):
+ gp.op = 'DELETE'
+ elif line.startswith('new file mode '):
+ gp.op = 'ADD'
+ gp.mode = int(line.rstrip()[-3:], 8)
+ elif line.startswith('new mode '):
+ gp.mode = int(line.rstrip()[-3:], 8)
+ if gp:
+ gitpatches.append(gp)
+
+ if not gitpatches:
+ dopatch = True
+
+ return (dopatch, gitpatches)
+
+def dogitpatch(patchname, gitpatches):
+ """Preprocess git patch so that vanilla patch can handle it"""
+ pf = file(patchname)
+ pfline = 1
+
+ fd, patchname = tempfile.mkstemp(prefix='hg-patch-')
+ tmpfp = os.fdopen(fd, 'w')
+
+ try:
+ for i in range(len(gitpatches)):
+ p = gitpatches[i]
+ if not p.copymod:
+ continue
+
+ if os.path.exists(p.path):
+ raise util.Abort(_("cannot create %s: destination already exists") %
+ p.path)
+
+ (src, dst) = [os.path.join(os.getcwd(), n)
+ for n in (p.oldpath, p.path)]
+
+ targetdir = os.path.dirname(dst)
+ if not os.path.isdir(targetdir):
+ os.makedirs(targetdir)
+ try:
+ shutil.copyfile(src, dst)
+ shutil.copymode(src, dst)
+ except shutil.Error, inst:
+ raise util.Abort(str(inst))
+
+ # rewrite patch hunk
+ while pfline < p.lineno:
+ tmpfp.write(pf.readline())
+ pfline += 1
+ tmpfp.write('diff --git a/%s b/%s\n' % (p.path, p.path))
+ line = pf.readline()
+ pfline += 1
+ while not line.startswith('--- a/'):
+ tmpfp.write(line)
+ line = pf.readline()
+ pfline += 1
+ tmpfp.write('--- a/%s\n' % p.path)
+
+ line = pf.readline()
+ while line:
+ tmpfp.write(line)
+ line = pf.readline()
+ except:
+ tmpfp.close()
+ os.unlink(patchname)
+ raise
+
+ tmpfp.close()
+ return patchname
+
+def patch(strip, patchname, ui, cwd=None):
+ """apply the patch <patchname> to the working directory.
+ a list of patched files is returned"""
+
+ (dopatch, gitpatches) = readgitpatch(patchname)
+
+ files = {}
+ if dopatch:
+ if dopatch == 'filter':
+ patchname = dogitpatch(patchname, gitpatches)
+ patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch')
+ args = []
+ if cwd:
+ args.append('-d %s' % util.shellquote(cwd))
+ fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
+ util.shellquote(patchname)))
+
+ if dopatch == 'filter':
+ False and os.unlink(patchname)
+
+ for line in fp:
+ line = line.rstrip()
+ ui.status("%s\n" % line)
+ if line.startswith('patching file '):
+ pf = util.parse_patch_output(line)
+ files.setdefault(pf, (None, None))
+ code = fp.close()
+ if code:
+ raise util.Abort(_("patch command failed: %s") %
+ util.explain_exit(code)[0])
+
+ for gp in gitpatches:
+ files[gp.path] = (gp.op, gp)
+
+ return files
--- a/mercurial/remoterepo.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/remoterepo.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
-# remoterepo - remote repositort proxy classes for mercurial
+# remoterepo - remote repository proxy classes for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/repo.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/repo.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,7 @@
# repo.py - repository base classes for mercurial
#
# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/revlog.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/revlog.py Sat Aug 12 16:05:09 2006 -0700
@@ -4,7 +4,7 @@
This provides efficient delta storage with O(1) retrieve and append
and O(changes) merge between branches
-Copyright 2005 Matt Mackall <mpm@selenic.com>
+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, incorporated herein by reference.
--- a/mercurial/sshrepo.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/sshrepo.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# sshrepo.py - ssh repository proxy class for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/sshserver.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/sshserver.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,7 @@
# sshserver.py - ssh protocol server support for mercurial
#
# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/statichttprepo.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/statichttprepo.py Sat Aug 12 16:05:09 2006 -0700
@@ -2,7 +2,7 @@
#
# This provides read-only repo access to repositories exported via static http
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/transaction.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/transaction.py Sat Aug 12 16:05:09 2006 -0700
@@ -6,7 +6,7 @@
# effectively log-structured, this should amount to simply truncating
# anything that isn't referenced in the changelog.
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/ui.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/ui.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,6 +1,6 @@
# ui.py - user interface bits for mercurial
#
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# 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, incorporated herein by reference.
--- a/mercurial/util.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/util.py Sat Aug 12 16:05:09 2006 -0700
@@ -2,6 +2,8 @@
util.py - Mercurial utility functions and platform specfic implementations
Copyright 2005 K. Thananchayan <thananck@yahoo.com>
+ Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
+ 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, incorporated herein by reference.
@@ -93,27 +95,6 @@
return p_name
return default
-def patch(strip, patchname, ui, cwd=None):
- """apply the patch <patchname> to the working directory.
- a list of patched files is returned"""
- patcher = find_in_path('gpatch', os.environ.get('PATH', ''), 'patch')
- args = []
- if cwd:
- args.append('-d %s' % shellquote(cwd))
- fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
- shellquote(patchname)))
- files = {}
- for line in fp:
- line = line.rstrip()
- ui.status("%s\n" % line)
- if line.startswith('patching file '):
- pf = parse_patch_output(line)
- files.setdefault(pf, 1)
- code = fp.close()
- if code:
- raise Abort(_("patch command failed: %s") % explain_exit(code)[0])
- return files.keys()
-
def binary(s):
"""return true if a string is binary data using diff's heuristic"""
if s and '\0' in s[:4096]:
--- a/mercurial/version.py Sat Aug 12 16:04:49 2006 -0700
+++ b/mercurial/version.py Sat Aug 12 16:05:09 2006 -0700
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 by Intevation GmbH
+# Copyright (C) 2005, 2006 by Intevation GmbH
# Author(s):
# Thomas Arendsen Hein <thomas@intevation.de>
#
--- a/tests/test-abort-checkin Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-abort-checkin Sat Aug 12 16:05:09 2006 -0700
@@ -3,6 +3,11 @@
HGRCPATH=$HGTMP/.hgrc; export HGRCPATH
echo "[extensions]" >> $HGTMP/.hgrc
echo "mq=" >> $HGTMP/.hgrc
+cat > $HGTMP/false <<EOF
+#!/bin/sh
+exit 1
+EOF
+chmod +x $HGTMP/false
hg init foo
cd foo
@@ -11,7 +16,7 @@
# mq may keep a reference to the repository so __del__ will not be called
# and .hg/journal.dirstate will not be deleted:
-HGEDITOR=false hg ci
-HGEDITOR=false hg ci
+HGEDITOR=$HGTMP/false hg ci
+HGEDITOR=$HGTMP/false hg ci
exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-git-import Sat Aug 12 16:05:09 2006 -0700
@@ -0,0 +1,122 @@
+#!/bin/sh
+
+hg init a
+cd a
+
+echo % new file
+hg import -mnew - <<EOF
+diff --git a/new b/new
+new file mode 100644
+index 0000000..7898192
+--- /dev/null
++++ b/new
+@@ -0,0 +1 @@
++a
+EOF
+
+echo % chmod +x
+hg import -msetx - <<EOF
+diff --git a/new b/new
+old mode 100644
+new mode 100755
+EOF
+
+test -x new || echo failed
+
+echo % copy
+hg import -mcopy - <<EOF
+diff --git a/new b/copy
+old mode 100755
+new mode 100644
+similarity index 100%
+copy from new
+copy to copy
+diff --git a/new b/copyx
+similarity index 100%
+copy from new
+copy to copyx
+EOF
+
+test -f copy -a ! -x copy || echo failed
+test -x copyx || echo failed
+cat copy
+hg cat copy
+
+echo % rename
+hg import -mrename - <<EOF
+diff --git a/copy b/rename
+similarity index 100%
+rename from copy
+rename to rename
+EOF
+
+hg locate
+
+echo % delete
+hg import -mdelete - <<EOF
+diff --git a/copyx b/copyx
+deleted file mode 100755
+index 7898192..0000000
+--- a/copyx
++++ /dev/null
+@@ -1 +0,0 @@
+-a
+EOF
+
+hg locate
+test -f copyx && echo failed || true
+
+echo % regular diff
+hg import -mregular - <<EOF
+diff --git a/rename b/rename
+index 7898192..72e1fe3 100644
+--- a/rename
++++ b/rename
+@@ -1 +1,5 @@
+ a
++a
++a
++a
++a
+EOF
+
+echo % copy and modify
+hg import -mcopymod - <<EOF
+diff --git a/rename b/copy2
+similarity index 80%
+copy from rename
+copy to copy2
+index 72e1fe3..b53c148 100644
+--- a/rename
++++ b/copy2
+@@ -1,5 +1,5 @@
+ a
+ a
+-a
++b
+ a
+ a
+EOF
+
+hg cat copy2
+
+echo % rename and modify
+hg import -mrenamemod - <<EOF
+diff --git a/copy2 b/rename2
+similarity index 80%
+rename from copy2
+rename to rename2
+index b53c148..8f81e29 100644
+--- a/copy2
++++ b/rename2
+@@ -1,5 +1,5 @@
+ a
+ a
+ b
+-a
++c
+ a
+EOF
+
+hg locate copy2
+hg cat rename2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-git-import.out Sat Aug 12 16:05:09 2006 -0700
@@ -0,0 +1,39 @@
+% new file
+applying patch from stdin
+patching file new
+% chmod +x
+applying patch from stdin
+% copy
+applying patch from stdin
+a
+a
+% rename
+applying patch from stdin
+copyx
+new
+rename
+% delete
+applying patch from stdin
+patching file copyx
+new
+rename
+% regular diff
+applying patch from stdin
+patching file rename
+% copy and modify
+applying patch from stdin
+patching file copy2
+a
+a
+b
+a
+a
+% rename and modify
+applying patch from stdin
+patching file rename2
+copy2: No such file or directory
+a
+a
+b
+c
+a
--- a/tests/test-globalopts Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-globalopts Sat Aug 12 16:05:09 2006 -0700
@@ -45,7 +45,7 @@
hg --cwd b tip --verbose
echo %% --config
-hg --cwd c --config paths.quuxfoo=bar paths | grep -q quuxfoo && echo quuxfoo
+hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
hg --cwd c --config '' tip -q
hg --cwd c --config a.b tip -q
hg --cwd c --config a tip -q
--- a/tests/test-grep Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-grep Sat Aug 12 16:05:09 2006 -0700
@@ -18,6 +18,13 @@
mv port1 port
hg commit -m 4 -u spam -d '4 0'
hg grep port port
-echo 'FIXME: history is wrong here'
hg grep --all -nu port port
hg grep import port
+
+hg cp port port2
+hg commit -m 4 -u spam -d '5 0'
+echo '% follow'
+hg grep -f 'import$' port2
+echo deport >> port2
+hg commit -m 5 -u eggs -d '6 0'
+hg grep -f --all -nu port port2
--- a/tests/test-grep.out Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-grep.out Sat Aug 12 16:05:09 2006 -0700
@@ -1,10 +1,25 @@
port:4:export
port:4:vaportight
port:4:import/export
-FIXME: history is wrong here
-port:1:1:-:eggs:import
-port:1:2:+:eggs:vaportight
-port:1:3:+:eggs:import/export
-port:0:2:+:spam:export
-port:0:1:+:spam:import
+port:4:4:-:spam:import/export
+port:3:4:+:eggs:import/export
+port:2:1:-:spam:import
+port:2:2:-:spam:export
+port:2:1:+:spam:export
+port:2:2:+:spam:vaportight
+port:2:3:+:spam:import/export
+port:1:2:+:eggs:export
+port:0:1:+:eggs:import
port:4:import/export
+% follow
+port:0:import
+port2:6:4:+:eggs:deport
+port:4:4:-:spam:import/export
+port:3:4:+:eggs:import/export
+port:2:1:-:spam:import
+port:2:2:-:spam:export
+port:2:1:+:spam:export
+port:2:2:+:spam:vaportight
+port:2:3:+:spam:import/export
+port:1:2:+:eggs:export
+port:0:1:+:eggs:import
--- a/tests/test-import Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-import Sat Aug 12 16:05:09 2006 -0700
@@ -72,7 +72,7 @@
echo % plain diff in email, no subject, no message body, should fail
hg clone -r0 a b
-grep -v '^\(Subject\|email\)' msg.patch | hg --cwd b import -
+egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
rm -rf b
echo % hg export in email, should use patch header
@@ -89,9 +89,10 @@
echo % hg import in a subdirectory
hg clone -r0 a b
hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch
-pushd b/d1/d2 2>&1 > /dev/null
+dir=`pwd`
+cd b/d1/d2 2>&1 > /dev/null
hg import ../../../tip.patch
-popd 2>&1 > /dev/null
+cd $dir
echo "% message should be 'subdir change'"
hg --cwd b tip | grep 'subdir change'
echo "% committer should be 'someoneelse'"
--- a/tests/test-mq Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-mq Sat Aug 12 16:05:09 2006 -0700
@@ -10,6 +10,10 @@
hg init a
cd a
echo a > a
+hg ci -Ama
+
+hg clone . ../k
+
mkdir b
echo z > b/z
hg ci -Ama
@@ -48,7 +52,7 @@
echo a >> a
hg qrefresh
-sed -e "s/\(^diff -r \)\([a-f0-9]* \)/\1 x/" \
+sed -e "s/^\(diff -r \)\([a-f0-9]* \)/\1 x/" \
-e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/test.patch
@@ -103,9 +107,19 @@
hg qprev
hg qapplied
+echo % commit should fail
+hg commit
+
+echo % push should fail
+hg push ../../k
+
echo % qunapplied
hg qunapplied
+echo % push should succeed
+hg qpop -a
+hg push ../../k
+
echo % strip
cd ../../b
echo x>x
--- a/tests/test-mq-guards Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-mq-guards Sat Aug 12 16:05:09 2006 -0700
@@ -63,22 +63,39 @@
hg qpush -a
hg qpop -a
-hg qguard a.patch +1 +2
+hg qguard a.patch +1
+hg qguard b.patch +2
hg qselect 1
+echo % should push a.patch, not b.patch
+hg qpush
+hg qpush
+hg qpop -a
+
+hg qselect 2
echo % should push b.patch
hg qpush
hg qpop -a
-hg qselect 2
+hg qselect 1 2
+echo % should push a.patch, b.patch
hg qpush
-hg qpop -a
-
-hg qselect 1 2
-echo % should push a.patch
hg qpush
hg qpop -a
hg qguard a.patch +1 +2 -3
hg qselect 1 2 3
+echo % list patches and guards
+hg qguard -l
+echo % list series
+hg qseries -v
+echo % list guards
+hg qselect
echo % should push b.patch
hg qpush
+
+hg qpush -a
+hg qselect -n --reapply
+echo % guards in series file: +1 +2 -3
+hg qselect -s
+echo % should show c.patch
+hg qapplied
--- a/tests/test-mq-guards.out Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-mq-guards.out Sat Aug 12 16:05:09 2006 -0700
@@ -13,7 +13,7 @@
applying b.patch
Now at: b.patch
Patch queue now empty
-3 of 3 unapplied patches active
+number of unguarded, unapplied patches has changed from 2 to 3
% should push a.patch
applying a.patch
Now at: a.patch
@@ -28,27 +28,57 @@
Now at: c.patch
Patch queue now empty
guards deactivated
-2 of 3 unapplied patches active
+number of unguarded, unapplied patches has changed from 3 to 2
% should push all
applying b.patch
applying c.patch
Now at: c.patch
Patch queue now empty
-2 of 3 unapplied patches active
+number of unguarded, unapplied patches has changed from 1 to 2
+% should push a.patch, not b.patch
+applying a.patch
+Now at: a.patch
+applying c.patch
+Now at: c.patch
+Patch queue now empty
% should push b.patch
applying b.patch
Now at: b.patch
Patch queue now empty
-2 of 3 unapplied patches active
+number of unguarded, unapplied patches has changed from 2 to 3
+% should push a.patch, b.patch
+applying a.patch
+Now at: a.patch
applying b.patch
Now at: b.patch
Patch queue now empty
-3 of 3 unapplied patches active
-% should push a.patch
-applying a.patch
-Now at: a.patch
-Patch queue now empty
-2 of 3 unapplied patches active
+number of unguarded, unapplied patches has changed from 3 to 2
+% list patches and guards
+a.patch: +1 +2 -3
+b.patch: +2
+c.patch: unguarded
+% list series
+0 G a.patch
+1 U b.patch
+2 U c.patch
+% list guards
+1
+2
+3
% should push b.patch
applying b.patch
Now at: b.patch
+applying c.patch
+Now at: c.patch
+guards deactivated
+popping guarded patches
+Patch queue now empty
+reapplying unguarded patches
+applying c.patch
+Now at: c.patch
+% guards in series file: +1 +2 -3
++1
++2
+-3
+% should show c.patch
+c.patch
--- a/tests/test-mq-qrefresh-replace-log-message Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-mq-qrefresh-replace-log-message Sat Aug 12 16:05:09 2006 -0700
@@ -33,7 +33,7 @@
echo bbbb > file
hg qrefresh -l logfile
echo =======================
-echo "Should display 'Third commit message\n This is the 3rd log message'"
+printf "Should display 'Third commit message\\\n This is the 3rd log message'\n"
hg log -l1 -v | sed -n '/description/,$p'
echo
@@ -46,6 +46,6 @@
echo " This is the 5th log message" >> logfile) |\
hg qrefresh -l-
echo =======================
-echo "Should display 'Fifth commit message\n This is the 5th log message'"
+printf "Should display 'Fifth commit message\\\n This is the 5th log message'\n"
hg log -l1 -v | sed -n '/description/,$p'
echo
--- a/tests/test-mq.out Sat Aug 12 16:04:49 2006 -0700
+++ b/tests/test-mq.out Sat Aug 12 16:05:09 2006 -0700
@@ -49,6 +49,7 @@
qunapplied print the patches not yet applied
strip strip a revision and all later revs on the same branch
adding a
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding b/z
% qinit
% -R qinit
@@ -102,8 +103,21 @@
test2.patch
Only one patch applied
test.patch
+% commit should fail
+abort: cannot commit over an applied mq patch
+% push should fail
+pushing to ../../k
+abort: source has mq patches applied
% qunapplied
test2.patch
+% push should succeed
+Patch queue now empty
+pushing to ../../k
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
% strip
adding x
0 files updated, 0 files merged, 1 files removed, 0 files unresolved