# HG changeset patch # User Thomas Arendsen Hein # Date 1201305991 -3600 # Node ID 4b8d568c65dd89230935d43064cce474140c9290 # Parent 48d01b1e315f1b0b871d8cf86a57e6c8ff6a4efc# Parent 597d8402087d7fa2a9b61c2f352d99670bd8faf8 merge with crew diff -r 48d01b1e315f -r 4b8d568c65dd hgext/keyword.py --- a/hgext/keyword.py Fri Jan 25 15:54:25 2008 -0500 +++ b/hgext/keyword.py Sat Jan 26 01:06:31 2008 +0100 @@ -94,8 +94,8 @@ '''Returns True if cmd should trigger restricted expansion. Keywords will only expanded when writing to working dir. Crucial for mq as expanded keywords should not make it into patches.''' - return cmd in ('diff1', - 'qimport', 'qnew', 'qpush', 'qrefresh', 'record', 'qrecord') + return cmd in ('diff1', 'record', + 'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord') _kwtemplater = None @@ -310,7 +310,7 @@ kwmaps = kwtemplater.templates if ui.configitems('keywordmaps'): # override maps from optional rcfile - for k, v in kwmaps.items(): + for k, v in kwmaps.iteritems(): ui.setconfig('keywordmaps', k, v) elif args: # simulate hgrc parsing @@ -329,7 +329,7 @@ demostatus('config using %s keyword template maps' % kwstatus) ui.write('[extensions]\n%s\n' % extension) demoitems('keyword', ui.configitems('keyword')) - demoitems('keywordmaps', kwmaps.items()) + demoitems('keywordmaps', kwmaps.iteritems()) keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n' repo.wopener(fn, 'w').write(keywords) repo.add([fn]) @@ -464,10 +464,10 @@ wlock = self.wlock() lock = self.lock() # store and postpone commit hooks - commithooks = [] + commithooks = {} for name, cmd in ui.configitems('hooks'): if name.split('.', 1)[0] == 'commit': - commithooks.append((name, cmd)) + commithooks[name] = cmd ui.setconfig('hooks', name, None) if commithooks: # store parents for commit hook environment @@ -488,7 +488,7 @@ p1=p1, p2=p2, extra=extra) # restore commit hooks - for name, cmd in commithooks: + for name, cmd in commithooks.iteritems(): ui.setconfig('hooks', name, cmd) if node is not None: _overwrite(ui, self, node=node) diff -r 48d01b1e315f -r 4b8d568c65dd hgext/patchbomb.py --- a/hgext/patchbomb.py Fri Jan 25 15:54:25 2008 -0500 +++ b/hgext/patchbomb.py Sat Jan 26 01:06:31 2008 +0100 @@ -381,7 +381,6 @@ parent = None sender_addr = email.Utils.parseaddr(sender)[1] - sendmail = None for m in msgs: try: m['Message-Id'] = genmsgid(m['X-Mercurial-Node']) @@ -426,12 +425,10 @@ fp.write('\n\n') fp.close() else: - if not sendmail: - sendmail = mail.connect(ui) ui.status('Sending ', m['Subject'], ' ...\n') # Exim does not remove the Bcc field del m['Bcc'] - sendmail(ui, sender, to + bcc + cc, m.as_string(0)) + mail.sendmail(ui, sender, to + bcc + cc, m.as_string(0)) cmdtable = { "email": diff -r 48d01b1e315f -r 4b8d568c65dd mercurial/mail.py --- a/mercurial/mail.py Fri Jan 25 15:54:25 2008 -0500 +++ b/mercurial/mail.py Sat Jan 26 01:06:31 2008 +0100 @@ -38,43 +38,39 @@ s.login(username, password) return s -def _sendmail(ui, sender, recipients, msg): +class _sendmail(object): '''send mail using sendmail.''' - program = ui.config('email', 'method') - cmdline = '%s -f %s %s' % (program, templater.email(sender), - ' '.join(map(templater.email, recipients))) - ui.note(_('sending mail: %s\n') % cmdline) - fp = os.popen(cmdline, 'w') - fp.write(msg) - ret = fp.close() - if ret: - raise util.Abort('%s %s' % ( - os.path.basename(program.split(None, 1)[0]), - util.explain_exit(ret)[0])) + + def __init__(self, ui, program): + self.ui = ui + self.program = program + + def sendmail(self, sender, recipients, msg): + cmdline = '%s -f %s %s' % ( + self.program, templater.email(sender), + ' '.join(map(templater.email, recipients))) + self.ui.note(_('sending mail: %s\n') % cmdline) + fp = os.popen(cmdline, 'w') + fp.write(msg) + ret = fp.close() + if ret: + raise util.Abort('%s %s' % ( + os.path.basename(self.program.split(None, 1)[0]), + util.explain_exit(ret)[0])) def connect(ui): - '''make a mail connection. return a function to send mail. + '''make a mail connection. object returned has one method, sendmail. call as sendmail(sender, list-of-recipients, msg).''' - func = _sendmail - if ui.config('email', 'method', 'smtp') == 'smtp': - func = _smtp(ui) + method = ui.config('email', 'method', 'smtp') + if method == 'smtp': + return _smtp(ui) - def send(ui, sender, recipients, msg): - try: - return func.sendmail(sender, recipients, msg) - except smtplib.SMTPRecipientsRefused, inst: - recipients = [r[1] for r in inst.recipients.values()] - raise util.Abort('\n' + '\n'.join(recipients)) - except smtplib.SMTPException, inst: - raise util.Abort(inst) - - return send + return _sendmail(ui, method) def sendmail(ui, sender, recipients, msg): try: - send = connect(ui) - return send(sender, recipients, msg) + return connect(ui).sendmail(sender, recipients, msg) except smtplib.SMTPRecipientsRefused, inst: recipients = [r[1] for r in inst.recipients.values()] raise util.Abort('\n' + '\n'.join(recipients)) diff -r 48d01b1e315f -r 4b8d568c65dd mercurial/ui.py --- a/mercurial/ui.py Fri Jan 25 15:54:25 2008 -0500 +++ b/mercurial/ui.py Sat Jan 26 01:06:31 2008 +0100 @@ -204,7 +204,8 @@ pathsitems = items for n, path in pathsitems: if path and "://" not in path and not os.path.isabs(path): - cdata.set("paths", n, os.path.join(root, path)) + cdata.set("paths", n, + os.path.normpath(os.path.join(root, path))) # update verbosity/interactive/report_untrusted settings if section is None or section == 'ui': diff -r 48d01b1e315f -r 4b8d568c65dd tests/test-keyword.out --- a/tests/test-keyword.out Fri Jan 25 15:54:25 2008 -0500 +++ b/tests/test-keyword.out Sat Jan 26 01:06:31 2008 +0100 @@ -293,7 +293,7 @@ added 1 changesets with 3 changes to 3 files 3 files updated, 0 files merged, 0 files removed, 0 files unresolved % incoming -comparing with test-keyword/Test-a/../Test +comparing with test-keyword/Test searching for changes changeset: 1:0729690beff6 tag: tip diff -r 48d01b1e315f -r 4b8d568c65dd tests/test-paths --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-paths Sat Jan 26 01:06:31 2008 +0100 @@ -0,0 +1,11 @@ +#!/bin/sh +base=`pwd` +hg init a +hg clone a b +cd a +echo '[paths]' >> .hg/hgrc +echo 'dupe = ../b' >> .hg/hgrc +hg in dupe | sed "s!$base!!g" +cd .. +hg -R a in dupe | sed "s!$base!!g" +true diff -r 48d01b1e315f -r 4b8d568c65dd tests/test-paths.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-paths.out Sat Jan 26 01:06:31 2008 +0100 @@ -0,0 +1,5 @@ +0 files updated, 0 files merged, 0 files removed, 0 files unresolved +comparing with /b +no changes found +comparing with /b +no changes found