chiark / gitweb /
Merge branch 'proposed' of git://github.com/gustavh/stgit
authorKarl Wiberg <kha@treskal.com>
Mon, 17 Aug 2009 08:50:42 +0000 (10:50 +0200)
committerKarl Wiberg <kha@treskal.com>
Mon, 17 Aug 2009 08:50:42 +0000 (10:50 +0200)
* 'proposed' of git://github.com/gustavh/stgit: (71 commits)
  stgit.el: Add menu bar menu
  stgit.el: Add stgit-toggle-mark
  stgit.el: Verify we're in stgit-mode before running commands
  stgit.el: Allow toggle-index on index and work tree
  stgit.el: Allow revert on index and work tree
  stgit.el: Add +/- to expand/collapse selected patches
  stgit.el: Fix some incorrect indentation
  stgit.el: Add stgit-new-and-refresh command
  stgit.el: Bugfix "P" when point is not on a patch line
  stgit.el: Fix problem where standard-output isn't bound correctly
  stgit.el: Bugfix of stgit-move-patches to top of stack
  stgit.el: Improve use of def{group,custom,face}
  stgit.el: Add C-c C-b for stgit-rebase
  stgit.el: Add better help text for stgit-mode
  stgit.el: Bugfix mode change display
  stgit.el: Minor documentation corrections
  stgit.el: Allow moving ignored files to index
  stgit.el: Move point in sane way after stgit-file-toggle-index on renames
  stgit.el: Move point correctly after stgit-revert-file
  stgit.el: Abbreviate renames/copies with common prefix/suffix
  ...

stgit/commands/common.py
stgit/commands/float.py
stgit/commands/imprt.py
stgit/commands/next.py [new file with mode: 0644]
stgit/commands/prev.py [new file with mode: 0644]
stgit/commands/publish.py
stgit/config.py
stgit/run.py

index d64cce13336dd91ea097cd1e1f3db381ef054d1b..d38d263843da340002fa1343c5c3fc8868449ae6 100644 (file)
@@ -323,7 +323,7 @@ def post_rebase(crt_series, applied, nopush, merged):
 #
 def __end_descr(line):
     return re.match('---\s*$', line) or re.match('diff -', line) or \
