#
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
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
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
if options.series == '-':
f = sys.stdin
else:
- f = file(args[0])
+ f = file(options.series)
patches = []
for line in f:
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)
else:
filename = None
- if filename:
+ if not options.url and filename:
filename = os.path.abspath(filename)
directory.cd_to_topdir()
--- /dev/null
+__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'
--- /dev/null
+__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'
# 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,
'stgit.keepoptimized': 'no',
'stgit.extensions': '.ancestor .current .patched',
'stgit.shortnr': '5',
- 'stgit.pager': 'less -FRSX'
+ 'stgit.pager': 'less'
}
__cache = None
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
global config
os.environ.setdefault('PAGER', config.get('stgit.pager'))
+ os.environ.setdefault('LESS', '-FRSX')
# FIXME: handle EDITOR the same way ?
class ConfigOption:
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))