Mercurial > public > mercurial-scm > hg
diff mercurial/subrepo.py @ 24256:e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
author | Mathias De Mar? <mathias.demare@gmail.com> |
---|---|
date | Mon, 09 Mar 2015 22:14:09 +0100 |
parents | 1e3e064c16a1 |
children | 6e092ea2eff1 |
line wrap: on
line diff
--- a/mercurial/subrepo.py Wed Jan 14 15:16:08 2015 -0500 +++ b/mercurial/subrepo.py Mon Mar 09 22:14:09 2015 +0100 @@ -1662,13 +1662,42 @@ deleted, unknown, ignored, clean = [], [], [], [] + command = ['status', '--porcelain', '-z'] if opts.get('unknown'): - command = ['ls-files', '--others', '--exclude-standard'] - out = self._gitcommand(command) - for line in out.split('\n'): - if len(line) == 0: - continue - unknown.append(line) + command += ['--untracked-files=all'] + if opts.get('ignored'): + command += ['--ignored'] + out = self._gitcommand(command) + + changedfiles = set() + changedfiles.update(modified) + changedfiles.update(added) + changedfiles.update(removed) + for line in out.split('\0'): + if not line: + continue + st = line[0:2] + #moves and copies show 2 files on one line + if line.find('\0') >= 0: + filename1, filename2 = line[3:].split('\0') + else: + filename1 = line[3:] + filename2 = None + + changedfiles.add(filename1) + if filename2: + changedfiles.add(filename2) + + if st == '??': + unknown.append(filename1) + elif st == '!!': + ignored.append(filename1) + + if opts.get('clean'): + out = self._gitcommand(['ls-files']) + for f in out.split('\n'): + if not f in changedfiles: + clean.append(f) return scmutil.status(modified, added, removed, deleted, unknown, ignored, clean)