##// END OF EJS Templates
match: remove files arg from repo.status and friends
Matt Mackall -
r6603:41eb20cc default
parent child Browse files
Show More
@@ -123,7 +123,7 b' def dodiff(ui, repo, diffcmd, diffopts, '
123 node1, node2 = cmdutil.revpair(repo, opts['rev'])
123 node1, node2 = cmdutil.revpair(repo, opts['rev'])
124 matcher = cmdutil.match(repo, pats, opts)
124 matcher = cmdutil.match(repo, pats, opts)
125 modified, added, removed, deleted, unknown = repo.status(
125 modified, added, removed, deleted, unknown = repo.status(
126 node1, node2, matcher.files(), match=matcher)[:5]
126 node1, node2, matcher)[:5]
127 if not (modified or added or removed):
127 if not (modified or added or removed):
128 return 0
128 return 0
129
129
@@ -56,7 +56,7 b' def difftree(ui, repo, node1=None, node2'
56 mmap = repo.changectx(node1).manifest()
56 mmap = repo.changectx(node1).manifest()
57 mmap2 = repo.changectx(node2).manifest()
57 mmap2 = repo.changectx(node2).manifest()
58 m = cmdutil.matchfiles(repo, files)
58 m = cmdutil.matchfiles(repo, files)
59 status = repo.status(node1, node2, files=m.files(), match=m)[:5]
59 status = repo.status(node1, node2, match=m)[:5]
60 modified, added, removed, deleted, unknown = status
60 modified, added, removed, deleted, unknown = status
61
61
62 empty = short(nullid)
62 empty = short(nullid)
@@ -47,8 +47,9 b' def reposetup(ui, repo):'
47 # to recurse.
47 # to recurse.
48 inotifyserver = False
48 inotifyserver = False
49
49
50 def status(self, files, match, list_ignored, list_clean,
50 def status(self, match, list_ignored, list_clean,
51 list_unknown=True):
51 list_unknown=True):
52 files = match.files()
52 try:
53 try:
53 if not list_ignored and not self.inotifyserver:
54 if not list_ignored and not self.inotifyserver:
54 result = client.query(ui, repo, files, match, False,
55 result = client.query(ui, repo, files, match, False,
@@ -88,7 +89,7 b' def reposetup(ui, repo):'
88 ui.print_exc()
89 ui.print_exc()
89
90
90 return super(inotifydirstate, self).status(
91 return super(inotifydirstate, self).status(
91 files, match or util.always, list_ignored, list_clean,
92 match, list_ignored, list_clean,
92 list_unknown)
93 list_unknown)
93
94
94 repo.dirstate.__class__ = inotifydirstate
95 repo.dirstate.__class__ = inotifydirstate
@@ -256,7 +256,7 b' def _status(ui, repo, kwt, *pats, **opts'
256 Returns status of working directory.'''
256 Returns status of working directory.'''
257 if kwt:
257 if kwt:
258 matcher = cmdutil.match(repo, pats, opts)
258 matcher = cmdutil.match(repo, pats, opts)
259 return repo.status(files=matcher.files(), match=matcher, list_clean=True)
259 return repo.status(match=matcher, list_clean=True)
260 if ui.configitems('keyword'):
260 if ui.configitems('keyword'):
261 raise util.Abort(_('[keyword] patterns cannot match'))
261 raise util.Abort(_('[keyword] patterns cannot match'))
262 raise util.Abort(_('no [keyword] patterns configured'))
262 raise util.Abort(_('no [keyword] patterns configured'))
@@ -456,7 +456,7 b' def reposetup(ui, repo):'
456 return kwt.wread(filename, data)
456 return kwt.wread(filename, data)
457
457
458 def commit(self, files=None, text='', user=None, date=None,
458 def commit(self, files=None, text='', user=None, date=None,
459 match=util.always, force=False, force_editor=False,
459 match=None, force=False, force_editor=False,
460 p1=None, p2=None, extra={}, empty_ok=False):
460 p1=None, p2=None, extra={}, empty_ok=False):
461 wlock = lock = None
461 wlock = lock = None
462 _p1 = _p2 = None
462 _p1 = _p2 = None
@@ -506,8 +506,10 b' class queue:'
506 repo.dirstate.merge(f)
506 repo.dirstate.merge(f)
507 p1, p2 = repo.dirstate.parents()
507 p1, p2 = repo.dirstate.parents()
508 repo.dirstate.setparents(p1, merge)
508 repo.dirstate.setparents(p1, merge)
509
509 files = patch.updatedir(self.ui, repo, files)
510 files = patch.updatedir(self.ui, repo, files)
510 n = repo.commit(files, message, user, date, match=util.never,
511 match = cmdutil.matchfiles(repo, files or [])
512 n = repo.commit(files, message, user, date, match=match,
511 force=True)
513 force=True)
512
514
513 if n == None:
515 if n == None:
@@ -620,7 +622,7 b' class queue:'
620 raise util.Abort(_('patch "%s" already exists') % patch)
622 raise util.Abort(_('patch "%s" already exists') % patch)
621 if opts.get('include') or opts.get('exclude') or pats:
623 if opts.get('include') or opts.get('exclude') or pats:
622 match = cmdutil.match(repo, pats, opts)
624 match = cmdutil.match(repo, pats, opts)
623 m, a, r, d = repo.status(files=match.files(), match=match)[:4]
625 m, a, r, d = repo.status(match=match)[:4]
624 else:
626 else:
625 m, a, r, d = self.check_localchanges(repo, force)
627 m, a, r, d = self.check_localchanges(repo, force)
626 match = cmdutil.match(repo, m + a + r)
628 match = cmdutil.match(repo, m + a + r)
@@ -1047,7 +1049,7 b' class queue:'
1047 match = cmdutil.matchfiles(repo, mm + aa + dd)
1049 match = cmdutil.matchfiles(repo, mm + aa + dd)
1048 else:
1050 else:
1049 match = cmdutil.matchall(repo)
1051 match = cmdutil.matchall(repo)
1050 m, a, r, d, u = repo.status(files=match.files(), match=match)[:5]
1052 m, a, r, d, u = repo.status(match=match)[:5]
1051
1053
1052 # we might end up with files that were added between
1054 # we might end up with files that were added between
1053 # tip and the dirstate parent, but then changed in the
1055 # tip and the dirstate parent, but then changed in the
@@ -86,8 +86,7 b' def purge(ui, repo, *dirs, **opts):'
86 files = []
86 files = []
87 match = cmdutil.match(repo, dirs, opts)
87 match = cmdutil.match(repo, dirs, opts)
88 match.dir = directories.append
88 match.dir = directories.append
89 for src, f, st in repo.dirstate.statwalk(match.files(), match,
89 for src, f, st in repo.dirstate.statwalk(match, ignored=ignored):
90 ignored=ignored):
91 if src == 'f' and f not in repo.dirstate:
90 if src == 'f' and f not in repo.dirstate:
92 files.append(f)
91 files.append(f)
93
92
@@ -431,7 +431,7 b' def dorecord(ui, repo, committer, *pats,'
431
431
432 if changes is None:
432 if changes is None:
433 match = cmdutil.matchfiles(repo, newfiles)
433 match = cmdutil.matchfiles(repo, newfiles)
434 changes = repo.status(files=match.files(), match=match)[:5]
434 changes = repo.status(match=match)[:5]
435 modified = dict.fromkeys(changes[0])
435 modified = dict.fromkeys(changes[0])
436
436
437 # 2. backup changed files, so we can restore them in the end
437 # 2. backup changed files, so we can restore them in the end
@@ -1153,7 +1153,7 b' def commit(ui, repo, commitfunc, pats, o'
1153
1153
1154 m = match(repo, pats, opts)
1154 m = match(repo, pats, opts)
1155 if pats:
1155 if pats:
1156 status = repo.status(files=m.files(), match=m)
1156 status = repo.status(match=m)
1157 modified, added, removed, deleted, unknown = status[:5]
1157 modified, added, removed, deleted, unknown = status[:5]
1158 files = modified + added + removed
1158 files = modified + added + removed
1159 slist = None
1159 slist = None
@@ -2180,7 +2180,7 b' def remove(ui, repo, *pats, **opts):'
2180 raise util.Abort(_('no files specified'))
2180 raise util.Abort(_('no files specified'))
2181
2181
2182 m = cmdutil.match(repo, pats, opts)
2182 m = cmdutil.match(repo, pats, opts)
2183 mardu = map(dict.fromkeys, repo.status(files=m.files(), match=m))[:5]
2183 mardu = map(dict.fromkeys, repo.status(match=m))[:5]
2184 modified, added, removed, deleted, unknown = mardu
2184 modified, added, removed, deleted, unknown = mardu
2185
2185
2186 remove, forget = [], []
2186 remove, forget = [], []
@@ -2363,7 +2363,7 b' def revert(ui, repo, *pats, **opts):'
2363 names[abs] = m.rel(abs), m.exact(abs)
2363 names[abs] = m.rel(abs), m.exact(abs)
2364
2364
2365 m = cmdutil.matchfiles(repo, names)
2365 m = cmdutil.matchfiles(repo, names)
2366 changes = repo.status(files=m.files(), match=m)[:4]
2366 changes = repo.status(match=m)[:4]
2367 modified, added, removed, deleted = map(dict.fromkeys, changes)
2367 modified, added, removed, deleted = map(dict.fromkeys, changes)
2368
2368
2369 # if f is a rename, also revert the source
2369 # if f is a rename, also revert the source
@@ -2630,7 +2630,7 b' def status(ui, repo, *pats, **opts):'
2630 matcher = cmdutil.match(repo, pats, opts)
2630 matcher = cmdutil.match(repo, pats, opts)
2631 cwd = (pats and repo.getcwd()) or ''
2631 cwd = (pats and repo.getcwd()) or ''
2632 modified, added, removed, deleted, unknown, ignored, clean = [
2632 modified, added, removed, deleted, unknown, ignored, clean = [
2633 n for n in repo.status(node1, node2, matcher.files(), matcher,
2633 n for n in repo.status(node1, node2, matcher,
2634 list_ignored=opts['ignored']
2634 list_ignored=opts['ignored']
2635 or all and not ui.quiet,
2635 or all and not ui.quiet,
2636 list_clean=opts['clean'] or all,
2636 list_clean=opts['clean'] or all,
@@ -418,10 +418,10 b' class dirstate(object):'
418
418
419 def walk(self, match):
419 def walk(self, match):
420 # filter out the src and stat
420 # filter out the src and stat
421 for src, f, st in self.statwalk(match.files(), match):
421 for src, f, st in self.statwalk(match):
422 yield f
422 yield f
423
423
424 def statwalk(self, files, match, unknown=True, ignored=False):
424 def statwalk(self, match, unknown=True, ignored=False):
425 '''
425 '''
426 walk recursively through the directory tree, finding all files
426 walk recursively through the directory tree, finding all files
427 matched by the match function
427 matched by the match function
@@ -442,6 +442,7 b' class dirstate(object):'
442 badfn = match.bad
442 badfn = match.bad
443
443
444 # walk all files by default
444 # walk all files by default
445 files = match.files()
445 if not files:
446 if not files:
446 files = ['.']
447 files = ['.']
447 dc = self._map.copy()
448 dc = self._map.copy()
@@ -569,11 +570,10 b' class dirstate(object):'
569 if imatch(k):
570 if imatch(k):
570 yield 'm', k, None
571 yield 'm', k, None
571
572
572 def status(self, files, match, list_ignored, list_clean, list_unknown):
573 def status(self, match, list_ignored, list_clean, list_unknown):
573 lookup, modified, added, unknown, ignored = [], [], [], [], []
574 lookup, modified, added, unknown, ignored = [], [], [], [], []
574 removed, deleted, clean = [], [], []
575 removed, deleted, clean = [], [], []
575
576
576 files = files or []
577 _join = self._join
577 _join = self._join
578 lstat = os.lstat
578 lstat = os.lstat
579 cmap = self._copymap
579 cmap = self._copymap
@@ -587,10 +587,10 b' class dirstate(object):'
587 dadd = deleted.append
587 dadd = deleted.append
588 cadd = clean.append
588 cadd = clean.append
589
589
590 for src, fn, st in self.statwalk(files, match, unknown=list_unknown,
590 for src, fn, st in self.statwalk(match, unknown=list_unknown,
591 ignored=list_ignored):
591 ignored=list_ignored):
592 if fn not in dmap:
592 if fn not in dmap:
593 if (list_ignored or fn in files) and self._dirignore(fn):
593 if (list_ignored or match.exact(fn)) and self._dirignore(fn):
594 if list_ignored:
594 if list_ignored:
595 iadd(fn)
595 iadd(fn)
596 elif list_unknown:
596 elif list_unknown:
@@ -11,6 +11,7 b' import repo, changegroup'
11 import changelog, dirstate, filelog, manifest, context, weakref
11 import changelog, dirstate, filelog, manifest, context, weakref
12 import lock, transaction, stat, errno, ui
12 import lock, transaction, stat, errno, ui
13 import os, revlog, time, util, extensions, hook, inspect
13 import os, revlog, time, util, extensions, hook, inspect
14 import match as match_
14
15
15 class localrepository(repo.repository):
16 class localrepository(repo.repository):
16 capabilities = util.set(('lookup', 'changegroupsubset'))
17 capabilities = util.set(('lookup', 'changegroupsubset'))
@@ -748,7 +749,7 b' class localrepository(repo.repository):'
748 p1=p1, p2=p2, extra=extra, empty_ok=True)
749 p1=p1, p2=p2, extra=extra, empty_ok=True)
749
750
750 def commit(self, files=None, text="", user=None, date=None,
751 def commit(self, files=None, text="", user=None, date=None,
751 match=util.always, force=False, force_editor=False,
752 match=None, force=False, force_editor=False,
752 p1=None, p2=None, extra={}, empty_ok=False):
753 p1=None, p2=None, extra={}, empty_ok=False):
753 wlock = lock = tr = None
754 wlock = lock = tr = None
754 valid = 0 # don't save the dirstate if this isn't set
755 valid = 0 # don't save the dirstate if this isn't set
@@ -964,7 +965,7 b' class localrepository(repo.repository):'
964 for fn in self.dirstate.walk(match):
965 for fn in self.dirstate.walk(match):
965 yield fn
966 yield fn
966
967
967 def status(self, node1=None, node2=None, files=[], match=util.always,
968 def status(self, node1=None, node2=None, match=None,
968 list_ignored=False, list_clean=False, list_unknown=True):
969 list_ignored=False, list_clean=False, list_unknown=True):
969 """return status of files between two nodes or node and working directory
970 """return status of files between two nodes or node and working directory
970
971
@@ -984,6 +985,9 b' class localrepository(repo.repository):'
984 del mf[fn]
985 del mf[fn]
985 return mf
986 return mf
986
987
988 if not match:
989 match = match_.always(self.root, self.getcwd())
990
987 modified, added, removed, deleted, unknown = [], [], [], [], []
991 modified, added, removed, deleted, unknown = [], [], [], [], []
988 ignored, clean = [], []
992 ignored, clean = [], []
989
993
@@ -1000,10 +1004,8 b' class localrepository(repo.repository):'
1000 # are we comparing the working directory?
1004 # are we comparing the working directory?
1001 if not node2:
1005 if not node2:
1002 (lookup, modified, added, removed, deleted, unknown,
1006 (lookup, modified, added, removed, deleted, unknown,
1003 ignored, clean) = self.dirstate.status(files, match,
1007 ignored, clean) = self.dirstate.status(match, list_ignored,
1004 list_ignored, list_clean,
1008 list_clean, list_unknown)
1005 list_unknown)
1006
1007 # are we comparing working dir against its parent?
1009 # are we comparing working dir against its parent?
1008 if compareworking:
1010 if compareworking:
1009 if lookup:
1011 if lookup:
@@ -1186,7 +1186,7 b' def diff(repo, node1=None, node2=None, m'
1186 date1 = util.datestr(ctx1.date())
1186 date1 = util.datestr(ctx1.date())
1187
1187
1188 if not changes:
1188 if not changes:
1189 changes = repo.status(node1, node2, files=match.files(), match=match)[:5]
1189 changes = repo.status(node1, node2, match=match)[:5]
1190 modified, added, removed, deleted, unknown = changes
1190 modified, added, removed, deleted, unknown = changes
1191
1191
1192 if not modified and not added and not removed:
1192 if not modified and not added and not removed:
@@ -96,6 +96,7 b' abort: local changes found, refresh firs'
96 A somefile
96 A somefile
97 % qnew with uncommitted changes and missing file (issue 803)
97 % qnew with uncommitted changes and missing file (issue 803)
98 someotherfile: No such file or directory
98 someotherfile: No such file or directory
99 someotherfile: No such file or directory
99 A somefile
100 A somefile
100 issue803.patch
101 issue803.patch
101 Patch queue now empty
102 Patch queue now empty
General Comments 0
You need to be logged in to leave comments. Login now