Mercurial > hg-stable
changeset 861:cbe5c4d016b7
dirstate.changes() now distinguishes 'hg remove'd or just deleted files.
Interface is not yet changed.
Non-regular files are considered to be removed or deleted.
Removed the unneeded match(fn) call for adding to the unknown list.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 09 Aug 2005 11:32:30 +0100 |
parents | 8ccbac05cf59 |
children | d70c1c31fd45 |
files | mercurial/hg.py |
diffstat | 1 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Tue Aug 09 11:15:57 2005 +0100 +++ b/mercurial/hg.py Tue Aug 09 11:32:30 2005 +0100 @@ -10,7 +10,7 @@ from revlog import * from demandload import * demandload(globals(), "re lock urllib urllib2 transaction time socket") -demandload(globals(), "tempfile httprangereader bdiff urlparse") +demandload(globals(), "tempfile httprangereader bdiff urlparse stat") demandload(globals(), "bisect select") class filelog(revlog): @@ -484,33 +484,41 @@ if match(fn): yield src, fn - def changes(self, files = None, match = util.always): + def changes(self, files=None, match=util.always): self.read() dc = self.map.copy() - lookup, changed, added, unknown = [], [], [], [] + lookup, modified, added, unknown = [], [], [], [] + removed, deleted = [], [] for src, fn in self.walk(files, match): - try: s = os.stat(os.path.join(self.root, fn)) - except: continue - - if fn in dc: - c = dc[fn] + try: + s = os.stat(os.path.join(self.root, fn)) + except OSError: + continue + if not stat.S_ISREG(s.st_mode): + continue + c = dc.get(fn) + if c: del dc[fn] - if c[0] == 'm': - changed.append(fn) + modified.append(fn) elif c[0] == 'a': added.append(fn) elif c[0] == 'r': unknown.append(fn) elif c[2] != s.st_size or (c[1] ^ s.st_mode) & 0100: - changed.append(fn) - elif c[1] != s.st_mode or c[3] != s.st_mtime: + modified.append(fn) + elif c[3] != s.st_mtime: lookup.append(fn) else: - if match(fn): unknown.append(fn) + unknown.append(fn) - return (lookup, changed, added, filter(match, dc.keys()), unknown) + for fn, c in [(fn, c) for fn, c in dc.items() if match(fn)]: + if c[0] == 'r': + removed.append(fn) + else: + deleted.append(fn) + return (lookup, modified, added, removed + deleted, unknown) # used to avoid circular references so destructors work def opener(base):