def testUpdateWithoutRevisionPin(self, develop, src, tempdir): from mr.developer.commands import CmdCheckout from mr.developer.commands import CmdUpdate repository = tempdir['repository'] os.mkdir(repository) process = Process(cwd=repository) process.check_call("hg init %s" % repository) foo = repository['foo'] foo.create_file('foo') process.check_call("hg add %s" % foo, echo=False) process.check_call("hg commit %s -m foo -u test" % foo, echo=False) bar = repository['bar'] bar.create_file('bar') process.check_call("hg add %s" % bar, echo=False) process.check_call("hg commit %s -m bar -u test" % bar, echo=False) develop.sources = { 'egg': Source( kind='hg', name='egg', url='%s' % repository, path=os.path.join(src, 'egg'))} _log = patch('mr.developer.mercurial.logger') log = _log.__enter__() try: CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'bar', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'bar', 'foo')) assert log.method_calls == [ ('info', ("Cloned 'egg' with mercurial.",), {}), ('info', ("Updated 'egg' with mercurial.",), {}), ('info', ("Switched 'egg' to default.",), {})] finally: _log.__exit__()
def testUpdateWithRevisionPin(self, develop, src, tempdir): from mr.developer.commands import CmdCheckout from mr.developer.commands import CmdUpdate process = Process() repository = tempdir['repository'] process.check_call("svnadmin create %s" % repository) checkout = tempdir['checkout'] process.check_call( "svn checkout file://%s %s" % (repository, checkout), echo=False) foo = checkout['foo'] foo.create_file('foo') process.check_call("svn add %s" % foo, echo=False) process.check_call("svn commit %s -m foo" % foo, echo=False) bar = checkout['bar'] bar.create_file('bar') process.check_call("svn add %s" % bar, echo=False) process.check_call("svn commit %s -m bar" % bar, echo=False) develop.sources = { 'egg': Source( kind='svn', name='egg', url='file://%s@1' % repository, path=src['egg'])} CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(src['egg'])) == set(('.svn', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(src['egg'])) == set(('.svn', 'foo'))
def testUpdateWithoutRevisionPin(self, develop, src, tempdir): from mr.developer.commands import CmdCheckout from mr.developer.commands import CmdUpdate process = Process() repository = tempdir['repository'] process.check_call("svnadmin create %s" % repository) checkout = tempdir['checkout'] process.check_call( "svn checkout file://%s %s" % (repository, checkout), echo=False) foo = checkout['foo'] foo.create_file('foo') process.check_call("svn add %s" % foo, echo=False) process.check_call("svn commit %s -m foo" % foo, echo=False) bar = checkout['bar'] bar.create_file('bar') process.check_call("svn add %s" % bar, echo=False) process.check_call("svn commit %s -m bar" % bar, echo=False) develop.sources = { 'egg': Source( kind='svn', name='egg', url='file://%s' % repository, path=src['egg'])} _log = patch('mr.developer.svn.logger') log = _log.__enter__() try: CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(src['egg'])) == set(('.svn', 'bar', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(src['egg'])) == set(('.svn', 'bar', 'foo')) assert log.method_calls == [ ('info', ("Checked out 'egg' with subversion.",), {}), ('info', ("Updated 'egg' with subversion.",), {})] finally: _log.__exit__()
def testDepthOption(self, mkgitrepo, src, tempdir): from mr.developer.develop import develop # create repository and make two commits on it repository = mkgitrepo('repository') self.createDefaultContent(repository) tempdir['buildout.cfg'].create_file( '[buildout]', 'mr.developer-threads = 1', '[sources]', 'egg = git %s' % repository.url) tempdir['.mr.developer.cfg'].create_file() # os.chdir(self.tempdir) develop('co', 'egg') # check that there are two commits in history egg_process = Process(cwd=src['egg']) lines = egg_process.check_call("git log", echo=False) commits = [msg for msg in lines if msg.decode('utf-8').startswith('commit')] assert len(commits) == 2 shutil.rmtree(src['egg']) tempdir['buildout.cfg'].create_file( '[buildout]', 'mr.developer-threads = 1', '[sources]', 'egg = git %s depth=1' % repository.url) develop('co', 'egg') # check that there is only one commit in history lines = egg_process.check_call("git log", echo=False) commits = [msg for msg in lines if msg.decode('utf-8').startswith('commit')] assert len(commits) == 1 shutil.rmtree(src['egg']) tempdir['buildout.cfg'].create_file( '[buildout]', 'mr.developer-threads = 1', 'git-clone-depth = 1', '[sources]', 'egg = git %s' % repository.url) develop('co', 'egg') # check that there is only one commit in history lines = egg_process.check_call("git log", echo=False) commits = [msg for msg in lines if msg.decode('utf-8').startswith('commit')] assert len(commits) == 1 # You should be able to combine depth and cloning a branch. # Otherwise with a depth of 1 you could clone the master # branch and then not be able to switch to the wanted branch, # because this branch would not be there: the revision that it # points to is not in the downloaded history. shutil.rmtree(src['egg']) tempdir['buildout.cfg'].create_file( '[buildout]', 'mr.developer-threads = 1', 'git-clone-depth = 1', '[sources]', 'egg = git %s branch=test' % repository.url) develop('co', 'egg') # check that there is only one commit in history lines = egg_process.check_call("git log", echo=False) commits = [msg for msg in lines if msg.decode('utf-8').startswith('commit')] assert len(commits) == 1 # Check that the expected files from the branch are there assert set(os.listdir(src['egg'])) == set(('.git', 'foo', 'foo2'))
def testUpdateWithRevisionPin(self, develop, src, tempdir): from mr.developer.commands import CmdCheckout from mr.developer.commands import CmdUpdate repository = tempdir['repository'] os.mkdir(repository) process = Process(cwd=repository) lines = process.check_call("hg init %s" % repository) foo = repository['foo'] foo.create_file('foo') lines = process.check_call("hg add %s" % foo, echo=False) # create branch for testing lines = process.check_call("hg branch test", echo=False) lines = process.check_call("hg commit %s -m foo -u test" % foo, echo=False) # get comitted rev lines = process.check_call("hg log %s" % foo, echo=False) try: # XXX older version rev = lines[0].split()[1].split(b(':'))[1] except Exception: rev = lines[0].split()[1] # return to default branch lines = process.check_call("hg branch default", echo=False) bar = repository['bar'] bar.create_file('bar') lines = process.check_call("hg add %s" % bar, echo=False) lines = process.check_call("hg commit %s -m bar -u test" % bar, echo=False) # check rev develop.sources = { 'egg': Source(kind='hg', name='egg', rev=rev, url='%s' % repository, path=os.path.join(src, 'egg')) } CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) # check branch develop.sources = { 'egg': Source(kind='hg', name='egg', branch='test', url='%s' % repository, path=os.path.join(src, 'egg')) } CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) # we can't use both rev and branch with pytest.raises(SystemExit): develop.sources = { 'egg': Source(kind='hg', name='egg', branch='test', rev=rev, url='%s' % repository, path=os.path.join(src, 'egg-failed')) } CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
def testUpdateWithRevisionPin(self, develop, src, tempdir): from mr.developer.commands import CmdCheckout from mr.developer.commands import CmdUpdate repository = tempdir['repository'] os.mkdir(repository) process = Process(cwd=repository) lines = process.check_call("hg init %s" % repository) foo = repository['foo'] foo.create_file('foo') lines = process.check_call("hg add %s" % foo, echo=False) # create branch for testing lines = process.check_call("hg branch test", echo=False) lines = process.check_call("hg commit %s -m foo -u test" % foo, echo=False) # get comitted rev lines = process.check_call("hg log %s" % foo, echo=False) try: # XXX older version rev = lines[0].split()[1].split(b(':'))[1] except: rev = lines[0].split()[1] # return to default branch lines = process.check_call("hg branch default", echo=False) bar = repository['bar'] bar.create_file('bar') lines = process.check_call("hg add %s" % bar, echo=False) lines = process.check_call("hg commit %s -m bar -u test" % bar, echo=False) # check rev develop.sources = { 'egg': Source( kind='hg', name='egg', rev=rev, url='%s' % repository, path=os.path.join(src, 'egg'))} CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) # check branch develop.sources = { 'egg': Source( kind='hg', name='egg', branch='test', url='%s' % repository, path=os.path.join(src, 'egg'))} CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg'])) assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo')) # we can't use both rev and branch pytest.raises(SystemExit, """ develop.sources = { 'egg': Source( kind='hg', name='egg', branch='test', rev=rev, url='%s' % repository, path=os.path.join(src, 'egg-failed'))} CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg'])) """)