Esempio n. 1
0
 def test_git(self):
     create_watcher = get_fallback_create_watcher()
     repo = guess(path=GIT_REPO, create_watcher=create_watcher)
     self.assertNotEqual(repo, None)
     self.assertEqual(repo.branch(), 'master')
     self.assertEqual(repo.status(), None)
     self.assertEqual(repo.status('file'), None)
     with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
         f.write('abc')
         f.flush()
         self.assertEqual(repo.status(), '  U')
         self.assertEqual(repo.status('file'), '??')
         call(['git', 'add', '.'], cwd=GIT_REPO)
         self.assertEqual(repo.status(), ' I ')
         self.assertEqual(repo.status('file'), 'A ')
         f.write('def')
         f.flush()
         self.assertEqual(repo.status(), 'DI ')
         self.assertEqual(repo.status('file'), 'AM')
     os.remove(os.path.join(GIT_REPO, 'file'))
     # Test changing branch
     self.assertEqual(repo.branch(), 'master')
     try:
         call(['git', 'branch', 'branch1'], cwd=GIT_REPO)
         call(['git', 'checkout', '-q', 'branch1'], cwd=GIT_REPO)
         self.do_branch_rename_test(repo, 'branch1')
         call(['git', 'branch', 'branch2'], cwd=GIT_REPO)
         call(['git', 'checkout', '-q', 'branch2'], cwd=GIT_REPO)
         self.do_branch_rename_test(repo, 'branch2')
         call(['git', 'checkout', '-q', '--detach', 'branch1'],
              cwd=GIT_REPO)
         self.do_branch_rename_test(repo,
                                    lambda b: re.match(r'^[a-f0-9]+$', b))
     finally:
         call(['git', 'checkout', '-q', 'master'], cwd=GIT_REPO)
Esempio n. 2
0
	def test_git(self):
		create_watcher = get_fallback_create_watcher()
		repo = guess(path=GIT_REPO, create_watcher=create_watcher)
		self.assertNotEqual(repo, None)
		self.assertEqual(repo.branch(), 'master')
		self.assertEqual(repo.status(), None)
		self.assertEqual(repo.status('file'), None)
		with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
			f.write('abc')
			f.flush()
			self.assertEqual(repo.status(), '  U')
			self.assertEqual(repo.status('file'), '??')
			call(['git', 'add', '.'], cwd=GIT_REPO)
			self.assertEqual(repo.status(), ' I ')
			self.assertEqual(repo.status('file'), 'A ')
			f.write('def')
			f.flush()
			self.assertEqual(repo.status(), 'DI ')
			self.assertEqual(repo.status('file'), 'AM')
		os.remove(os.path.join(GIT_REPO, 'file'))
		# Test changing branch
		self.assertEqual(repo.branch(), 'master')
		try:
			call(['git', 'branch', 'branch1'], cwd=GIT_REPO)
			call(['git', 'checkout', '-q', 'branch1'], cwd=GIT_REPO)
			self.do_branch_rename_test(repo, 'branch1')
			call(['git', 'branch', 'branch2'], cwd=GIT_REPO)
			call(['git', 'checkout', '-q', 'branch2'], cwd=GIT_REPO)
			self.do_branch_rename_test(repo, 'branch2')
			call(['git', 'checkout', '-q', '--detach', 'branch1'], cwd=GIT_REPO)
			self.do_branch_rename_test(repo, lambda b: re.match(r'^[a-f0-9]+$', b))
		finally:
			call(['git', 'checkout', '-q', 'master'], cwd=GIT_REPO)
Esempio n. 3
0
	def test_file_vcs_status(self):
		pl = Pl()
		create_watcher = get_fallback_create_watcher()
		file_vcs_status = partial(vim.file_vcs_status, pl=pl, create_watcher=create_watcher)
		with vim_module._with('buffer', '/foo') as segment_info:
			with replace_attr(vim, 'guess', get_dummy_guess(status=lambda file: 'M')):
				self.assertEqual(file_vcs_status(segment_info=segment_info),
						[{'highlight_group': ['file_vcs_status_M', 'file_vcs_status'], 'contents': 'M'}])
			with replace_attr(vim, 'guess', get_dummy_guess(status=lambda file: None)):
				self.assertEqual(file_vcs_status(segment_info=segment_info), None)
		with vim_module._with('buffer', '/bar') as segment_info:
			with vim_module._with('bufoptions', buftype='nofile'):
				with replace_attr(vim, 'guess', get_dummy_guess(status=lambda file: 'M')):
					self.assertEqual(file_vcs_status(segment_info=segment_info), None)
