##// END OF EJS Templates
status: add -c (clean) and -A (all files) options...
Vadim Gelfer -
r2661:5c10b7ed default
parent child Browse files
Show More
@@ -2599,37 +2599,44 b' def serve(ui, repo, **opts):'
2599 def status(ui, repo, *pats, **opts):
2599 def status(ui, repo, *pats, **opts):
2600 """show changed files in the working directory
2600 """show changed files in the working directory
2601
2601
2602 Show changed files in the repository. If names are
2602 Show status of files in the repository. If names are given, only
2603 given, only files that match are shown.
2603 files that match are shown. Files that are clean or ignored, are
2604 not listed unless -c (clean), -i (ignored) or -A is given.
2604
2605
2605 The codes used to show the status of files are:
2606 The codes used to show the status of files are:
2606 M = modified
2607 M = modified
2607 A = added
2608 A = added
2608 R = removed
2609 R = removed
2610 C = clean
2609 ! = deleted, but still tracked
2611 ! = deleted, but still tracked
2610 ? = not tracked
2612 ? = not tracked
2611 I = ignored (not shown by default)
2613 I = ignored (not shown by default)
2612 = the previous added file was copied from here
2614 = the previous added file was copied from here
2613 """
2615 """
2614
2616
2615 show_ignored = opts['ignored'] and True or False
2617 all = opts['all']
2618
2616 files, matchfn, anypats = matchpats(repo, pats, opts)
2619 files, matchfn, anypats = matchpats(repo, pats, opts)
2617 cwd = (pats and repo.getcwd()) or ''
2620 cwd = (pats and repo.getcwd()) or ''
2618 modified, added, removed, deleted, unknown, ignored = [
2621 modified, added, removed, deleted, unknown, ignored, clean = [
2619 [util.pathto(cwd, x) for x in n]
2622 [util.pathto(cwd, x) for x in n]
2620 for n in repo.changes(files=files, match=matchfn,
2623 for n in repo.status(files=files, match=matchfn,
2621 show_ignored=show_ignored)]
2624 list_ignored=all or opts['ignored'],
2622
2625 list_clean=all or opts['clean'])]
2623 changetypes = [('modified', 'M', modified),
2626
2627 changetypes = (('modified', 'M', modified),
2624 ('added', 'A', added),
2628 ('added', 'A', added),
2625 ('removed', 'R', removed),
2629 ('removed', 'R', removed),
2626 ('deleted', '!', deleted),
2630 ('deleted', '!', deleted),
2627 ('unknown', '?', unknown),
2631 ('unknown', '?', unknown),
2628 ('ignored', 'I', ignored)]
2632 ('ignored', 'I', ignored))
2633
2634 explicit_changetypes = changetypes + (('clean', 'C', clean),)
2629
2635
2630 end = opts['print0'] and '\0' or '\n'
2636 end = opts['print0'] and '\0' or '\n'
2631
2637
2632 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
2638 for opt, char, changes in ([ct for ct in explicit_changetypes
2639 if all or opts[ct[0]]]
2633 or changetypes):
2640 or changetypes):
2634 if opts['no_status']:
2641 if opts['no_status']:
2635 format = "%%s%s" % end
2642 format = "%%s%s" % end
@@ -2638,7 +2645,7 b' def status(ui, repo, *pats, **opts):'
2638
2645
2639 for f in changes:
2646 for f in changes:
2640 ui.write(format % f)
2647 ui.write(format % f)
2641 if (opts.get('copies') and not opts.get('no_status')
2648 if ((all or opts.get('copies')) and not opts.get('no_status')
2642 and opt == 'added' and repo.dirstate.copies.has_key(f)):
2649 and opt == 'added' and repo.dirstate.copies.has_key(f)):
2643 ui.write(' %s%s' % (repo.dirstate.copies[f], end))
2650 ui.write(' %s%s' % (repo.dirstate.copies[f], end))
2644
2651
@@ -3123,10 +3130,12 b' table = {'
3123 _('hg serve [OPTION]...')),
3130 _('hg serve [OPTION]...')),
3124 "^status|st":
3131 "^status|st":
3125 (status,
3132 (status,
3126 [('m', 'modified', None, _('show only modified files')),
3133 [('A', 'all', None, _('show status of all files')),
3134 ('m', 'modified', None, _('show only modified files')),
3127 ('a', 'added', None, _('show only added files')),
3135 ('a', 'added', None, _('show only added files')),
3128 ('r', 'removed', None, _('show only removed files')),
3136 ('r', 'removed', None, _('show only removed files')),
3129 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
3137 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
3138 ('c', 'clean', None, _('show only files without changes')),
3130 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
3139 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
3131 ('i', 'ignored', None, _('show ignored files')),
3140 ('i', 'ignored', None, _('show ignored files')),
3132 ('n', 'no-status', None, _('hide status prefix')),
3141 ('n', 'no-status', None, _('hide status prefix')),
@@ -434,15 +434,16 b' class dirstate(object):'
434 if not seen(k) and (statmatch(k, None)):
434 if not seen(k) and (statmatch(k, None)):
435 yield 'm', k, None
435 yield 'm', k, None
436
436
437 def changes(self, files=None, match=util.always, show_ignored=None):
437 def status(self, files=None, match=util.always, list_ignored=False,
438 list_clean=False):
438 lookup, modified, added, unknown, ignored = [], [], [], [], []
439 lookup, modified, added, unknown, ignored = [], [], [], [], []
439 removed, deleted = [], []
440 removed, deleted, clean = [], [], []
440
441
441 for src, fn, st in self.statwalk(files, match, ignored=show_ignored):
442 for src, fn, st in self.statwalk(files, match, ignored=list_ignored):
442 try:
443 try:
443 type_, mode, size, time = self[fn]
444 type_, mode, size, time = self[fn]
444 except KeyError:
445 except KeyError:
445 if show_ignored and self.ignore(fn):
446 if list_ignored and self.ignore(fn):
446 ignored.append(fn)
447 ignored.append(fn)
447 else:
448 else:
448 unknown.append(fn)
449 unknown.append(fn)
@@ -473,6 +474,8 b' class dirstate(object):'
473 modified.append(fn)
474 modified.append(fn)
474 elif time != st.st_mtime:
475 elif time != st.st_mtime:
475 lookup.append(fn)
476 lookup.append(fn)
477 elif list_clean:
478 clean.append(fn)
476 elif type_ == 'm':
479 elif type_ == 'm':
477 modified.append(fn)
480 modified.append(fn)
478 elif type_ == 'a':
481 elif type_ == 'a':
@@ -480,4 +483,5 b' class dirstate(object):'
480 elif type_ == 'r':
483 elif type_ == 'r':
481 removed.append(fn)
484 removed.append(fn)
482
485
483 return (lookup, modified, added, removed, deleted, unknown, ignored)
486 return (lookup, modified, added, removed, deleted, unknown, ignored,
487 clean)
@@ -658,9 +658,9 b' class localrepository(repo.repository):'
658 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
658 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
659 yield src, fn
659 yield src, fn
660
660
661 def changes(self, node1=None, node2=None, files=[], match=util.always,
661 def status(self, node1=None, node2=None, files=[], match=util.always,
662 wlock=None, show_ignored=None):
662 wlock=None, list_ignored=False, list_clean=False):
663 """return changes between two nodes or node and working directory
663 """return status of files between two nodes or node and working directory
664
664
665 If node1 is None, use the first dirstate parent instead.
665 If node1 is None, use the first dirstate parent instead.
666 If node2 is None, compare node1 with working directory.
666 If node2 is None, compare node1 with working directory.
@@ -679,7 +679,9 b' class localrepository(repo.repository):'
679 del mf[fn]
679 del mf[fn]
680 return mf
680 return mf
681
681
682 modified, added, removed, deleted, unknown, ignored = [],[],[],[],[],[]
682 modified, added, removed, deleted, unknown = [], [], [], [], []
683 ignored, clean = [], []
684
683 compareworking = False
685 compareworking = False
684 if not node1 or (not node2 and node1 == self.dirstate.parents()[0]):
686 if not node1 or (not node2 and node1 == self.dirstate.parents()[0]):
685 compareworking = True
687 compareworking = True
@@ -697,8 +699,9 b' class localrepository(repo.repository):'
697 wlock = self.wlock(wait=0)
699 wlock = self.wlock(wait=0)
698 except lock.LockException:
700 except lock.LockException:
699 wlock = None
701 wlock = None
700 lookup, modified, added, removed, deleted, unknown, ignored = (
702 (lookup, modified, added, removed, deleted, unknown,
701 self.dirstate.changes(files, match, show_ignored))
703 ignored, clean) = self.dirstate.status(files, match,
704 list_ignored, list_clean)
702
705
703 # are we comparing working dir against its parent?
706 # are we comparing working dir against its parent?
704 if compareworking:
707 if compareworking:
@@ -721,12 +724,11 b' class localrepository(repo.repository):'
721 del mf2[f]
724 del mf2[f]
722 else:
725 else:
723 # we are comparing two revisions
726 # we are comparing two revisions
724 deleted, unknown, ignored = [], [], []
725 mf2 = mfmatches(node2)
727 mf2 = mfmatches(node2)
726
728
727 if not compareworking:
729 if not compareworking:
728 # flush lists from dirstate before comparing manifests
730 # flush lists from dirstate before comparing manifests
729 modified, added = [], []
731 modified, added, clean = [], [], []
730
732
731 # make sure to sort the files so we talk to the disk in a
733 # make sure to sort the files so we talk to the disk in a
732 # reasonable order
734 # reasonable order
@@ -736,6 +738,8 b' class localrepository(repo.repository):'
736 if mf1.has_key(fn):
738 if mf1.has_key(fn):
737 if mf1[fn] != mf2[fn] and (mf2[fn] != "" or fcmp(fn, mf1)):
739 if mf1[fn] != mf2[fn] and (mf2[fn] != "" or fcmp(fn, mf1)):
738 modified.append(fn)
740 modified.append(fn)
741 elif list_clean:
742 clean.append(fn)
739 del mf1[fn]
743 del mf1[fn]
740 else:
744 else:
741 added.append(fn)
745 added.append(fn)
@@ -743,12 +747,19 b' class localrepository(repo.repository):'
743 removed = mf1.keys()
747 removed = mf1.keys()
744
748
745 # sort and return results:
749 # sort and return results:
746 for l in modified, added, removed, deleted, unknown, ignored:
750 for l in modified, added, removed, deleted, unknown, ignored, clean:
747 l.sort()
751 l.sort()
748 if show_ignored is None:
752 return (modified, added, removed, deleted, unknown, ignored, clean)
749 return (modified, added, removed, deleted, unknown)
753
754 def changes(self, node1=None, node2=None, files=[], match=util.always,
755 wlock=None, list_ignored=False, list_clean=False):
756 '''DEPRECATED - use status instead'''
757 marduit = self.status(node1, node2, files, match, wlock,
758 list_ignored, list_clean)
759 if list_ignored:
760 return marduit[:-1]
750 else:
761 else:
751 return (modified, added, removed, deleted, unknown, ignored)
762 return marduit[:-2]
752
763
753 def add(self, list, wlock=None):
764 def add(self, list, wlock=None):
754 if not wlock:
765 if not wlock:
@@ -185,13 +185,15 b' hg status [OPTION]... [FILE]...'
185
185
186 show changed files in the working directory
186 show changed files in the working directory
187
187
188 Show changed files in the repository. If names are
188 Show status of files in the repository. If names are given, only
189 given, only files that match are shown.
189 files that match are shown. Files that are clean or ignored, are
190 not listed unless -c (clean), -i (ignored) or -A is given.
190
191
191 The codes used to show the status of files are:
192 The codes used to show the status of files are:
192 M = modified
193 M = modified
193 A = added
194 A = added
194 R = removed
195 R = removed
196 C = clean
195 ! = deleted, but still tracked
197 ! = deleted, but still tracked
196 ? = not tracked
198 ? = not tracked
197 I = ignored (not shown by default)
199 I = ignored (not shown by default)
@@ -201,10 +203,12 b' aliases: st'
201
203
202 options:
204 options:
203
205
206 -A --all show status of all files
204 -m --modified show only modified files
207 -m --modified show only modified files
205 -a --added show only added files
208 -a --added show only added files
206 -r --removed show only removed files
209 -r --removed show only removed files
207 -d --deleted show only deleted (but tracked) files
210 -d --deleted show only deleted (but tracked) files
211 -c --clean show only files without changes
208 -u --unknown show only unknown (not tracked) files
212 -u --unknown show only unknown (not tracked) files
209 -i --ignored show ignored files
213 -i --ignored show ignored files
210 -n --no-status hide status prefix
214 -n --no-status hide status prefix
@@ -35,3 +35,8 b' hg status modified added removed deleted'
35 hg copy modified copied
35 hg copy modified copied
36 echo "hg status -C:"
36 echo "hg status -C:"
37 hg status -C
37 hg status -C
38
39 echo "hg status -t:"
40 hg status -t
41 echo "hg status -A:"
42 hg status -A
@@ -108,3 +108,50 b' A copied'
108 R removed
108 R removed
109 ! deleted
109 ! deleted
110 ? unknown
110 ? unknown
111 hg status -t:
112 hg status: option -t not recognized
113 hg status [OPTION]... [FILE]...
114
115 show changed files in the working directory
116
117 Show status of files in the repository. If names are given, only
118 files that match are shown. Files that are clean or ignored, are
119 not listed unless -c (clean), -i (ignored) or -A is given.
120
121 The codes used to show the status of files are:
122 M = modified
123 A = added
124 R = removed
125 C = clean
126 ! = deleted, but still tracked
127 ? = not tracked
128 I = ignored (not shown by default)
129 = the previous added file was copied from here
130
131 aliases: st
132
133 options:
134
135 -A --all show status of all files
136 -m --modified show only modified files
137 -a --added show only added files
138 -r --removed show only removed files
139 -d --deleted show only deleted (but tracked) files
140 -c --clean show only files without changes
141 -u --unknown show only unknown (not tracked) files
142 -i --ignored show ignored files
143 -n --no-status hide status prefix
144 -C --copies show source of copied files
145 -0 --print0 end filenames with NUL, for use with xargs
146 -I --include include names matching the given patterns
147 -X --exclude exclude names matching the given patterns
148 hg status -A:
149 A added
150 A copied
151 modified
152 R removed
153 ! deleted
154 ? unknown
155 I ignored
156 C .hgignore
157 C modified
General Comments 0
You need to be logged in to leave comments. Login now