Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 46418:dc00324e80f4
errors: use StateError more in merge module
Differential Revision: https://phab.mercurial-scm.org/D9912
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 29 Jan 2021 15:56:08 -0800 |
parents | 57370e7deb7b |
children | e2f7b2695ba1 |
comparison
equal
deleted
inserted
replaced
46417:768056549737 | 46418:dc00324e80f4 |
---|---|
231 else: | 231 else: |
232 warn(_(b"%s: untracked directory conflicts with file\n") % f) | 232 warn(_(b"%s: untracked directory conflicts with file\n") % f) |
233 else: | 233 else: |
234 warn(_(b"%s: untracked file differs\n") % f) | 234 warn(_(b"%s: untracked file differs\n") % f) |
235 if abortconflicts: | 235 if abortconflicts: |
236 raise error.Abort( | 236 raise error.StateError( |
237 _( | 237 _( |
238 b"untracked files in working directory " | 238 b"untracked files in working directory " |
239 b"differ from files in requested revision" | 239 b"differ from files in requested revision" |
240 ) | 240 ) |
241 ) | 241 ) |
339 # check case-folding collision in provisional merged manifest | 339 # check case-folding collision in provisional merged manifest |
340 foldmap = {} | 340 foldmap = {} |
341 for f in pmmf: | 341 for f in pmmf: |
342 fold = util.normcase(f) | 342 fold = util.normcase(f) |
343 if fold in foldmap: | 343 if fold in foldmap: |
344 raise error.Abort( | 344 raise error.StateError( |
345 _(b"case-folding collision between %s and %s") | 345 _(b"case-folding collision between %s and %s") |
346 % (f, foldmap[fold]) | 346 % (f, foldmap[fold]) |
347 ) | 347 ) |
348 foldmap[fold] = f | 348 foldmap[fold] = f |
349 | 349 |
350 # check case-folding of directories | 350 # check case-folding of directories |
351 foldprefix = unfoldprefix = lastfull = b'' | 351 foldprefix = unfoldprefix = lastfull = b'' |
352 for fold, f in sorted(foldmap.items()): | 352 for fold, f in sorted(foldmap.items()): |
353 if fold.startswith(foldprefix) and not f.startswith(unfoldprefix): | 353 if fold.startswith(foldprefix) and not f.startswith(unfoldprefix): |
354 # the folded prefix matches but actual casing is different | 354 # the folded prefix matches but actual casing is different |
355 raise error.Abort( | 355 raise error.StateError( |
356 _(b"case-folding collision between %s and directory of %s") | 356 _(b"case-folding collision between %s and directory of %s") |
357 % (lastfull, f) | 357 % (lastfull, f) |
358 ) | 358 ) |
359 foldprefix = fold + b'/' | 359 foldprefix = fold + b'/' |
360 unfoldprefix = f + b'/' | 360 unfoldprefix = f + b'/' |
502 break | 502 break |
503 | 503 |
504 if invalidconflicts: | 504 if invalidconflicts: |
505 for p in invalidconflicts: | 505 for p in invalidconflicts: |
506 repo.ui.warn(_(b"%s: is both a file and a directory\n") % p) | 506 repo.ui.warn(_(b"%s: is both a file and a directory\n") % p) |
507 raise error.Abort(_(b"destination manifest contains path conflicts")) | 507 raise error.StateError( |
508 _(b"destination manifest contains path conflicts") | |
509 ) | |
508 | 510 |
509 | 511 |
510 def _filternarrowactions(narrowmatch, branchmerge, mresult): | 512 def _filternarrowactions(narrowmatch, branchmerge, mresult): |
511 """ | 513 """ |
512 Filters out actions that can ignored because the repo is narrowed. | 514 Filters out actions that can ignored because the repo is narrowed. |
1916 | 1918 |
1917 overwrite = force and not branchmerge | 1919 overwrite = force and not branchmerge |
1918 ### check phase | 1920 ### check phase |
1919 if not overwrite: | 1921 if not overwrite: |
1920 if len(pl) > 1: | 1922 if len(pl) > 1: |
1921 raise error.Abort(_(b"outstanding uncommitted merge")) | 1923 raise error.StateError(_(b"outstanding uncommitted merge")) |
1922 ms = wc.mergestate() | 1924 ms = wc.mergestate() |
1923 if ms.unresolvedcount(): | 1925 if ms.unresolvedcount(): |
1924 raise error.Abort( | 1926 raise error.StateError( |
1925 _(b"outstanding merge conflicts"), | 1927 _(b"outstanding merge conflicts"), |
1926 hint=_(b"use 'hg resolve' to resolve"), | 1928 hint=_(b"use 'hg resolve' to resolve"), |
1927 ) | 1929 ) |
1928 if branchmerge: | 1930 if branchmerge: |
1929 if pas == [p2]: | 1931 if pas == [p2]: |
2005 | 2007 |
2006 if updatecheck == UPDATECHECK_NO_CONFLICT: | 2008 if updatecheck == UPDATECHECK_NO_CONFLICT: |
2007 if mresult.hasconflicts(): | 2009 if mresult.hasconflicts(): |
2008 msg = _(b"conflicting changes") | 2010 msg = _(b"conflicting changes") |
2009 hint = _(b"commit or update --clean to discard changes") | 2011 hint = _(b"commit or update --clean to discard changes") |
2010 raise error.Abort(msg, hint=hint) | 2012 raise error.StateError(msg, hint=hint) |
2011 | 2013 |
2012 # Prompt and create actions. Most of this is in the resolve phase | 2014 # Prompt and create actions. Most of this is in the resolve phase |
2013 # already, but we can't handle .hgsubstate in filemerge or | 2015 # already, but we can't handle .hgsubstate in filemerge or |
2014 # subrepoutil.submerge yet so we have to keep prompting for it. | 2016 # subrepoutil.submerge yet so we have to keep prompting for it. |
2015 vals = mresult.getfile(b'.hgsubstate') | 2017 vals = mresult.getfile(b'.hgsubstate') |