Don't look in the "conflicts" file for that, since it isn't updated. Also
added a test that the check_conflicts() function works.
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
more about what to do next.""")
def check_conflicts():
more about what to do next.""")
def check_conflicts():
- if os.path.exists(os.path.join(basedir.get(), 'conflicts')):
+ if git.get_conflicts():
raise CmdException, \
'Unsolved conflicts. Please resolve them first or\n' \
' revert the changes with "status --reset"'
raise CmdException, \
'Unsolved conflicts. Please resolve them first or\n' \
' revert the changes with "status --reset"'
def resolved_all(reset = None):
conflicts = git.get_conflicts()
def resolved_all(reset = None):
conflicts = git.get_conflicts()
- if conflicts:
- for filename in conflicts:
- resolved(filename, reset)
- os.remove(os.path.join(basedir.get(), 'conflicts'))
+ for filename in conflicts:
+ resolved(filename, reset)
def push_patches(crt_series, patches, check_merged = False):
"""Push multiple patches onto the stack. This function is shared
def push_patches(crt_series, patches, check_merged = False):
"""Push multiple patches onto the stack. This function is shared
def get_conflicts():
"""Return the list of file conflicts
"""
def get_conflicts():
"""Return the list of file conflicts
"""
- conflicts_file = os.path.join(basedir.get(), 'conflicts')
- if os.path.isfile(conflicts_file):
- f = file(conflicts_file)
- names = [line.strip() for line in f.readlines()]
- f.close()
- return names
- else:
- return None
+ names = []
+ for line in GRun('ls-files', '-z', '--unmerged'
+ ).raw_output().split('\0')[:-1]:
+ stat, path = line.split('\t', 1)
+ # Look for entries in stage 2 (could equally well use 3)
+ if stat.endswith(' 2'):
+ names.append(path)
+ return names
def exclude_files():
files = [os.path.join(basedir.get(), 'info', 'exclude')]
def exclude_files():
files = [os.path.join(basedir.get(), 'info', 'exclude')]
# conflicted files
conflicts = get_conflicts()
# conflicted files
conflicts = get_conflicts()
- if not conflicts:
- conflicts = []
cache_files += [('C', filename) for filename in conflicts
if not files or filename in files]
reported_files = set(conflicts)
cache_files += [('C', filename) for filename in conflicts
if not files or filename in files]
reported_files = set(conflicts)
-test_expect_failure 'Status after conflicting push' '
+test_expect_success 'Status after conflicting push' '
! stg push &&
stg status > output.txt &&
diff -u expected.txt output.txt
! stg push &&
stg status > output.txt &&
diff -u expected.txt output.txt
cat > expected.txt <<EOF
C foo/bar
EOF
cat > expected.txt <<EOF
C foo/bar
EOF
-test_expect_failure 'Status of file' '
+test_expect_success 'Status of file' '
stg status foo/bar > output.txt &&
diff -u expected.txt output.txt
'
stg status foo/bar > output.txt &&
diff -u expected.txt output.txt
'
cat > expected.txt <<EOF
C foo/bar
EOF
cat > expected.txt <<EOF
C foo/bar
EOF
-test_expect_failure 'Status of dir' '
+test_expect_success 'Status of dir' '
stg status foo > output.txt &&
diff -u expected.txt output.txt
'
stg status foo > output.txt &&
diff -u expected.txt output.txt
'
-test_expect_success 'Status after resolving the push' '
+test_expect_failure 'Status after resolving the push' '
stg resolved -a &&
stg status > output.txt &&
diff -u expected.txt output.txt
stg resolved -a &&
stg status > output.txt &&
diff -u expected.txt output.txt
git diff --cached --stat | grep -q -e "^ test2 | *1 "
'
git diff --cached --stat | grep -q -e "^ test2 | *1 "
'
+test_expect_success \
+ 'Check that pop will fail while there are unmerged conflicts' \
+ '
+ ! stg pop
+ '
+
test_expect_success \
'Resolve the conflict' \
'
test_expect_success \
'Resolve the conflict' \
'
[ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
'
[ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
'
-test_expect_failure 'Conflicting push from subdir' '
+test_expect_success 'Conflicting push from subdir' '
stg pop p1 p2 &&
[ "$(echo $(cat x.txt))" = "x0" ] &&
[ "$(echo $(cat foo/y.txt))" = "y0" ] &&
stg pop p1 p2 &&
[ "$(echo $(cat x.txt))" = "x0" ] &&
[ "$(echo $(cat foo/y.txt))" = "y0" ] &&