1869
1869
reporter = NullCommitReporter()
1871
msgfilename = self._save_commit_message(message, tree.basedir)
1873
1872
tree.commit(message, specific_files=selected_list,
1874
1873
allow_pointless=unchanged, strict=strict, local=local,
1875
1874
reporter=reporter)
1876
if msgfilename is not None:
1878
os.unlink(msgfilename)
1880
warning("failed to unlink %s: %s; ignored", msgfilename, e)
1881
1875
except PointlessCommit:
1882
1876
# FIXME: This should really happen before the file is read in;
1883
1877
# perhaps prepare the commit; get the message; then actually commit
1884
if msgfilename is not None:
1885
raise errors.BzrCommandError("no changes to commit."
1886
" use --unchanged to commit anyhow\n"
1887
"Commit message saved. To reuse the message,"
1888
" do\nbzr commit --file " + msgfilename)
1890
raise errors.BzrCommandError("no changes to commit."
1891
" use --unchanged to commit anyhow")
1878
raise errors.BzrCommandError("no changes to commit."
1879
" use --unchanged to commit anyhow")
1892
1880
except ConflictsInTree:
1893
if msgfilename is not None:
1894
raise errors.BzrCommandError('Conflicts detected in working '
1895
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
1897
'Commit message saved. To reuse the message,'
1898
' do\nbzr commit --file ' + msgfilename)
1900
raise errors.BzrCommandError('Conflicts detected in working '
1901
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
1881
raise errors.BzrCommandError('Conflicts detected in working '
1882
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
1903
1884
except StrictCommitFailed:
1904
if msgfilename is not None:
1905
raise errors.BzrCommandError("Commit refused because there are"
1906
" unknown files in the working tree.\n"
1907
"Commit message saved. To reuse the message,"
1908
" do\nbzr commit --file " + msgfilename)
1910
raise errors.BzrCommandError("Commit refused because there are"
1911
" unknown files in the working tree.")
1885
raise errors.BzrCommandError("Commit refused because there are"
1886
" unknown files in the working tree.")
1912
1887
except errors.BoundBranchOutOfDate, e:
1913
if msgfilename is not None:
1914
raise errors.BzrCommandError(str(e) + "\n"
1915
'To commit to master branch, run update and then commit.\n'
1916
'You can also pass --local to commit to continue working '
1918
'Commit message saved. To reuse the message,'
1919
' do\nbzr commit --file ' + msgfilename)
1921
raise errors.BzrCommandError(str(e) + "\n"
1922
'To commit to master branch, run update and then commit.\n'
1923
'You can also pass --local to commit to continue working '
1926
def _save_commit_message(self, message, basedir):
1927
# save the commit message and only unlink it if the commit was
1931
tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr-commit-',
1935
# No access to working dir, try $TMP
1936
tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr-commit-')
1938
# We can't create a temp file, try to work without it
1941
os.write(tmp_fileno, message.encode(bzrlib.user_encoding, 'replace'))
1943
os.close(tmp_fileno)
1888
raise errors.BzrCommandError(str(e) + "\n"
1889
'To commit to master branch, run update and then commit.\n'
1890
'You can also pass --local to commit to continue working '
1947
1894
class cmd_check(Command):