Esempio n. 4
0
		def test_mercurial(self):
			create_watcher = get_fallback_create_watcher()
			repo = guess(path=HG_REPO, create_watcher=create_watcher)
			self.assertNotEqual(repo, None)
			self.assertEqual(repo.branch(), 'default')
			self.assertEqual(repo.status(), None)
			with open(os.path.join(HG_REPO, 'file'), 'w') as f:
				f.write('abc')
				f.flush()
				self.assertEqual(repo.status(), ' U')
				self.assertEqual(repo.status('file'), 'U')
				call(['hg', 'add', '.'], cwd=HG_REPO, stdout=PIPE)
				self.assertEqual(repo.status(), 'D ')
				self.assertEqual(repo.status('file'), 'A')
			os.remove(os.path.join(HG_REPO, 'file'))
Esempio n. 5
0
	def test_git_sym(self):
		create_watcher = get_fallback_create_watcher()
		dotgit = os.path.join(GIT_REPO, '.git')
		spacegit = os.path.join(GIT_REPO, ' .git ')
		os.rename(dotgit, spacegit)
		try:
			with open(dotgit, 'w') as F:
				F.write('gitdir:  .git \n')
			gitdir = git_directory(GIT_REPO)
			self.assertTrue(os.path.isdir(gitdir))
			self.assertEqual(gitdir, os.path.abspath(spacegit))
			repo = guess(path=GIT_REPO, create_watcher=create_watcher)
			self.assertEqual(repo.branch(), 'master')
		finally:
			os.remove(dotgit)
			os.rename(spacegit, dotgit)
Esempio n. 6
0
 def test_git_sym(self):
     create_watcher = get_fallback_create_watcher()
     dotgit = os.path.join(GIT_REPO, '.git')
     spacegit = os.path.join(GIT_REPO, ' .git ')
     os.rename(dotgit, spacegit)
     try:
         with open(dotgit, 'w') as F:
             F.write('gitdir:  .git \n')
         gitdir = git_directory(GIT_REPO)
         self.assertTrue(os.path.isdir(gitdir))
         self.assertEqual(gitdir, os.path.abspath(spacegit))
         repo = guess(path=GIT_REPO, create_watcher=create_watcher)
         self.assertEqual(repo.branch(), 'master')
     finally:
         os.remove(dotgit)
         os.rename(spacegit, dotgit)
Esempio n. 7
0
 def test_mercurial(self):
     if not use_mercurial:
         raise SkipTest('Mercurial is not available')
     create_watcher = get_fallback_create_watcher()
     repo = guess(path=HG_REPO, create_watcher=create_watcher)
     self.assertNotEqual(repo, None)
     self.assertEqual(repo.branch(), 'default')
     self.assertEqual(repo.status(), None)
     with open(os.path.join(HG_REPO, 'file'), 'w') as f:
         f.write('abc')
         f.flush()
         self.assertEqual(repo.status(), ' U')
         self.assertEqual(repo.status('file'), 'U')
         call(['hg', 'add', '.'], cwd=HG_REPO, stdout=PIPE)
         self.assertEqual(repo.status(), 'D ')
         self.assertEqual(repo.status('file'), 'A')
     os.remove(os.path.join(HG_REPO, 'file'))
