~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-11-23 07:00:38 UTC
  • mfrom: (1551.9.5 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20061123070038-57f13b951191257e
Revert broken save-commit-message code

Show diffs side-by-side

added added

removed removed

Lines of Context:
1868
1868
        else:
1869
1869
            reporter = NullCommitReporter()
1870
1870
 
1871
 
        msgfilename = self._save_commit_message(message, tree.basedir)
1872
1871
        try:
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:
1877
 
                try:
1878
 
                    os.unlink(msgfilename)
1879
 
                except IOError, e:
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)
1889
 
            else:
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'
1896
 
                    ' resolve.\n'
1897
 
                    'Commit message saved. To reuse the message,'
1898
 
                    ' do\nbzr commit --file ' + msgfilename)
1899
 
            else:
1900
 
                raise errors.BzrCommandError('Conflicts detected in working '
1901
 
                    'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
1902
 
                    ' resolve.')
 
1881
            raise errors.BzrCommandError('Conflicts detected in working '
 
1882
                'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
 
1883
                ' resolve.')
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)
1909
 
            else:
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 '
1917
 
                'disconnected.\n'
1918
 
                'Commit message saved. To reuse the message,'
1919
 
                ' do\nbzr commit --file ' + msgfilename)
1920
 
            else:
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 '
1924
 
                'disconnected.')
1925
 
 
1926
 
    def _save_commit_message(self, message, basedir):
1927
 
        # save the commit message and only unlink it if the commit was
1928
 
        # successful
1929
 
        msgfilename = None
1930
 
        try:
1931
 
            tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr-commit-',
1932
 
                                                       dir=basedir)
1933
 
        except OSError:
1934
 
            try:
1935
 
                # No access to working dir, try $TMP
1936
 
                tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr-commit-')
1937
 
            except OSError:
1938
 
                # We can't create a temp file, try to work without it
1939
 
                return None
1940
 
        try:
1941
 
            os.write(tmp_fileno, message.encode(bzrlib.user_encoding, 'replace'))
1942
 
        finally:
1943
 
            os.close(tmp_fileno)
1944
 
        return msgfilename
 
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 '
 
1891
            'disconnected.')
1945
1892
 
1946
1893
 
1947
1894
class cmd_check(Command):