From df14a70c4529821d7450303ec553a9f608af1656 Mon Sep 17 00:00:00 2001 From: Anthony Newnam Date: Sun, 9 Jan 2011 17:31:57 -0800 Subject: [PATCH] Make path references OS independent Change-Id: I5573995adfd52fd54bddc62d1d1ea78fb1328130 (cherry picked from commit b0f9a02394779c1c9422a9649412c9ac5fb0f12f) Conflicts: command.py --- command.py | 6 ++++-- manifest_xml.py | 2 +- project.py | 4 ++-- repo | 6 +++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/command.py b/command.py index a941b95a..8e93787e 100644 --- a/command.py +++ b/command.py @@ -74,7 +74,7 @@ class Command(object): project = all.get(arg) if not project: - path = os.path.abspath(arg) + path = os.path.abspath(arg).replace('\\', '/') if not by_path: by_path = dict() @@ -82,13 +82,15 @@ class Command(object): by_path[p.worktree] = p if os.path.exists(path): + oldpath = None while path \ - and path != '/' \ + and path != oldpath \ and path != self.manifest.topdir: try: project = by_path[path] break except KeyError: + oldpath = path path = os.path.dirname(path) else: try: diff --git a/manifest_xml.py b/manifest_xml.py index 9d68f09f..0103cf55 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -435,7 +435,7 @@ class XmlManifest(object): worktree = None gitdir = os.path.join(self.topdir, '%s.git' % name) else: - worktree = os.path.join(self.topdir, path) + worktree = os.path.join(self.topdir, path).replace('\\', '/') gitdir = os.path.join(self.repodir, 'projects/%s.git' % path) project = Project(manifest = self, diff --git a/project.py b/project.py index 01dc8678..25347daf 100644 --- a/project.py +++ b/project.py @@ -236,8 +236,8 @@ class Project(object): self.manifest = manifest self.name = name self.remote = remote - self.gitdir = gitdir - self.worktree = worktree + self.gitdir = gitdir.replace('\\', '/') + self.worktree = worktree.replace('\\', '/') self.relpath = relpath self.revisionExpr = revisionExpr diff --git a/repo b/repo index 02858ec2..96daa9b7 100755 --- a/repo +++ b/repo @@ -430,10 +430,14 @@ def _FindRepo(): dir = os.getcwd() repo = None - while dir != '/' and not repo: + olddir = None + while dir != '/' \ + and dir != olddir \ + and not repo: repo = os.path.join(dir, repodir, REPO_MAIN) if not os.path.isfile(repo): repo = None + olddir = dir dir = os.path.dirname(dir) return (repo, os.path.join(dir, repodir))