1801
1802
reporter = ReportCommitToLog()
1803
1804
reporter = NullCommitReporter()
1806
# save the commit message and only unlink it if the commit was
1809
tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr-commit-',
1811
os.close(tmp_fileno)
1814
# No access to working dir, try $TMP
1815
tmp_fileno, msgfilename= tempfile.mkstemp(prefix='bzr-commit-')
1816
os.close(tmp_fileno)
1818
# We can't create a temp file, try to work without it
1820
if msgfilename is not None:
1821
msgfile = open(msgfilename, "wt")
1823
msgfile.write(message.encode(bzrlib.user_encoding, 'replace'))
1806
1828
tree.commit(message, specific_files=selected_list,
1807
1829
allow_pointless=unchanged, strict=strict, local=local,
1808
1830
reporter=reporter)
1831
if msgfilename is not None:
1833
os.unlink(msgfilename)
1835
warning("failed to unlink %s: %s; ignored", msgfilename, e)
1809
1836
except PointlessCommit:
1810
1837
# FIXME: This should really happen before the file is read in;
1811
1838
# perhaps prepare the commit; get the message; then actually commit
1812
raise errors.BzrCommandError("no changes to commit."
1813
" use --unchanged to commit anyhow")
1839
if msgfilename is not None:
1840
raise errors.BzrCommandError("no changes to commit."
1841
" use --unchanged to commit anyhow\n"
1842
"Commit message saved. To reuse the message,"
1843
" do\nbzr commit --file " + msgfilename)
1845
raise errors.BzrCommandError("no changes to commit."
1846
" use --unchanged to commit anyhow")
1814
1847
except ConflictsInTree:
1815
raise errors.BzrCommandError("Conflicts detected in working tree. "
1816
'Use "bzr conflicts" to list, "bzr resolve FILE" to resolve.')
1848
if msgfilename is not None:
1849
raise errors.BzrCommandError('Conflicts detected in working '
1850
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
1852
'Commit message saved. To reuse the message,'
1853
' do\nbzr commit --file ' + msgfilename)
1855
raise errors.BzrCommandError('Conflicts detected in working '
1856
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
1817
1858
except StrictCommitFailed:
1818
raise errors.BzrCommandError("Commit refused because there are unknown "
1819
"files in the working tree.")
1859
if msgfilename is not None:
1860
raise errors.BzrCommandError("Commit refused because there are"
1861
" unknown files in the working tree.\n"
1862
"Commit message saved. To reuse the message,"
1863
" do\nbzr commit --file " + msgfilename)
1865
raise errors.BzrCommandError("Commit refused because there are"
1866
" unknown files in the working tree.")
1820
1867
except errors.BoundBranchOutOfDate, e:
1821
raise errors.BzrCommandError(str(e) + "\n"
1868
if msgfilename is not None:
1869
raise errors.BzrCommandError(str(e) + "\n"
1870
'To commit to master branch, run update and then commit.\n'
1871
'You can also pass --local to commit to continue working '
1873
'Commit message saved. To reuse the message,'
1874
' do\nbzr commit --file ' + msgfilename)
1876
raise errors.BzrCommandError(str(e) + "\n"
1822
1877
'To commit to master branch, run update and then commit.\n'
1823
1878
'You can also pass --local to commit to continue working '
1824
1879
'disconnected.')