-            re.match('Index: ', line)
+            re.match('Index: ', line) or re.match('--- \w', line)
 
 def __split_descr_diff(string):
     """Return the description and the diff from the given string
@@ -405,7 +405,8 @@ def parse_mail(msg):
         authname = authemail = None
 
     # '\n\t' can be found on multi-line headers
-    descr = __decode_header(msg['subject']).replace('\n\t', ' ')
+    descr = __decode_header(msg['subject'])
+    descr = re.sub('\n[ \t]*', ' ', descr)
     authdate = msg['date']
 
     # remove the '[*PATCH*]' expression in the subject
index e561c3995414240b623d5df6205dea86667b8bbd..9316398ff078ed572c3a7ce0b0a2c74d3bd11b18 100644 (file)
@@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
+import re
 import sys
 from stgit.argparse import opt
 from stgit.commands import common
@@ -55,7 +56,7 @@ def func(parser, options, args):
         if options.series == '-':
             f = sys.stdin
         else:
-            f = file(args[0])
+            f = file(options.series)
 
         patches = []
         for line in f:
index 7a806cce60fd7382848953db6b432fcf7e307100..8067beb11adfaf0ebec52aa5c097eac08b2e8f25 100644 (file)
@@ -267,7 +267,7 @@ def __import_url(url, options):
     import tempfile
 
     if not url:
-        parser.error('URL argument required')
+        raise CmdException('URL argument required')
 
     patch = os.path.basename(urllib.unquote(url))
     filename = os.path.join(tempfile.gettempdir(), patch)
@@ -327,7 +327,7 @@ def func(parser, options, args):
     else:
         filename = None
 
-    if filename:
+    if not options.url and filename:
         filename = os.path.abspath(filename)
     directory.cd_to_topdir()
 
diff --git a/stgit/commands/next.py b/stgit/commands/next.py
new file mode 100644 (file)
index 0000000..c8e2599
--- /dev/null
@@ -0,0 +1,48 @@
+__copyright__ = """
+Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+from stgit.argparse import opt
+from stgit.commands import common
+from stgit.out import out
+from stgit import argparse
+
+help = 'Print the name of the next patch'
+kind = 'stack'
+usage = ['']
+description = """
+Print the name of the next patch."""
+
+args = []
+options = [
+    opt('-b', '--branch', args = [argparse.stg_branches],
+        short = 'Use BRANCH instead of the default branch')]
+
+directory = common.DirectoryHasRepositoryLib()
+
+def func(parser, options, args):
+    """Show the name of the next patch
+    """
+    if len(args) != 0:
+        parser.error('incorrect number of arguments')
+
+    stack = directory.repository.get_stack(options.branch)
+    unapplied = stack.patchorder.unapplied
+
+    if unapplied:
+        out.stdout(unapplied[0])
+    else:
+        raise common.CmdException, 'No unapplied patches'
diff --git a/stgit/commands/prev.py b/stgit/commands/prev.py
new file mode 100644 (file)
index 0000000..79f97a8
--- /dev/null
@@ -0,0 +1,48 @@
+__copyright__ = """
+Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+from stgit.argparse import opt
+from stgit.commands import common
+from stgit.out import out
+from stgit import argparse
+
+help = 'Print the name of the previous patch'
+kind = 'stack'
+usage = ['']
+description = """
+Print the name of the previous patch."""
+
+args = []
+options = [
+    opt('-b', '--branch', args = [argparse.stg_branches],
+        short = 'Use BRANCH instead of the default branch')]
+
+directory = common.DirectoryHasRepositoryLib()
+
+def func(parser, options, args):
+    """Show the name of the previous patch
+    """
+    if len(args) != 0:
+        parser.error('incorrect number of arguments')
+
+    stack = directory.repository.get_stack(options.branch)
+    applied = stack.patchorder.applied
+
+    if applied and len(applied) >= 2:
+        out.stdout(applied[-2])
+    else:
+        raise common.CmdException, 'Not enough applied patches'
index cfd63a0b9eda40752875199bbea1d2ef41870c15..d82991626252ceb3fddeb530628c01251f4add95 100644 (file)
@@ -110,7 +110,7 @@ def func(parser, options, args):
     # base by setting two parents.
     merge_bases = repository.get_merge_bases(public_head, stack.base)
     if not stack.base in merge_bases:
-        message = 'Merge %s into %s' % (repository.describe(stack.base),
+        message = 'Merge %s into %s' % (repository.describe(stack.base).strip(),
                                         utils.strip_prefix('refs/heads/',
                                                            public_ref))
         public_head = __create_commit(repository, stack.head.data.tree,
index f205e5bd91888076de234d91a7733491391ebbdd..6f84b10d80b468fe537ddcf19026a98e5e4e8210 100644 (file)
@@ -37,7 +37,7 @@ class GitConfig:
         'stgit.keepoptimized': 'no',
         'stgit.extensions':    '.ancestor .current .patched',
         'stgit.shortnr': '5',
-        'stgit.pager':  'less -FRSX'
+        'stgit.pager':  'less'
         }
 
     __cache = None
@@ -94,8 +94,8 @@ class GitConfig:
         self.__cache[name] = value
 
     def unset(self, name):
-        Run('git', 'config', '--unset', name)
-        self.__cache[name] = None
+        Run('git', 'config', '--unset', name).run()
+        self.__cache[name] = [None]
 
     def sections_matching(self, regexp):
         """Takes a regexp with a single group, matches it against all
@@ -121,6 +121,7 @@ def config_setup():
     global config
 
     os.environ.setdefault('PAGER', config.get('stgit.pager'))
+    os.environ.setdefault('LESS', '-FRSX')
     # FIXME: handle EDITOR the same way ?
 
 class ConfigOption:
index 7493ed321f094198a36ceb1e225d95bf6b020a5e..2d8ed348b67883f19f050ce89aa8347b417e2e2a 100644 (file)
@@ -110,7 +110,11 @@ class Run:
                                  stdin = subprocess.PIPE,
                                  stdout = subprocess.PIPE,
                                  stderr = subprocess.PIPE)
-            outdata, errdata = p.communicate(self.__indata)
+            # TODO: only use communicate() once support for Python 2.4 is
+            # dropped (write() needed because of performance reasons)
+            if self.__indata:
+                p.stdin.write(self.__indata)
+            outdata, errdata = p.communicate()
             self.exitcode = p.returncode
         except OSError, e:
             raise self.exc('%s failed: %s' % (self.__cmd[0], e))