comparison mercurial/merge.py @ 18985:a59e575c6ff8

update: allow dirty update to foreground (successors) Update to "foreground" are no longer seen as cross branch update. "Foreground" are descendants or successors (or successors of descendants (or descendant of successors (etc))). This allows to update with uncommited changes that get automatically merged. This changeset is a small step forward. We want to allow dirty update to "background" (precursors) and takes obsolescence in account when finding the default update destination. But those requires deeper changes and will comes in later changesets.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 16 Apr 2013 15:33:18 +0200
parents ed676ed67a5c
children 5cc71484ee9c
comparison
equal deleted inserted replaced
18984:efef056b1ae9 18985:a59e575c6ff8
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from node import nullid, nullrev, hex, bin 8 from node import nullid, nullrev, hex, bin
9 from i18n import _ 9 from i18n import _
10 from mercurial import obsolete
10 import error, util, filemerge, copies, subrepo, worker, dicthelpers 11 import error, util, filemerge, copies, subrepo, worker, dicthelpers
11 import errno, os, shutil 12 import errno, os, shutil
12 13
13 class mergestate(object): 14 class mergestate(object):
14 '''track 3-way merge state of individual files''' 15 '''track 3-way merge state of individual files'''
695 if wc.sub(s).dirty(): 696 if wc.sub(s).dirty():
696 raise util.Abort(_("outstanding uncommitted changes in " 697 raise util.Abort(_("outstanding uncommitted changes in "
697 "subrepository '%s'") % s) 698 "subrepository '%s'") % s)
698 699
699 elif not overwrite: 700 elif not overwrite:
700 if pa == p1 or pa == p2: # linear 701 if pa not in (p1, p2): # nolinear
701 pass # all good 702 dirty = wc.dirty(missing=True)
702 elif wc.dirty(missing=True): 703 if dirty or onode is None:
703 raise util.Abort(_("crosses branches (merge branches or use" 704 # Branching is a bit strange to ensure we do the minimal
704 " --clean to discard changes)")) 705 # amount of call to obsolete.background.
705 elif onode is None: 706 foreground = obsolete.foreground(repo, [p1.node()])
706 raise util.Abort(_("crosses branches (merge branches or update" 707 # note: the <node> variable contains a random identifier
707 " --check to force update)")) 708 if repo[node].node() in foreground:
708 else: 709 pa = p1 # allow updating to successors
709 # Allow jumping branches if clean and specific rev given 710 elif dirty:
710 pa = p1 711 msg = _("crosses branches (merge branches or use"
712 " --clean to discard changes)")
713 raise util.Abort(msg)
714 else: # node is none
715 msg = _("crosses branches (merge branches or update"
716 " --check to force update)")
717 raise util.Abort(msg)
718 else:
719 # Allow jumping branches if clean and specific rev given
720 pa = p1
711 721
712 ### calculate phase 722 ### calculate phase
713 actions = calculateupdates(repo, wc, p2, pa, 723 actions = calculateupdates(repo, wc, p2, pa,
714 branchmerge, force, partial, mergeancestor) 724 branchmerge, force, partial, mergeancestor)
715 725