From c98a858abe7d209b602aaad6e01dbbf8e66bdf21 Mon Sep 17 00:00:00 2001 From: "Yaakov M. Nemoy" Date: Sun, 18 Jan 2009 17:10:15 -0500 Subject: Refactor some generic stuff out of darcs into packagesource --- modules/packagesource.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'modules/packagesource.py') diff --git a/modules/packagesource.py b/modules/packagesource.py index d556ef5..b0b87b8 100644 --- a/modules/packagesource.py +++ b/modules/packagesource.py @@ -74,6 +74,34 @@ class PackageSource(Directory): ''' return join(self.dir, self.source) + @contextmanager + def src_dir(self, *args): + '''executes a code block inside a specific branch and or checkout + ''' + with src(*args): + with pwd(self.source_dir): + yield + + @contextmanager + def src(self, *args): + '''executes a code block with a particular branch or checkout + + if there are no args, this block is executed in the raw + ''' + if args: + old_src = self.cfg['source'] + self.set_cur_to(*args) + yield + if args: + self.cfg['source'] = old_src + self.set_current_src() + + def set_current_src(self): + raise NotImplementedError + + def set_cur_to(self, *args): + raise NotImplementedError + def branch(self, *args): raise NotImplementedError -- cgit