Esempio n. 8
0
	def test_branch(self):
		pl = Pl()
		create_watcher = get_fallback_create_watcher()
		branch = partial(vim.branch, pl=pl, create_watcher=create_watcher)
		with vim_module._with('buffer', '/foo') as segment_info:
			with replace_attr(vim, 'guess', get_dummy_guess(status=lambda: None)):
				with replace_attr(vim, 'tree_status', lambda repo, pl: None):
					self.assertEqual(branch(segment_info=segment_info, status_colors=False),
							[{'divider_highlight_group': 'branch:divider', 'highlight_group': ['branch'], 'contents': 'foo'}])
					self.assertEqual(branch(segment_info=segment_info, status_colors=True),
							[{'divider_highlight_group': 'branch:divider', 'highlight_group': ['branch_clean', 'branch'], 'contents': 'foo'}])
			with replace_attr(vim, 'guess', get_dummy_guess(status=lambda: 'DU')):
				with replace_attr(vim, 'tree_status', lambda repo, pl: 'DU'):
					self.assertEqual(branch(segment_info=segment_info, status_colors=False),
							[{'divider_highlight_group': 'branch:divider', 'highlight_group': ['branch'], 'contents': 'foo'}])
					self.assertEqual(branch(segment_info=segment_info, status_colors=True),
							[{'divider_highlight_group': 'branch:divider', 'highlight_group': ['branch_dirty', 'branch'], 'contents': 'foo'}])
