changeset 7159:a634e0065295

Merge with crew
author Brendan Cully <brendan@kublai.com>
date Sat, 18 Oct 2008 16:53:44 -0700
parents d1d011accf94 (diff) ba897f6dc934 (current diff)
children 1b7b21b634f2
files
diffstat 3 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sun Oct 19 01:29:57 2008 +0200
+++ b/hgext/mq.py	Sat Oct 18 16:53:44 2008 -0700
@@ -34,7 +34,7 @@
 from mercurial.repo import RepoError
 from mercurial import commands, cmdutil, hg, patch, revlog, util
 from mercurial import repair
-import os, sys, re, errno
+import os, sys, re, errno, urllib
 
 commands.norepo += " qclone"
 
@@ -641,6 +641,9 @@
                              % name)
 
     def new(self, repo, patch, *pats, **opts):
+        """options:
+           msg: a string or a no-argument function returning a string
+        """
         msg = opts.get('msg')
         force = opts.get('force')
         user = opts.get('user')
@@ -661,6 +664,8 @@
         wlock = repo.wlock()
         try:
             insert = self.full_series_end()
+            if callable(msg):
+                msg = msg()
             commitmsg = msg and msg or ("[mq]: %s" % patch)
             n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
             if n == None:
@@ -1494,7 +1499,10 @@
                             raise util.Abort(_('need --name to import a patch from -'))
                         text = sys.stdin.read()
                     else:
-                        text = file(filename, 'rb').read()
+                        if os.path.exists(filename):
+                            text = file(filename, 'rb').read()
+                        else:
+                            text = urllib.urlopen(filename).read()
                 except IOError:
                     raise util.Abort(_("unable to read %s") % filename)
                 if not patchname:
@@ -1735,11 +1743,14 @@
     -e, -m or -l set the patch header as well as the commit message.
     If none is specified, the patch header is empty and the
     commit message is '[mq]: PATCH'"""
+    msg = cmdutil.logmessage(opts)
+    def getmsg(): return ui.edit(msg, ui.username())
     q = repo.mq
-    message = cmdutil.logmessage(opts)
-    if opts['edit']:
-        message = ui.edit(message, ui.username())
-    opts['msg'] = message
+    opts['msg'] = msg
+    if opts.get('edit'):
+        opts['msg'] = getmsg
+    else:
+        opts['msg'] = msg
     setupheaderopts(ui, opts)
     q.new(repo, patch, *args, **opts)
     q.save_dirty()
--- a/tests/test-mq-qimport	Sun Oct 19 01:29:57 2008 +0200
+++ b/tests/test-mq-qimport	Sat Oct 18 16:53:44 2008 -0700
@@ -27,6 +27,15 @@
 echo % qimport non-existing-file
 hg qimport non-existing-file
 
+echo % import URL
+echo foo >> foo
+hg add foo
+hg diff > $HGTMP/url.diff
+hg revert --no-backup foo
+rm foo
+hg qimport file://$HGTMP/url.diff
+hg qun
+
 echo % build diff with CRLF
 python ../writelines.py b 5 'a\n' 5 'a\r\n'
 hg ci -Am addb
--- a/tests/test-mq-qimport.out	Sun Oct 19 01:29:57 2008 +0200
+++ b/tests/test-mq-qimport.out	Sat Oct 18 16:53:44 2008 -0700
@@ -1,5 +1,8 @@
 % qimport non-existing-file
 abort: unable to read non-existing-file
+% import URL
+adding url.diff to series file
+url.diff
 % build diff with CRLF
 adding b
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved