diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -897,21 +897,26 @@ :clean: whether changes in the working directory can be discarded :updatecheck: how to deal with a dirty working directory - Valid values for updatecheck are (None => linear): + Valid values for updatecheck are the UPDATECHECK_* constants + defined in the merge module. Passing `None` will result in using the + configured default. - * abort: abort if the working directory is dirty - * none: don't check (merge working directory changes into destination) - * linear: check that update is linear before merging working directory + * ABORT: abort if the working directory is dirty + * NONE: don't check (merge working directory changes into destination) + * LINEAR: check that update is linear before merging working directory changes into destination - * noconflict: check that the update does not result in file merges + * NO_CONFLICT: check that the update does not result in file merges This returns whether conflict is detected at updating or not. """ if updatecheck is None: updatecheck = ui.config('commands', 'update.check') - if updatecheck not in ('abort', 'none', 'linear', 'noconflict'): + if updatecheck not in (mergemod.UPDATECHECK_ABORT, + mergemod.UPDATECHECK_NONE, + mergemod.UPDATECHECK_LINEAR, + mergemod.UPDATECHECK_NO_CONFLICT): # If not configured, or invalid value configured - updatecheck = 'linear' + updatecheck = mergemod.UPDATECHECK_LINEAR with repo.wlock(): movemarkfrom = None warndest = False @@ -923,9 +928,9 @@ if clean: ret = _clean(repo, checkout) else: - if updatecheck == 'abort': + if updatecheck == mergemod.UPDATECHECK_ABORT: cmdutil.bailifchanged(repo, merge=False) - updatecheck = 'none' + updatecheck = mergemod.UPDATECHECK_NONE ret = _update(repo, checkout, updatecheck=updatecheck) if not ret and movemarkfrom: diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1926,6 +1926,11 @@ else: repo.dirstate.normal(f) +UPDATECHECK_ABORT = 'abort' # handled at higher layers +UPDATECHECK_NONE = 'none' +UPDATECHECK_LINEAR = 'linear' +UPDATECHECK_NO_CONFLICT = 'noconflict' + def update(repo, node, branchmerge, force, ancestor=None, mergeancestor=False, labels=None, matcher=None, mergeforce=False, updatecheck=None, wc=None): @@ -1992,8 +1997,11 @@ # and force=False pass a value for updatecheck. We may want to allow # updatecheck='abort' to better suppport some of these callers. if updatecheck is None: - updatecheck = 'linear' - assert updatecheck in ('none', 'linear', 'noconflict') + updatecheck = UPDATECHECK_LINEAR + assert updatecheck in (UPDATECHECK_NONE, + UPDATECHECK_LINEAR, + UPDATECHECK_NO_CONFLICT, + ) # If we're doing a partial update, we need to skip updating # the dirstate, so make a note of any partial-ness to the # update here. @@ -2050,7 +2058,7 @@ repo.hook('update', parent1=xp2, parent2='', error=0) return updateresult(0, 0, 0, 0) - if (updatecheck == 'linear' and + if (updatecheck == UPDATECHECK_LINEAR and pas not in ([p1], [p2])): # nonlinear dirty = wc.dirty(missing=True) if dirty: @@ -2087,7 +2095,7 @@ repo, wc, p2, pas, branchmerge, force, mergeancestor, followcopies, matcher=matcher, mergeforce=mergeforce) - if updatecheck == 'noconflict': + if updatecheck == UPDATECHECK_NO_CONFLICT: for f, (m, args, msg) in actionbyfile.iteritems(): if m not in (ACTION_GET, ACTION_KEEP, ACTION_EXEC, ACTION_REMOVE, ACTION_PATH_CONFLICT_RESOLVE):