Esempio n. 9
0
	def test_branch(self):
		pl = Pl()
		create_watcher = get_fallback_create_watcher()
		segment_info = {'getcwd': os.getcwd}
		branch = partial(common.branch, pl=pl, create_watcher=create_watcher)
		with replace_attr(common, 'guess', get_dummy_guess(status=lambda: None, directory='/tmp/tests')):
			with replace_attr(common, 'tree_status', lambda repo, pl: None):
				self.assertEqual(branch(segment_info=segment_info, status_colors=False),
						[{'highlight_group': ['branch'], 'contents': 'tests'}])
				self.assertEqual(branch(segment_info=segment_info, status_colors=True),
						[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
		with replace_attr(common, 'guess', get_dummy_guess(status=lambda: 'D  ', directory='/tmp/tests')):
			with replace_attr(common, 'tree_status', lambda repo, pl: 'D '):
				self.assertEqual(branch(segment_info=segment_info, status_colors=False),
						[{'highlight_group': ['branch'], 'contents': 'tests'}])
				self.assertEqual(branch(segment_info=segment_info, status_colors=True),
						[{'contents': 'tests', 'highlight_group': ['branch_dirty', 'branch']}])
				self.assertEqual(branch(segment_info=segment_info, status_colors=False),
						[{'highlight_group': ['branch'], 'contents': 'tests'}])
		with replace_attr(common, 'guess', lambda path, create_watcher: None):
			self.assertEqual(branch(segment_info=segment_info, status_colors=False), None)
Esempio n. 10
0
	def test_bzr(self):
		if not use_bzr:
			raise SkipTest('Bazaar is not available')
		create_watcher = get_fallback_create_watcher()
		repo = guess(path=BZR_REPO, create_watcher=create_watcher)
		self.assertNotEqual(repo, None, 'No bzr repo found. Do you have bzr installed?')
		self.assertEqual(repo.branch(), 'test_powerline')
		self.assertEqual(repo.status(), None)
		with open(os.path.join(BZR_REPO, 'file'), 'w') as f:
			f.write('abc')
		self.assertEqual(repo.status(), ' U')
		self.assertEqual(repo.status('file'), '? ')
		call(['bzr', 'add', '-q', '.'], cwd=BZR_REPO, stdout=PIPE)
		self.assertEqual(repo.status(), 'D ')
		self.assertEqual(repo.status('file'), '+N')
		call(['bzr', 'commit', '-q', '-m', 'initial commit'], cwd=BZR_REPO)
		self.assertEqual(repo.status(), None)
		with open(os.path.join(BZR_REPO, 'file'), 'w') as f:
			f.write('def')
		self.assertEqual(repo.status(), 'D ')
		self.assertEqual(repo.status('file'), ' M')
		self.assertEqual(repo.status('notexist'), None)
		with open(os.path.join(BZR_REPO, 'ignored'), 'w') as f:
			f.write('abc')
		self.assertEqual(repo.status('ignored'), '? ')
		# Test changing the .bzrignore file should update status
		with open(os.path.join(BZR_REPO, '.bzrignore'), 'w') as f:
			f.write('ignored')
		self.assertEqual(repo.status('ignored'), None)
		# Test changing the dirstate file should invalidate the cache for
		# all files in the repo
		with open(os.path.join(BZR_REPO, 'file2'), 'w') as f:
			f.write('abc')
		call(['bzr', 'add', 'file2'], cwd=BZR_REPO, stdout=PIPE)
		call(['bzr', 'commit', '-q', '-m', 'file2 added'], cwd=BZR_REPO)
		with open(os.path.join(BZR_REPO, 'file'), 'a') as f:
			f.write('hello')
		with open(os.path.join(BZR_REPO, 'file2'), 'a') as f:
			f.write('hello')
		self.assertEqual(repo.status('file'), ' M')
		self.assertEqual(repo.status('file2'), ' M')
		call(['bzr', 'commit', '-q', '-m', 'multi'], cwd=BZR_REPO)
		self.assertEqual(repo.status('file'), None)
		self.assertEqual(repo.status('file2'), None)

		# Test changing branch
		call(['bzr', 'nick', 'branch1'], cwd=BZR_REPO, stdout=PIPE, stderr=PIPE)
		self.do_branch_rename_test(repo, 'branch1')

		# Test branch name/status changes when swapping repos
		for x in ('b1', 'b2'):
			d = os.path.join(BZR_REPO, x)
			os.mkdir(d)
			call(['bzr', 'init', '-q'], cwd=d)
			call(['bzr', 'nick', '-q', x], cwd=d)
			repo = guess(path=d, create_watcher=create_watcher)
			self.assertEqual(repo.branch(), x)
			self.assertFalse(repo.status())
			if x == 'b1':
				open(os.path.join(d, 'dirty'), 'w').close()
				self.assertTrue(repo.status())
		os.rename(os.path.join(BZR_REPO, 'b1'), os.path.join(BZR_REPO, 'b'))
		os.rename(os.path.join(BZR_REPO, 'b2'), os.path.join(BZR_REPO, 'b1'))
		os.rename(os.path.join(BZR_REPO, 'b'), os.path.join(BZR_REPO, 'b2'))
		for x, y in (('b1', 'b2'), ('b2', 'b1')):
			d = os.path.join(BZR_REPO, x)
			repo = guess(path=d, create_watcher=create_watcher)
			self.do_branch_rename_test(repo, y)
			if x == 'b1':
				self.assertFalse(repo.status())
			else:
				self.assertTrue(repo.status())
Esempio n. 11
0
    def test_bzr(self):
        if not use_bzr:
            raise SkipTest('Bazaar is not available')
        create_watcher = get_fallback_create_watcher()
        repo = guess(path=BZR_REPO, create_watcher=create_watcher)
        self.assertNotEqual(repo, None,
                            'No bzr repo found. Do you have bzr installed?')
        self.assertEqual(repo.branch(), 'test_powerline')
        self.assertEqual(repo.status(), None)
        with open(os.path.join(BZR_REPO, 'file'), 'w') as f:
            f.write('abc')
        self.assertEqual(repo.status(), ' U')
        self.assertEqual(repo.status('file'), '? ')
        call(['bzr', 'add', '-q', '.'], cwd=BZR_REPO, stdout=PIPE)
        self.assertEqual(repo.status(), 'D ')
        self.assertEqual(repo.status('file'), '+N')
        call(['bzr', 'commit', '-q', '-m', 'initial commit'], cwd=BZR_REPO)
        self.assertEqual(repo.status(), None)
        with open(os.path.join(BZR_REPO, 'file'), 'w') as f:
            f.write('def')
        self.assertEqual(repo.status(), 'D ')
        self.assertEqual(repo.status('file'), ' M')
        self.assertEqual(repo.status('notexist'), None)
        with open(os.path.join(BZR_REPO, 'ignored'), 'w') as f:
            f.write('abc')
        self.assertEqual(repo.status('ignored'), '? ')
        # Test changing the .bzrignore file should update status
        with open(os.path.join(BZR_REPO, '.bzrignore'), 'w') as f:
            f.write('ignored')
        self.assertEqual(repo.status('ignored'), None)
        # Test changing the dirstate file should invalidate the cache for
        # all files in the repo
        with open(os.path.join(BZR_REPO, 'file2'), 'w') as f:
            f.write('abc')
        call(['bzr', 'add', 'file2'], cwd=BZR_REPO, stdout=PIPE)
        call(['bzr', 'commit', '-q', '-m', 'file2 added'], cwd=BZR_REPO)
        with open(os.path.join(BZR_REPO, 'file'), 'a') as f:
            f.write('hello')
        with open(os.path.join(BZR_REPO, 'file2'), 'a') as f:
            f.write('hello')
        self.assertEqual(repo.status('file'), ' M')
        self.assertEqual(repo.status('file2'), ' M')
        call(['bzr', 'commit', '-q', '-m', 'multi'], cwd=BZR_REPO)
        self.assertEqual(repo.status('file'), None)
        self.assertEqual(repo.status('file2'), None)

        # Test changing branch
        call(['bzr', 'nick', 'branch1'],
             cwd=BZR_REPO,
             stdout=PIPE,
             stderr=PIPE)
        self.do_branch_rename_test(repo, 'branch1')

        # Test branch name/status changes when swapping repos
        for x in ('b1', 'b2'):
            d = os.path.join(BZR_REPO, x)
            os.mkdir(d)
            call(['bzr', 'init', '-q'], cwd=d)
            call(['bzr', 'nick', '-q', x], cwd=d)
            repo = guess(path=d, create_watcher=create_watcher)
            self.assertEqual(repo.branch(), x)
            self.assertFalse(repo.status())
            if x == 'b1':
                open(os.path.join(d, 'dirty'), 'w').close()
                self.assertTrue(repo.status())
        os.rename(os.path.join(BZR_REPO, 'b1'), os.path.join(BZR_REPO, 'b'))
        os.rename(os.path.join(BZR_REPO, 'b2'), os.path.join(BZR_REPO, 'b1'))
        os.rename(os.path.join(BZR_REPO, 'b'), os.path.join(BZR_REPO, 'b2'))
        for x, y in (('b1', 'b2'), ('b2', 'b1')):
            d = os.path.join(BZR_REPO, x)
            repo = guess(path=d, create_watcher=create_watcher)
            self.do_branch_rename_test(repo, y)
            if x == 'b1':
                self.assertFalse(repo.status())
            else:
                self.assertTrue(repo.status())
Esempio n. 12
0
 def test_mercurial(self):
     if not use_mercurial:
         raise SkipTest('Mercurial is not available')
     create_watcher = get_fallback_create_watcher()
     repo = guess(path=HG_REPO, create_watcher=create_watcher)
     self.assertNotEqual(repo, None)
     self.assertEqual(repo.branch, 'default')
     self.assertEqual(repo.bookmark, None)
     self.assertEqual(repo.short, '-1')
     self.assertEqual(repo.summary, '')
     self.assertEqual(repo.name, 'tip')
     self.assertEqual(repo.status(), None)
     with open(os.path.join(HG_REPO, 'file'), 'w') as f:
         f.write('abc')
         f.flush()
         self.assertEqual(repo.status(), ' U')
         self.assertEqual(repo.status('file'), 'U')
         call(['hg', 'add', '.'], cwd=HG_REPO, stdout=PIPE)
         self.assertEqual(repo.status(), 'D ')
         self.assertEqual(repo.status('file'), 'A')
     call(['hg', 'commit', '-m', 'Abc\ndef'], cwd=HG_REPO, stdout=PIPE)
     self.assertEqual(repo.branch, 'default')
     self.assertEqual(repo.bookmark, None)
     self.assertEqual(repo.short, '0')
     self.assertEqual(repo.summary, 'Abc')
     self.assertEqual(repo.name, 'tip')
     call(['hg', 'bookmark', 'bm'], cwd=HG_REPO, stdout=PIPE)
     self.assertEqual(repo.branch, 'default')
     self.assertEqual(repo.bookmark, 'bm')
     self.assertEqual(repo.short, '0')
     self.assertEqual(repo.summary, 'Abc')
     self.assertEqual(repo.name, 'bm')
     call(['hg', 'rm', 'file'], cwd=HG_REPO, stdout=PIPE)
     call(['hg', 'commit', '-m', 'Ghi'], cwd=HG_REPO, stdout=PIPE)
     self.assertEqual(repo.branch, 'default')
     self.assertEqual(repo.bookmark, 'bm')
     self.assertEqual(repo.short, '1')
     self.assertEqual(repo.summary, 'Ghi')
     self.assertEqual(repo.name, 'bm')
     call(['hg', 'bookmark', '-i'], cwd=HG_REPO, stdout=PIPE)
     self.assertEqual(repo.branch, 'default')
     self.assertEqual(repo.bookmark, None)
     self.assertEqual(repo.short, '1')
     self.assertEqual(repo.summary, 'Ghi')
     self.assertEqual(repo.name, 'tip')
     call(['hg', 'update', '-r', '-2'], cwd=HG_REPO, stdout=PIPE)
     call(['hg', 'branch', 'b2'], cwd=HG_REPO, stdout=PIPE)
     call(['hg', 'rm', 'file'], cwd=HG_REPO, stdout=PIPE)
     call(['hg', 'commit', '-m', 'Jkl'], cwd=HG_REPO, stdout=PIPE)
     self.do_branch_rename_test(repo, 'b2')
     self.assertEqual(repo.bookmark, None)
     self.assertEqual(repo.short, '2')
     self.assertEqual(repo.summary, 'Jkl')
     self.assertEqual(repo.name, 'tip')
     call(['hg', 'update', 'default'], cwd=HG_REPO, stdout=PIPE)
     self.do_branch_rename_test(repo, 'default')
     self.assertEqual(repo.bookmark, None)
     self.assertEqual(repo.short, '1')
     self.assertEqual(repo.summary, 'Ghi')
     self.assertEqual(repo.name, 'default')
     call(['hg', 'update', '0'], cwd=HG_REPO, stdout=PIPE)
     self.assertEqual(repo.branch, 'default')
     self.assertEqual(repo.bookmark, None)
     self.assertEqual(repo.short, '0')
     self.assertEqual(repo.summary, 'Abc')
     self.assertEqual(repo.name, '0')
Esempio n. 13
0
    def test_git(self):
        create_watcher = get_fallback_create_watcher()
        repo = guess(path=GIT_REPO, create_watcher=create_watcher)
        self.assertNotEqual(repo, None)
        self.assertEqual(repo.branch, 'master')
        self.assertEqual(repo.status(), None)
        self.assertEqual(repo.status('file'), None)
        with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
            f.write('abc')
            f.flush()
            self.assertEqual(repo.status(), '  U')
            self.assertEqual(repo.status('file'), '??')
            call(['git', 'add', '.'], cwd=GIT_REPO)
            self.assertEqual(repo.status(), ' I ')
            self.assertEqual(repo.status('file'), 'A ')
            f.write('def')
            f.flush()
            self.assertEqual(repo.status(), 'DI ')
            self.assertEqual(repo.status('file'), 'AM')
        os.remove(os.path.join(GIT_REPO, 'file'))
        # Test changing branch
        self.assertEqual(repo.branch, 'master')
        self.assertEqual(repo.bookmark, 'master')
        self.assertTrue(git_abbr_re.match(repo.short))
        self.assertEqual(repo.summary, 'Initial commit')
        self.assertEqual(repo.name, 'master')
        try:
            call(['git', 'branch', 'branch1'], cwd=GIT_REPO)
            call(['git', 'checkout', '-q', 'branch1'], cwd=GIT_REPO)
            self.do_branch_rename_test(repo, 'branch1')
            call(['git', 'branch', 'branch2'], cwd=GIT_REPO)
            call(['git', 'checkout', '-q', 'branch2'], cwd=GIT_REPO)
            self.do_branch_rename_test(repo, 'branch2')
            call(['git', 'checkout', '-q', '--detach', 'branch1'],
                 cwd=GIT_REPO)
            self.do_branch_rename_test(repo, git_abbr_re.match)
        finally:
            call(['git', 'checkout', '-q', 'master'], cwd=GIT_REPO)
        # Test stashing
        self.assertEqual(repo.stash(), 0)

        def stash_save():
            with open(os.path.join(GIT_REPO, 'file'), 'w') as f:
                f.write('abc')
            return call(['git', 'stash', '-u'], cwd=GIT_REPO, stdout=PIPE)

        def stash_drop():
            return call(['git', 'stash', 'drop'], cwd=GIT_REPO, stdout=PIPE)

        def stash_list():
            return call(['git', 'stash', 'list'], cwd=GIT_REPO, stdout=PIPE)

        try:
            stash_save()
            self.assertEqual(repo.stash(), 1)
            stash_save()
            self.assertEqual(repo.stash(), 2)
            stash_drop()
            self.assertEqual(repo.stash(), 1)
            stash_drop()
            self.assertEqual(repo.stash(), 0)
        finally:
            while stash_list():
                stash_drop()