##// END OF EJS Templates
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré -
r24256:e964edc3 default
parent child Browse files
Show More
@@ -1662,13 +1662,42 b' class gitsubrepo(abstractsubrepo):'
1662
1662
1663 deleted, unknown, ignored, clean = [], [], [], []
1663 deleted, unknown, ignored, clean = [], [], [], []
1664
1664
1665 command = ['status', '--porcelain', '-z']
1665 if opts.get('unknown'):
1666 if opts.get('unknown'):
1666 command = ['ls-files', '--others', '--exclude-standard']
1667 command += ['--untracked-files=all']
1667 out = self._gitcommand(command)
1668 if opts.get('ignored'):
1668 for line in out.split('\n'):
1669 command += ['--ignored']
1669 if len(line) == 0:
1670 out = self._gitcommand(command)
1670 continue
1671
1671 unknown.append(line)
1672 changedfiles = set()
1673 changedfiles.update(modified)
1674 changedfiles.update(added)
1675 changedfiles.update(removed)
1676 for line in out.split('\0'):
1677 if not line:
1678 continue
1679 st = line[0:2]
1680 #moves and copies show 2 files on one line
1681 if line.find('\0') >= 0:
1682 filename1, filename2 = line[3:].split('\0')
1683 else:
1684 filename1 = line[3:]
1685 filename2 = None
1686
1687 changedfiles.add(filename1)
1688 if filename2:
1689 changedfiles.add(filename2)
1690
1691 if st == '??':
1692 unknown.append(filename1)
1693 elif st == '!!':
1694 ignored.append(filename1)
1695
1696 if opts.get('clean'):
1697 out = self._gitcommand(['ls-files'])
1698 for f in out.split('\n'):
1699 if not f in changedfiles:
1700 clean.append(f)
1672
1701
1673 return scmutil.status(modified, added, removed, deleted,
1702 return scmutil.status(modified, added, removed, deleted,
1674 unknown, ignored, clean)
1703 unknown, ignored, clean)
@@ -175,6 +175,8 b' user a pulls, merges, commits'
175 pulling subrepo s from $TESTTMP/gitroot
175 pulling subrepo s from $TESTTMP/gitroot
176 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
176 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
177 (branch merge, don't forget to commit)
177 (branch merge, don't forget to commit)
178 $ hg st --subrepos s
179 A s/f
178 $ cat s/f
180 $ cat s/f
179 f
181 f
180 $ cat s/g
182 $ cat s/g
@@ -944,6 +946,16 b' except for explicitly added files (no pa'
944 ? s/c.c
946 ? s/c.c
945 ? s/cpp.cpp
947 ? s/cpp.cpp
946 ? s/foobar.orig
948 ? s/foobar.orig
949 $ hg st --subrepos s --all
950 A s/.gitignore
951 ? s/barfoo
952 ? s/c.c
953 ? s/cpp.cpp
954 ? s/foobar.orig
955 I s/snake.python
956 C s/f
957 C s/foobar
958 C s/g
947 $ hg add --subrepos "glob:**.python"
959 $ hg add --subrepos "glob:**.python"
948 $ hg st --subrepos s
960 $ hg st --subrepos s
949 A s/.gitignore
961 A s/.gitignore
@@ -978,13 +990,41 b' error given when adding an already track'
978 $ hg add s/.gitignore
990 $ hg add s/.gitignore
979 s/.gitignore already tracked!
991 s/.gitignore already tracked!
980 [1]
992 [1]
993 $ hg add s/g
994 s/g already tracked!
995 [1]
981
996
982 removed files can be re-added
997 removed files can be re-added
998 removing files using 'rm' or 'git rm' has the same effect,
999 since we ignore the staging area
983 $ hg ci --subrepos -m 'snake'
1000 $ hg ci --subrepos -m 'snake'
984 committing subrepository s
1001 committing subrepository s
985 $ cd s
1002 $ cd s
1003 $ rm snake.python
1004 (remove leftover .hg so Mercurial doesn't look for a root here)
1005 $ rm -r .hg
1006 $ hg status --subrepos --all .
1007 R snake.python
1008 ? barfoo
1009 ? c.c
1010 ? cpp.cpp
1011 ? foobar.orig
1012 C .gitignore
1013 C f
1014 C foobar
1015 C g
986 $ git rm snake.python
1016 $ git rm snake.python
987 rm 'snake.python'
1017 rm 'snake.python'
1018 $ hg status --subrepos --all .
1019 R snake.python
1020 ? barfoo
1021 ? c.c
1022 ? cpp.cpp
1023 ? foobar.orig
1024 C .gitignore
1025 C f
1026 C foobar
1027 C g
988 $ touch snake.python
1028 $ touch snake.python
989 $ cd ..
1029 $ cd ..
990 $ hg add s/snake.python
1030 $ hg add s/snake.python
General Comments 0
You need to be logged in to leave comments. Login now