# HG changeset patch # User mpm@selenic.com # Date 1120206890 28800 # Node ID f6c6fa15ff706c79d77b47baacfb7e4fafd1a22e # Parent 39a1cfb03ebda231574d532106ea75f11d746bbf Move dirstate.uniq to util.unique -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Move dirstate.uniq to util.unique manifest hash: 8ac613c30a4471f14ae52f14ed0839d66eeaebb7 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxQAqywK+sNU5EO8RAsTiAJ9E9/cALe+W8ojtfVdiXXre5dB/9gCeOgxr mRnVw/WDplkATW5450Pgsug= =xSfl -----END PGP SIGNATURE----- diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -296,16 +296,9 @@ class dirstate: # compare all files by default if not files: files = [self.root] - def uniq(g): - seen = {} - for f in g: - if f not in seen: - seen[f] = 1 - yield f - # recursive generator of all files listed def walk(files): - for f in uniq(files): + for f in util.unique(files): f = os.path.join(self.root, f) if os.path.isdir(f): for dir, subdirs, fl in os.walk(f): @@ -317,7 +310,7 @@ class dirstate: else: yield f[len(self.root) + 1:] - for fn in uniq(walk(files)): + for fn in util.unique(walk(files)): try: s = os.stat(os.path.join(self.root, fn)) except: continue diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -7,6 +7,13 @@ import os +def unique(g): + seen = {} + for f in g: + if f not in seen: + seen[f] = 1 + yield f + class CommandError(Exception): pass def explain_exit(code):