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 8e93787e..4e0253fc 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 oldpath = None 103 oldpath = None
86 while path \ 104 while path \
87 and path != oldpath \ 105 and path != oldpath \
@@ -92,11 +110,6 @@ class Command(object):
92 except KeyError: 110 except KeyError:
93 oldpath = path 111 oldpath = path
94 path = os.path.dirname(path) 112 path = os.path.dirname(path)
95 else:
96 try:
97 project = by_path[path]
98 except KeyError:
99 pass
100 113
101 if not project: 114 if not project:
102 raise NoSuchProjectError(arg) 115 raise NoSuchProjectError(arg)