"""
import sys, os, re
+from email.Utils import formatdate
from stgit.utils import *
+from stgit.out import *
from stgit import git, basedir, templates
from stgit.config import config
from shutil import copyfile
f.seek(0); f.truncate()
f.writelines(lines)
+# TODO: move this out of the stgit.stack module, it is really for
+# higher level commands to handle the user interaction
def edit_file(series, line, comment, show_patch = True):
fname = '.stgitmsg.txt'
tmpl = templates.get_template('patchdescr.tmpl')
if show_patch:
print >> f, __patch_prefix
# series.get_patch(series.get_current()).get_top()
- git.diff([], series.get_patch(series.get_current()).get_bottom(), None, f)
+ diff_str = git.diff(rev1 = series.get_patch(series.get_current()).get_bottom())
+ f.write(diff_str)
#Vim modeline must be near the end.
print >> f, __comment_prefix, 'vi: set textwidth=75 filetype=diff nobackup:'
self._set_field('authemail', email or git.author().email)
def get_authdate(self):
- return self._get_field('authdate')
+ date = self._get_field('authdate')
+ if not date:
+ return date
+
+ if re.match('[0-9]+\s+[+-][0-9]+', date):
+ # Unix time (seconds) + time zone
+ secs_tz = date.split()
+ date = formatdate(int(secs_tz[0]))[:-5] + secs_tz[1]
+
+ return date
def set_authdate(self, date):
self._set_field('authdate', date or git.author().date)
return bool(config.get(self.format_version_key()))
+def shortlog(patches):
+ log = ''.join(Run('git-log', '--pretty=short',
+ p.get_top(), '^%s' % p.get_bottom()).raw_output()
+ for p in patches)
+ return Run('git-shortlog').raw_input(log).raw_output()
+
class Series(PatchSet):
"""Class including the operations on series
"""
out.note(('No parent remote declared for stack "%s",'
' defaulting to "origin".' % self.get_name()),
('Consider setting "branch.%s.remote" and'
- ' "branch.%s.merge" with "git repo-config".'
+ ' "branch.%s.merge" with "git config".'
% (self.get_name(), self.get_name())))
return 'origin'
else:
out.note(('No parent branch declared for stack "%s",'
' defaulting to "heads/origin".' % self.get_name()),
('Consider setting "branch.%s.stgit.parentbranch"'
- ' with "git repo-config".' % self.get_name()))
+ ' with "git config".' % self.get_name()))
return 'heads/origin'
else:
raise StackException, 'Cannot find a parent branch for "%s"' % self.get_name()
elif message:
descr = message
+ # TODO: move this out of the stgit.stack module, it is really
+ # for higher level commands to handle the user interaction
if not message and edit:
descr = edit_file(self, descr.rstrip(), \
'Please edit the description for patch "%s" ' \
if not committer_email:
committer_email = patch.get_commemail()
- if sign_str:
- descr = descr.rstrip()
- if descr.find("\nSigned-off-by:") < 0 \
- and descr.find("\nAcked-by:") < 0:
- descr = descr + "\n"
-
- descr = '%s\n%s: %s <%s>\n' % (descr, sign_str,
- committer_name, committer_email)
+ descr = add_sign_line(descr, sign_str, committer_name, committer_email)
bottom = patch.get_bottom()
if self.patch_exists(name):
raise StackException, 'Patch "%s" already exists' % name
+ # TODO: move this out of the stgit.stack module, it is really
+ # for higher level commands to handle the user interaction
if not message and can_edit:
descr = edit_file(
self, None,