loman: don't report error when adding an exact duplicate.

BUG=5787
TEST=Updated and re-ran unittests.

Change-Id: I399e8cacde103f16b749dd83c57d03bcdf2e9475

Review URL: http://codereview.chromium.org/3385001
This commit is contained in:
Mandeep Singh Baines 2010-09-14 10:19:50 -07:00
parent 03b6ebf7d4
commit 6c6000b2c2
2 changed files with 7 additions and 2 deletions

View File

@ -43,6 +43,9 @@ class LocalManifest:
for project in self._root.findall('project'):
if project.attrib['path'] == path or project.attrib['name'] == name:
if project.attrib['path'] == path and project.attrib['name'] == name:
return True
else:
return False
self._AddProject(name, path, workon='True')
return True

View File

@ -52,7 +52,7 @@ class LocalManifestTest(unittest.TestCase):
ptree = loman.LocalManifest('<manifest>\n</manifest>')
ptree.Parse()
ptree.AddWorkonProject('foo', 'path/to/foo')
self.assertTrue(not ptree.AddWorkonProject('foo', 'path/to/foo'))
self.assertTrue(ptree.AddWorkonProject('foo', 'path/to/foo'))
self.assertTrue(not ptree.AddWorkonProject('foo', 'path/foo'))
self.assertTrue(not ptree.AddWorkonProject('foobar', 'path/to/foo'))
@ -100,11 +100,13 @@ class MainTest(unittest.TestCase):
print >> temp, '<manifest>\n</manifest>'
temp.flush()
os.fsync(temp.fileno())
loman.main(['loman', 'add', '--workon', '-f',
temp.name, 'foo', 'path/to/foo'])
loman.main(['loman', 'add', '--workon', '-f',
temp.name, 'foo', 'path/to/foo'])
self.assertRaises(SystemExit, loman.main,
['loman', 'add', '--workon', '-f',
temp.name, 'foo', 'path/to/foo'])
temp.name, 'foo', 'path/foo'])
if __name__ == '__main__':