Mercurial > hg > hgforest
changeset 33:54ab5a322cac
use util.walkrepos to enumerate nested repositories
author | Robin Farine <robin.farine@terminus.org> |
---|---|
date | Sun, 17 Dec 2006 19:56:29 +0100 |
parents | 8732cc34aea6 |
children | 3668035ca554 |
files | forest.py |
diffstat | 1 files changed, 16 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/forest.py Sun Dec 17 17:09:27 2006 +0100 +++ b/forest.py Sun Dec 17 19:56:29 2006 +0100 @@ -51,23 +51,21 @@ return res -def enumerate_repos(ui, top=''): - """Generate a lexicographically sorted list of repository roots.""" +def enumerate_repos(ui, top='.'): + """Generate a lexicographically sorted list of repository roots. + + When explicit, top must be a normalized path. + """ - dirs = ['.'] - while dirs: - root = dirs.pop() - entries = os.listdir(os.path.join(top, root)) - entries.sort() - entries.reverse() - for e in entries: - path = os.path.join(root, e) - if not os.path.isdir(os.path.join(top, path)): - continue - if e == '.hg': - yield util.normpath(root) - else: - dirs.append(path) + res = util.walkrepos(top) + pfxlen = len(top + os.sep) + res = [p[pfxlen:] for p in res] + res.sort() + # when the prefix is removed from top itself, it yields the empty string; + # let's replace it with '.' + res.remove('') + res.insert(0, '.') + return res def mq_patches_applied(rpath): @@ -226,9 +224,8 @@ srcpath = source destpath = dest else: - subdir = rpath - srcpath = os.path.join(source, subdir) - destpath = os.path.join(dest, subdir) + srcpath = os.path.join(source, rpath) + destpath = os.path.join(dest, rpath) if mq_patches_applied(srcpath): raise util.Abort( _("'%s' has mq patches applied") % util.pconvert(rpath))