This is not specific to "stg goto" -- it affects all commands that use
the new infrastructure. (But of those, only goto and coalesce were
subdirectory unsafe.)
Signed-off-by: Karl Hasselström <kha@treskal.com>
def __init__(self, directory):
self.__directory = directory
env = property(lambda self: { 'GIT_WORK_TREE': self.__directory })
def __init__(self, directory):
self.__directory = directory
env = property(lambda self: { 'GIT_WORK_TREE': self.__directory })
+ directory = property(lambda self: self.__directory)
class CheckoutException(exception.StgException):
pass
class CheckoutException(exception.StgException):
pass
self.run(['git', 'read-tree', '-u', '-m',
'--exclude-per-directory=.gitignore',
old_tree.sha1, new_tree.sha1]
self.run(['git', 'read-tree', '-u', '-m',
'--exclude-per-directory=.gitignore',
old_tree.sha1, new_tree.sha1]
+ ).cwd(self.__worktree.directory).discard_output()
except run.RunException:
raise CheckoutException('Index/workdir dirty')
def merge(self, base, ours, theirs):
except run.RunException:
raise CheckoutException('Index/workdir dirty')
def merge(self, base, ours, theirs):
env = { 'GITHEAD_%s' % base.sha1: 'ancestor',
'GITHEAD_%s' % ours.sha1: 'current',
'GITHEAD_%s' % theirs.sha1: 'patched'}
env = { 'GITHEAD_%s' % base.sha1: 'ancestor',
'GITHEAD_%s' % ours.sha1: 'current',
'GITHEAD_%s' % theirs.sha1: 'patched'}
+ ).cwd(self.__worktree.directory).discard_output()
except run.RunException, e:
raise MergeException('Index/worktree dirty')
def changed_files(self):
except run.RunException, e:
raise MergeException('Index/worktree dirty')
def changed_files(self):
if type(c) != str:
raise Exception, 'Bad command: %r' % (cmd,)
self.__good_retvals = [0]
if type(c) != str:
raise Exception, 'Bad command: %r' % (cmd,)
self.__good_retvals = [0]
+ self.__env = self.__cwd = None
self.__indata = None
self.__discard_stderr = False
def __log_start(self):
self.__indata = None
self.__discard_stderr = False
def __log_start(self):
"""Run with captured IO."""
self.__log_start()
try:
"""Run with captured IO."""
self.__log_start()
try:
- p = subprocess.Popen(self.__cmd, env = self.__env,
+ p = subprocess.Popen(self.__cmd, env = self.__env, cwd = self.__cwd,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
assert self.__indata == None
self.__log_start()
try:
assert self.__indata == None
self.__log_start()
try:
- p = subprocess.Popen(self.__cmd, env = self.__env)
+ p = subprocess.Popen(self.__cmd, env = self.__env, cwd = self.__cwd)
self.exitcode = p.wait()
except OSError, e:
raise self.exc('%s failed: %s' % (self.__cmd[0], e))
self.exitcode = p.wait()
except OSError, e:
raise self.exc('%s failed: %s' % (self.__cmd[0], e))
self.__env = dict(os.environ)
self.__env.update(env)
return self
self.__env = dict(os.environ)
self.__env.update(env)
return self
+ def cwd(self, cwd):
+ self.__cwd = cwd
+ return self
def raw_input(self, indata):
self.__indata = indata
return self
def raw_input(self, indata):
self.__indata = indata
return self
cat > expected2.txt <<EOF
bar
EOF
cat > expected2.txt <<EOF
bar
EOF
-test_expect_failure 'Goto in subdirectory (just pop)' '
+test_expect_success 'Goto in subdirectory (just pop)' '
(cd foo && stg goto p1) &&
cat foo/bar > actual.txt &&
diff -u expected1.txt actual.txt &&
(cd foo && stg goto p1) &&
cat foo/bar > actual.txt &&
diff -u expected1.txt actual.txt &&
cat > expected2.txt <<EOF
bar
EOF
cat > expected2.txt <<EOF
bar
EOF
-test_expect_failure 'Goto in subdirectory (conflicting push)' '
+test_expect_success 'Goto in subdirectory (conflicting push)' '
(cd foo && stg goto p3) ;
[ $? -eq 3 ] &&
cat foo/bar > actual.txt &&
(cd foo && stg goto p3) ;
[ $? -eq 3 ] &&
cat foo/bar > actual.txt &&