Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 48717:6c4b10d01af0
merge: break up two not-so-one-liner for extra readability
Differential Revision: https://phab.mercurial-scm.org/D12106
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 28 Jan 2022 14:25:05 +0100 |
parents | ec23b0ba85c2 |
children | 58a2c66fa94c |
comparison
equal
deleted
inserted
replaced
48716:ec23b0ba85c2 | 48717:6c4b10d01af0 |
---|---|
1883 # TODO: remove the default once all callers that pass branchmerge=False | 1883 # TODO: remove the default once all callers that pass branchmerge=False |
1884 # and force=False pass a value for updatecheck. We may want to allow | 1884 # and force=False pass a value for updatecheck. We may want to allow |
1885 # updatecheck='abort' to better suppport some of these callers. | 1885 # updatecheck='abort' to better suppport some of these callers. |
1886 if updatecheck is None: | 1886 if updatecheck is None: |
1887 updatecheck = UPDATECHECK_LINEAR | 1887 updatecheck = UPDATECHECK_LINEAR |
1888 if updatecheck not in ( | 1888 okay = (UPDATECHECK_NONE, UPDATECHECK_LINEAR, UPDATECHECK_NO_CONFLICT) |
1889 UPDATECHECK_NONE, | 1889 if updatecheck not in okay: |
1890 UPDATECHECK_LINEAR, | 1890 msg = r'Invalid updatecheck %r (can accept %r)' |
1891 UPDATECHECK_NO_CONFLICT, | 1891 msg %= (updatecheck, okay) |
1892 ): | 1892 raise ValueError(msg) |
1893 raise ValueError( | |
1894 r'Invalid updatecheck %r (can accept %r)' | |
1895 % ( | |
1896 updatecheck, | |
1897 ( | |
1898 UPDATECHECK_NONE, | |
1899 UPDATECHECK_LINEAR, | |
1900 UPDATECHECK_NO_CONFLICT, | |
1901 ), | |
1902 ) | |
1903 ) | |
1904 if wc is not None and wc.isinmemory(): | 1893 if wc is not None and wc.isinmemory(): |
1905 maybe_wlock = util.nullcontextmanager() | 1894 maybe_wlock = util.nullcontextmanager() |
1906 else: | 1895 else: |
1907 maybe_wlock = repo.wlock() | 1896 maybe_wlock = repo.wlock() |
1908 with maybe_wlock: | 1897 with maybe_wlock: |
1927 if not overwrite: | 1916 if not overwrite: |
1928 if len(pl) > 1: | 1917 if len(pl) > 1: |
1929 raise error.StateError(_(b"outstanding uncommitted merge")) | 1918 raise error.StateError(_(b"outstanding uncommitted merge")) |
1930 ms = wc.mergestate() | 1919 ms = wc.mergestate() |
1931 if ms.unresolvedcount(): | 1920 if ms.unresolvedcount(): |
1932 raise error.StateError( | 1921 msg = _(b"outstanding merge conflicts") |
1933 _(b"outstanding merge conflicts"), | 1922 hint = _(b"use 'hg resolve' to resolve") |
1934 hint=_(b"use 'hg resolve' to resolve"), | 1923 raise error.StateError(msg, hint=hint) |
1935 ) | |
1936 if branchmerge: | 1924 if branchmerge: |
1937 if pas == [p2]: | 1925 if pas == [p2]: |
1938 raise error.Abort( | 1926 raise error.Abort( |
1939 _( | 1927 _( |
1940 b"merging with a working directory ancestor" | 1928 b"merging with a working directory ancestor" |