changeset 5877:5692bed8230b

Merge with crew
author Matt Mackall <mpm@selenic.com>
date Fri, 18 Jan 2008 10:07:36 -0600
parents 2c565b9598b8 (diff) fb93c774dfff (current diff)
children d39af2eabb8c
files
diffstat 6 files changed, 54 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/zsh_completion	Fri Jan 18 00:16:20 2008 +0100
+++ b/contrib/zsh_completion	Fri Jan 18 10:07:36 2008 -0600
@@ -13,6 +13,9 @@
 # option) any later version.
 #
 
+emulate -LR zsh
+setopt extendedglob
+
 local curcontext="$curcontext" state line
 typeset -A _hg_cmd_globals
 
@@ -153,9 +156,9 @@
   typeset -a tags
   local tag rev
 
-  _hg_cmd tags 2> /dev/null | while read tag rev
+  _hg_cmd tags 2> /dev/null | while read tag
   do
-    tags+=($tag)
+    tags+=(${tag/ #    [0-9]#:*})
   done
   (( $#tags )) && _describe -t tags 'tags' tags
 }
@@ -674,13 +677,13 @@
 # MQ
 _hg_qseries() {
   typeset -a patches
-  patches=($(_hg_cmd qseries 2>/dev/null))
+  patches=(${(f)"$(_hg_cmd qseries 2>/dev/null)"})
   (( $#patches )) && _describe -t hg-patches 'patches' patches
 }
 
 _hg_qapplied() {
   typeset -a patches
-  patches=($(_hg_cmd qapplied 2>/dev/null))
+  patches=(${(f)"$(_hg_cmd qapplied 2>/dev/null)"})
   if (( $#patches ))
   then
     patches+=(qbase qtip)
@@ -690,7 +693,7 @@
 
 _hg_qunapplied() {
   typeset -a patches
-  patches=($(_hg_cmd qunapplied 2>/dev/null))
+  patches=(${(f)"$(_hg_cmd qunapplied 2>/dev/null)"})
   (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
 }
 
@@ -730,6 +733,12 @@
   '*:unapplied patch:_hg_qunapplied'
 }
 
+_hg_cmd_qgoto() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--force -f)'{-f,--force}'[overwrite any local changes]' \
+  ':patch:_hg_qseries'
+}
+
 _hg_cmd_qguard() {
   _arguments -s -w : $_hg_global_opts \
   '(--list -l)'{-l,--list}'[list all patches and guards]' \
--- a/hgext/patchbomb.py	Fri Jan 18 00:16:20 2008 +0100
+++ b/hgext/patchbomb.py	Fri Jan 18 10:07:36 2008 -0600
@@ -381,6 +381,7 @@
     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,10 +427,12 @@
             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']
-            mail.sendmail(ui, sender, to + bcc + cc, m.as_string(0))
+            sendmail(ui, sender, to + bcc + cc, m.as_string(0))
 
 cmdtable = {
     "email":
--- a/mercurial/dispatch.py	Fri Jan 18 00:16:20 2008 +0100
+++ b/mercurial/dispatch.py	Fri Jan 18 10:07:36 2008 -0600
@@ -354,12 +354,12 @@
         d = lambda: func(ui, *args, **cmdoptions)
 
     # run pre-hook, and abort if it fails
-    ret = hook.hook(ui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
+    ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
     if ret:
         return ret
     ret = _runcommand(ui, options, cmd, d)
     # run post-hook, passing command result
-    hook.hook(ui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
+    hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
               result = ret)
     return ret
 
--- a/mercurial/hook.py	Fri Jan 18 00:16:20 2008 +0100
+++ b/mercurial/hook.py	Fri Jan 18 10:07:36 2008 -0600
@@ -71,7 +71,11 @@
 def _exthook(ui, repo, name, cmd, args, throw):
     ui.note(_("running hook %s: %s\n") % (name, cmd))
     env = dict([('HG_' + k.upper(), v) for k, v in args.iteritems()])
-    r = util.system(cmd, environ=env, cwd=repo.root)
+    if repo:
+        cwd = repo.root
+    else:
+        cwd = os.getcwd()
+    r = util.system(cmd, environ=env, cwd=cwd)
     if r:
         desc, r = util.explain_exit(r)
         if throw:
--- a/mercurial/mail.py	Fri Jan 18 00:16:20 2008 +0100
+++ b/mercurial/mail.py	Fri Jan 18 10:07:36 2008 -0600
@@ -38,39 +38,43 @@
         s.login(username, password)
     return s
 
-class _sendmail(object):
+def _sendmail(ui, sender, recipients, msg):
     '''send mail using sendmail.'''
-
-    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]))
+    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 connect(ui):
-    '''make a mail connection. object returned has one method, sendmail.
+    '''make a mail connection. return a function to send mail.
     call as sendmail(sender, list-of-recipients, msg).'''
 
-    method = ui.config('email', 'method', 'smtp')
-    if method == 'smtp':
-        return _smtp(ui)
+    func =  _sendmail
+    if ui.config('email', 'method', 'smtp') == 'smtp':
+        func = _smtp(ui)
 
-    return _sendmail(ui, method)
+    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
 
 def sendmail(ui, sender, recipients, msg):
     try:
-        return connect(ui).sendmail(sender, recipients, msg)
+        send = connect(ui)
+        return send(sender, recipients, msg)
     except smtplib.SMTPRecipientsRefused, inst:
         recipients = [r[1] for r in inst.recipients.values()]
         raise util.Abort('\n' + '\n'.join(recipients))
--- a/tests/test-journal-exists	Fri Jan 18 00:16:20 2008 +0100
+++ b/tests/test-journal-exists	Fri Jan 18 10:07:36 2008 -0600
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 hg init
 echo a > a