changeset 2757:787e18b84893

merge patches from brendan cully that did not apply clean against tip.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Tue, 01 Aug 2006 15:40:28 -0700
parents caa6d992608b (diff) 5dfeda163bb7 (current diff)
children c9359142cba3
files hgext/mq.py
diffstat 2 files changed, 67 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Tue Aug 01 12:21:55 2006 -0700
+++ b/hgext/mq.py	Tue Aug 01 15:40:28 2006 -0700
@@ -940,17 +940,23 @@
                 self.ui.write("%d " % self.series.index(p))
             self.ui.write("%s\n" % p)
 
-    def qseries(self, repo, missing=None):
+    def qseries(self, repo, missing=None, summary=False):
         start = self.series_end()
         if not missing:
-            for p in self.series[:start]:
+            for i in range(len(self.series)):
+                patch = self.series[i]
                 if self.ui.verbose:
-                    self.ui.write("%d A " % self.series.index(p))
-                self.ui.write("%s\n" % p)
-            for p in self.series[start:]:
-                if self.ui.verbose:
-                    self.ui.write("%d U " % self.series.index(p))
-                self.ui.write("%s\n" %  p)
+                    if i < start:
+                        status = 'A'
+                    else:
+                        status = 'U'
+                    self.ui.write('%d %s ' % (i, status))
+                if summary:
+                    msg = self.readheaders(patch)[0]
+                    msg = msg and ': ' + msg[0] or ': '
+                else:
+                    msg = ''
+                self.ui.write('%s%s\n' % (patch, msg))
         else:
             list = []
             for root, dirs, files in os.walk(self.path):
@@ -1193,7 +1199,12 @@
     return 0
 
 def init(ui, repo, **opts):
-    """init a new queue repository"""
+    """init a new queue repository
+
+    The queue repository is unversioned by default. If -c is
+    specified, qinit will create a separate nested repository
+    for patches. Use qcommit to commit changes to this queue
+    repository."""
     q = repo.mq
     r = q.init(repo, create=opts['create_repo'])
     q.save_dirty()
@@ -1259,7 +1270,7 @@
 
 def series(ui, repo, **opts):
     """print the entire series file"""
-    repo.mq.qseries(repo, missing=opts['missing'])
+    repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary'])
     return 0
 
 def top(ui, repo, **opts):
@@ -1278,7 +1289,19 @@
     return 0
 
 def new(ui, repo, patch, **opts):
-    """create a new patch"""
+    """create a new patch
+
+    qnew creates a new patch on top of the currently-applied patch
+    (if any). It will refuse to run if there are any outstanding
+    changes unless -f is specified, in which case the patch will
+    be initialised with them.
+
+    -m or -l set the patch header as well as the commit message.
+    If neither is specified, the patch header is empty and the
+    commit message is 'New patch: PATCH'
+
+    If -f is specified, the patch will be initialized with any
+    uncommitted changes. Otherwise, if there outsta"""
     q = repo.mq
     message=commands.logmessage(**opts)
     q.new(repo, patch, msg=message, force=opts['force'])
@@ -1305,9 +1328,13 @@
     repo.mq.diff(repo, list(files))
     return 0
 
-def fold(ui, repo, *files):
+def fold(ui, repo, *files, **opts):
     """fold the named patches into the current patch
-    Patches must not yet be applied."""
+
+    Patches must not yet be applied.
+    The header for each folded patch will be concatenated with
+    the current patch header, separated by a line of '* * *'."""
+
     q = repo.mq
 
     if not files:
@@ -1315,6 +1342,11 @@
     if not q.check_toppatch(repo):
         raise util.Abort(_('No patches applied\n'))
 
+    message=commands.logmessage(**opts)
+    if opts['edit']:
+        if message:
+            raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
+
     parent = q.lookup('qtip')
     patches = []
     messages = []
@@ -1327,17 +1359,22 @@
         patches.append(patch)
 
     for patch in patches:
-        messages.append(q.readheaders(patch)[0])
+        if not message:
+            messages.append(q.readheaders(patch)[0])
         pf = os.path.join(q.path, patch)
         (patchsuccess, files, fuzz) = q.patch(repo, pf)
         if not patchsuccess:
             raise util.Abort(_('Error folding patch %s') % patch)
 
-    message = q.readheaders(parent)[0]
-    for msg in messages:
-        message.append('* * *')
-        message.extend(msg)
-    message = '\n'.join(message)
+    if not message:
+        message, comments, user = q.readheaders(parent)[0:3]
+        for msg in messages:
+            message.append('* * *')
+            message.extend(msg)
+        message = '\n'.join(message)
+
+    if opts['edit']:
+        message = ui.edit(message, user or ui.username())
 
     q.refresh(repo, msg=message)
 
@@ -1521,7 +1558,7 @@
     return 0
 
 def version(ui, q=None):
-    """print the version number"""
+    """print the version number of the mq extension"""
     ui.write("mq version %s\n" % versionstr)
     return 0
 
@@ -1572,7 +1609,12 @@
         (delete,
          [('f', 'force', None, _('delete patch file'))],
           'hg qdelete [-f] PATCH'),
-    'qfold': (fold, [], 'hg qfold PATCH...'),
+    'qfold':
+        (fold,
+         [('e', 'edit', None, _('edit patch header')),
+          ('m', 'message', '', _('set patch header to <text>')),
+          ('l', 'logfile', '', _('set patch header to contents of <file>'))],
+         'hg qfold [-e] [-m <text>] [-l <file] PATCH...'),
     'qheader': (header, [],
                 _('hg qheader [PATCH]')),
     "^qimport":
@@ -1589,7 +1631,7 @@
         (new,
          [('m', 'message', '', _('use <text> as commit message')),
           ('l', 'logfile', '', _('read the commit message from <file>')),
-          ('f', 'force', None, 'force')],
+          ('f', 'force', None, _('import uncommitted changes into patch'))],
          'hg qnew [-m TEXT] [-l FILE] [-f] PATCH'),
     "qnext": (next, [], 'hg qnext'),
     "qprev": (prev, [], 'hg qprev'),
@@ -1632,7 +1674,8 @@
          'hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'),
     "qseries":
         (series,
-         [('m', 'missing', None, 'print patches not in series')],
+         [('m', 'missing', None, 'print patches not in series'),
+          ('s', 'summary', None, _('print first line of patch header'))],
          'hg qseries [-m]'),
     "^strip":
         (strip,
--- a/mercurial/commands.py	Tue Aug 01 12:21:55 2006 -0700
+++ b/mercurial/commands.py	Tue Aug 01 15:40:28 2006 -0700
@@ -3352,9 +3352,8 @@
     try:
         return sys.modules[external[name]]
     except KeyError:
-        dotname = '.' + name
         for k, v in external.iteritems():
-            if k.endswith('.' + name) or v == name:
+            if k.endswith('.' + name) or k.endswith('/' + name) or v == name:
                 return sys.modules[v]
         raise KeyError(name)