comparison mercurial/cmdutil.py @ 12167:d2c5b0927c28

diff: recurse into subrepositories with --subrepos/-S flag
author Martin Geisler <mg@lazybytes.net>
date Fri, 03 Sep 2010 12:58:51 +0200
parents 1849b6147831
children c0a8f9dea0f6
comparison
equal deleted inserted replaced
12166:441a74b8def1 12167:d2c5b0927c28
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from node import hex, nullid, nullrev, short 8 from node import hex, bin, nullid, nullrev, short
9 from i18n import _ 9 from i18n import _
10 import os, sys, errno, re, glob, tempfile 10 import os, sys, errno, re, glob, tempfile
11 import util, templater, patch, error, encoding, templatekw 11 import util, templater, patch, error, encoding, templatekw
12 import match as matchmod 12 import match as matchmod
13 import similar, revset 13 import similar, revset
653 653
654 for seqno, rev in enumerate(revs): 654 for seqno, rev in enumerate(revs):
655 single(rev, seqno + 1, fp) 655 single(rev, seqno + 1, fp)
656 656
657 def diffordiffstat(ui, repo, diffopts, node1, node2, match, 657 def diffordiffstat(ui, repo, diffopts, node1, node2, match,
658 changes=None, stat=False, fp=None): 658 changes=None, stat=False, fp=None, prefix='',
659 listsubrepos=False):
659 '''show diff or diffstat.''' 660 '''show diff or diffstat.'''
660 if fp is None: 661 if fp is None:
661 write = ui.write 662 write = ui.write
662 else: 663 else:
663 def write(s, **kw): 664 def write(s, **kw):
666 if stat: 667 if stat:
667 diffopts = diffopts.copy(context=0) 668 diffopts = diffopts.copy(context=0)
668 width = 80 669 width = 80
669 if not ui.plain(): 670 if not ui.plain():
670 width = util.termwidth() 671 width = util.termwidth()
671 chunks = patch.diff(repo, node1, node2, match, changes, diffopts) 672 chunks = patch.diff(repo, node1, node2, match, changes, diffopts,
673 prefix=prefix)
672 for chunk, label in patch.diffstatui(util.iterlines(chunks), 674 for chunk, label in patch.diffstatui(util.iterlines(chunks),
673 width=width, 675 width=width,
674 git=diffopts.git): 676 git=diffopts.git):
675 write(chunk, label=label) 677 write(chunk, label=label)
676 else: 678 else:
677 for chunk, label in patch.diffui(repo, node1, node2, match, 679 for chunk, label in patch.diffui(repo, node1, node2, match,
678 changes, diffopts): 680 changes, diffopts, prefix=prefix):
679 write(chunk, label=label) 681 write(chunk, label=label)
682
683 if listsubrepos:
684 ctx1 = repo[node1]
685 for subpath in ctx1.substate:
686 sub = ctx1.sub(subpath)
687 if node2 is not None:
688 node2 = bin(repo[node2].substate[subpath][1])
689 submatch = matchmod.narrowmatcher(subpath, match)
690 sub.diff(diffopts, node2, submatch, changes=changes,
691 stat=stat, fp=fp, prefix=prefix)
680 692
681 class changeset_printer(object): 693 class changeset_printer(object):
682 '''show changeset information when templating not requested.''' 694 '''show changeset information when templating not requested.'''
683 695
684 def __init__(self, ui, repo, patch, diffopts, buffered): 696 def __init__(self, ui, repo, patch, diffopts, buffered):