Show More
@@ -240,6 +240,9 b' class notifier(object):' | |||||
240 | prev = self.repo.changelog.parents(node)[0] |
|
240 | prev = self.repo.changelog.parents(node)[0] | |
241 | patch.diff(self.repo, prev, ref, fp=fp) |
|
241 | patch.diff(self.repo, prev, ref, fp=fp) | |
242 | difflines = fp.getvalue().splitlines(1) |
|
242 | difflines = fp.getvalue().splitlines(1) | |
|
243 | if self.ui.configbool('notify', 'diffstat', True): | |||
|
244 | s = patch.diffstat(difflines) | |||
|
245 | self.sio.write('\ndiffstat:\n\n' + s) | |||
243 | if maxdiff > 0 and len(difflines) > maxdiff: |
|
246 | if maxdiff > 0 and len(difflines) > maxdiff: | |
244 | self.sio.write(_('\ndiffs (truncated from %d to %d lines):\n\n') % |
|
247 | self.sio.write(_('\ndiffs (truncated from %d to %d lines):\n\n') % | |
245 | (len(difflines), maxdiff)) |
|
248 | (len(difflines), maxdiff)) |
@@ -65,7 +65,7 b'' | |||||
65 |
|
65 | |||
66 | from mercurial.demandload import * |
|
66 | from mercurial.demandload import * | |
67 | demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils |
|
67 | demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils | |
68 | mercurial:commands,hg,mail,ui |
|
68 | mercurial:commands,hg,mail,ui,patch | |
69 | os errno popen2 socket sys tempfile time''') |
|
69 | os errno popen2 socket sys tempfile time''') | |
70 | from mercurial.i18n import gettext as _ |
|
70 | from mercurial.i18n import gettext as _ | |
71 | from mercurial.node import * |
|
71 | from mercurial.node import * | |
@@ -76,27 +76,6 b' try:' | |||||
76 | import readline |
|
76 | import readline | |
77 | except ImportError: pass |
|
77 | except ImportError: pass | |
78 |
|
78 | |||
79 | def diffstat(patch): |
|
|||
80 | fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt") |
|
|||
81 | try: |
|
|||
82 | p = popen2.Popen3('diffstat -p1 -w79 2>/dev/null > ' + name) |
|
|||
83 | try: |
|
|||
84 | for line in patch: print >> p.tochild, line |
|
|||
85 | p.tochild.close() |
|
|||
86 | if p.wait(): return |
|
|||
87 | fp = os.fdopen(fd, 'r') |
|
|||
88 | stat = [] |
|
|||
89 | for line in fp: stat.append(line.lstrip()) |
|
|||
90 | last = stat.pop() |
|
|||
91 | stat.insert(0, last) |
|
|||
92 | stat = ''.join(stat) |
|
|||
93 | if stat.startswith('0 files'): raise ValueError |
|
|||
94 | return stat |
|
|||
95 | except: raise |
|
|||
96 | finally: |
|
|||
97 | try: os.unlink(name) |
|
|||
98 | except: pass |
|
|||
99 |
|
||||
100 | def patchbomb(ui, repo, *revs, **opts): |
|
79 | def patchbomb(ui, repo, *revs, **opts): | |
101 | '''send changesets as a series of patch emails |
|
80 | '''send changesets as a series of patch emails | |
102 |
|
81 | |||
@@ -123,8 +102,8 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
123 | if not prompt(s, default = 'y', rest = '? ').lower().startswith('y'): |
|
102 | if not prompt(s, default = 'y', rest = '? ').lower().startswith('y'): | |
124 | raise ValueError |
|
103 | raise ValueError | |
125 |
|
104 | |||
126 | def cdiffstat(summary, patch): |
|
105 | def cdiffstat(summary, patchlines): | |
127 | s = diffstat(patch) |
|
106 | s = patch.diffstat(patchlines) | |
128 | if s: |
|
107 | if s: | |
129 | if summary: |
|
108 | if summary: | |
130 | ui.write(summary, '\n') |
|
109 | ui.write(summary, '\n') |
@@ -9,7 +9,8 b' from demandload import demandload' | |||||
9 | from i18n import gettext as _ |
|
9 | from i18n import gettext as _ | |
10 | from node import * |
|
10 | from node import * | |
11 | demandload(globals(), "cmdutil mdiff util") |
|
11 | demandload(globals(), "cmdutil mdiff util") | |
12 |
demandload(globals(), |
|
12 | demandload(globals(), '''cStringIO email.Parser errno os re shutil sys tempfile | |
|
13 | popen2''') | |||
13 |
|
14 | |||
14 | # helper functions |
|
15 | # helper functions | |
15 |
|
16 | |||
@@ -550,3 +551,24 b" def export(repo, revs, template='hg-%h.p" | |||||
550 |
|
551 | |||
551 | for seqno, cset in enumerate(revs): |
|
552 | for seqno, cset in enumerate(revs): | |
552 | single(cset, seqno, fp) |
|
553 | single(cset, seqno, fp) | |
|
554 | ||||
|
555 | def diffstat(patchlines): | |||
|
556 | fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt") | |||
|
557 | try: | |||
|
558 | p = popen2.Popen3('diffstat -p1 -w79 2>/dev/null > ' + name) | |||
|
559 | try: | |||
|
560 | for line in patchlines: print >> p.tochild, line | |||
|
561 | p.tochild.close() | |||
|
562 | if p.wait(): return | |||
|
563 | fp = os.fdopen(fd, 'r') | |||
|
564 | stat = [] | |||
|
565 | for line in fp: stat.append(line.lstrip()) | |||
|
566 | last = stat.pop() | |||
|
567 | stat.insert(0, last) | |||
|
568 | stat = ''.join(stat) | |||
|
569 | if stat.startswith('0 files'): raise ValueError | |||
|
570 | return stat | |||
|
571 | except: raise | |||
|
572 | finally: | |||
|
573 | try: os.unlink(name) | |||
|
574 | except: pass |
General Comments 0
You need to be logged in to leave comments.
Login now