1924 repo.dirstate.add(f) |
1924 repo.dirstate.add(f) |
1925 repo.dirstate.copy(f0, f) |
1925 repo.dirstate.copy(f0, f) |
1926 else: |
1926 else: |
1927 repo.dirstate.normal(f) |
1927 repo.dirstate.normal(f) |
1928 |
1928 |
|
1929 UPDATECHECK_ABORT = 'abort' # handled at higher layers |
|
1930 UPDATECHECK_NONE = 'none' |
|
1931 UPDATECHECK_LINEAR = 'linear' |
|
1932 UPDATECHECK_NO_CONFLICT = 'noconflict' |
|
1933 |
1929 def update(repo, node, branchmerge, force, ancestor=None, |
1934 def update(repo, node, branchmerge, force, ancestor=None, |
1930 mergeancestor=False, labels=None, matcher=None, mergeforce=False, |
1935 mergeancestor=False, labels=None, matcher=None, mergeforce=False, |
1931 updatecheck=None, wc=None): |
1936 updatecheck=None, wc=None): |
1932 """ |
1937 """ |
1933 Perform a merge between the working directory and the given node |
1938 Perform a merge between the working directory and the given node |
1990 if not branchmerge and not force: |
1995 if not branchmerge and not force: |
1991 # TODO: remove the default once all callers that pass branchmerge=False |
1996 # TODO: remove the default once all callers that pass branchmerge=False |
1992 # and force=False pass a value for updatecheck. We may want to allow |
1997 # and force=False pass a value for updatecheck. We may want to allow |
1993 # updatecheck='abort' to better suppport some of these callers. |
1998 # updatecheck='abort' to better suppport some of these callers. |
1994 if updatecheck is None: |
1999 if updatecheck is None: |
1995 updatecheck = 'linear' |
2000 updatecheck = UPDATECHECK_LINEAR |
1996 assert updatecheck in ('none', 'linear', 'noconflict') |
2001 assert updatecheck in (UPDATECHECK_NONE, |
|
2002 UPDATECHECK_LINEAR, |
|
2003 UPDATECHECK_NO_CONFLICT, |
|
2004 ) |
1997 # If we're doing a partial update, we need to skip updating |
2005 # If we're doing a partial update, we need to skip updating |
1998 # the dirstate, so make a note of any partial-ness to the |
2006 # the dirstate, so make a note of any partial-ness to the |
1999 # update here. |
2007 # update here. |
2000 if matcher is None or matcher.always(): |
2008 if matcher is None or matcher.always(): |
2001 partial = False |
2009 partial = False |
2048 # call the hooks and exit early |
2056 # call the hooks and exit early |
2049 repo.hook('preupdate', throw=True, parent1=xp2, parent2='') |
2057 repo.hook('preupdate', throw=True, parent1=xp2, parent2='') |
2050 repo.hook('update', parent1=xp2, parent2='', error=0) |
2058 repo.hook('update', parent1=xp2, parent2='', error=0) |
2051 return updateresult(0, 0, 0, 0) |
2059 return updateresult(0, 0, 0, 0) |
2052 |
2060 |
2053 if (updatecheck == 'linear' and |
2061 if (updatecheck == UPDATECHECK_LINEAR and |
2054 pas not in ([p1], [p2])): # nonlinear |
2062 pas not in ([p1], [p2])): # nonlinear |
2055 dirty = wc.dirty(missing=True) |
2063 dirty = wc.dirty(missing=True) |
2056 if dirty: |
2064 if dirty: |
2057 # Branching is a bit strange to ensure we do the minimal |
2065 # Branching is a bit strange to ensure we do the minimal |
2058 # amount of call to obsutil.foreground. |
2066 # amount of call to obsutil.foreground. |
2085 ### calculate phase |
2093 ### calculate phase |
2086 actionbyfile, diverge, renamedelete = calculateupdates( |
2094 actionbyfile, diverge, renamedelete = calculateupdates( |
2087 repo, wc, p2, pas, branchmerge, force, mergeancestor, |
2095 repo, wc, p2, pas, branchmerge, force, mergeancestor, |
2088 followcopies, matcher=matcher, mergeforce=mergeforce) |
2096 followcopies, matcher=matcher, mergeforce=mergeforce) |
2089 |
2097 |
2090 if updatecheck == 'noconflict': |
2098 if updatecheck == UPDATECHECK_NO_CONFLICT: |
2091 for f, (m, args, msg) in actionbyfile.iteritems(): |
2099 for f, (m, args, msg) in actionbyfile.iteritems(): |
2092 if m not in (ACTION_GET, ACTION_KEEP, ACTION_EXEC, |
2100 if m not in (ACTION_GET, ACTION_KEEP, ACTION_EXEC, |
2093 ACTION_REMOVE, ACTION_PATH_CONFLICT_RESOLVE): |
2101 ACTION_REMOVE, ACTION_PATH_CONFLICT_RESOLVE): |
2094 msg = _("conflicting changes") |
2102 msg = _("conflicting changes") |
2095 hint = _("commit or update --clean to discard changes") |
2103 hint = _("commit or update --clean to discard changes") |