summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
Diffstat (limited to 'command.py')
-rw-r--r--command.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/command.py b/command.py
index a941b95a..6e4e2c57 100644
--- a/command.py
+++ b/command.py
@@ -17,6 +17,8 @@ import os
17import optparse 17import optparse
18import sys 18import sys
19 19
20import manifest_loader
21
20from error import NoSuchProjectError 22from error import NoSuchProjectError
21 23
22class Command(object): 24class Command(object):
@@ -24,7 +26,6 @@ class Command(object):
24 """ 26 """
25 27
26 common = False 28 common = False
27 manifest = None
28 _optparse = None 29 _optparse = None
29 30
30 def WantPager(self, opt): 31 def WantPager(self, opt):
@@ -57,10 +58,25 @@ class Command(object):
57 """ 58 """
58 raise NotImplementedError 59 raise NotImplementedError
59 60
61 @property
62 def manifest(self):
63 return self.GetManifest()
64
65 def GetManifest(self, reparse=False, type=None):
66 return manifest_loader.GetManifest(self.repodir,
67 reparse=reparse,
68 type=type)
69
60 def GetProjects(self, args, missing_ok=False): 70 def GetProjects(self, args, missing_ok=False):
61 """A list of projects that match the arguments. 71 """A list of projects that match the arguments.
62 """ 72 """
63 all = self.manifest.projects 73 all = self.manifest.projects
74
75 mp = self.manifest.manifestProject
76 if mp.relpath == '.':
77 all = dict(all)
78 all[mp.name] = mp
79
64 result = [] 80 result = []
65 81
66 if not args: 82 if not args:
@@ -81,7 +97,9 @@ class Command(object):
81 for p in all.values(): 97 for p in all.values():
82 by_path[p.worktree] = p 98 by_path[p.worktree] = p
83 99
84 if os.path.exists(path): 100 try:
101 project = by_path[path]
102 except KeyError:
85 while path \ 103 while path \
86 and path != '/' \ 104 and path != '/' \
87 and path != self.manifest.topdir: 105 and path != self.manifest.topdir:
@@ -90,11 +108,6 @@ class Command(object):
90 break 108 break
91 except KeyError: 109 except KeyError:
92 path = os.path.dirname(path) 110 path = os.path.dirname(path)
93 else:
94 try:
95 project = by_path[path]
96 except KeyError:
97 pass
98 111
99 if not project: 112 if not project:
100 raise NoSuchProjectError(arg) 113 raise NoSuchProjectError(arg)