# HG changeset patch # User Matt Mackall # Date 1374730408 18000 # Node ID 499fc471296baefd8c68206d8dcee7627ff1cb28 # Parent ee1af0f33d0ed9b31ff5f6ae9c9cca3fd3434795 update: add tracking of interrupted updates (issue3113) This takes advantage of the new checkunfinished infrastructure diff -r ee1af0f33d0e -r 499fc471296b mercurial/cmdutil.py --- a/mercurial/cmdutil.py Thu Jul 25 00:00:47 2013 -0500 +++ b/mercurial/cmdutil.py Thu Jul 25 00:33:28 2013 -0500 @@ -2110,7 +2110,9 @@ # (state file, clearable, error, hint) unfinishedstates = [ ('graftstate', True, _('graft in progress'), - _("use 'hg graft --continue' or 'hg update' to abort")) + _("use 'hg graft --continue' or 'hg update' to abort")), + ('updatestate', True, _('last update was interrupted'), + _("use 'hg update' to get a consistent checkout")) ] def checkunfinished(repo): diff -r ee1af0f33d0e -r 499fc471296b mercurial/commands.py --- a/mercurial/commands.py Thu Jul 25 00:00:47 2013 -0500 +++ b/mercurial/commands.py Thu Jul 25 00:33:28 2013 -0500 @@ -5482,7 +5482,9 @@ t = ', '.join(t) cleanworkdir = False - if len(parents) > 1: + if repo.vfs.exists('updatestate'): + t += _(' (interrupted update)') + elif len(parents) > 1: t += _(' (merge)') elif branch != parents[0].branch(): t += _(' (new branch)') diff -r ee1af0f33d0e -r 499fc471296b mercurial/merge.py --- a/mercurial/merge.py Thu Jul 25 00:00:47 2013 -0500 +++ b/mercurial/merge.py Thu Jul 25 00:33:28 2013 -0500 @@ -747,12 +747,17 @@ fp1, fp2, xp1, xp2 = fp2, nullid, xp2, '' if not partial: repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) + # note that we're in the middle of an update + repo.vfs.write('updatestate', p2.hex()) stats = applyupdates(repo, actions, wc, p2, pa, overwrite) if not partial: repo.setparents(fp1, fp2) recordupdates(repo, actions, branchmerge) + # update completed, clear state + util.unlink(repo.join('updatestate')) + if not branchmerge: repo.dirstate.setbranch(p2.branch()) finally: diff -r ee1af0f33d0e -r 499fc471296b tests/test-merge1.t --- a/tests/test-merge1.t Thu Jul 25 00:00:47 2013 -0500 +++ b/tests/test-merge1.t Thu Jul 25 00:33:28 2013 -0500 @@ -23,6 +23,37 @@ $ hg update 0 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + +Test interrupted updates by exploiting our non-handling of directory collisions + + $ mkdir b + $ hg up + abort: Is a directory: '$TESTTMP/t/b' + [255] + $ hg ci + abort: last update was interrupted + (use 'hg update' to get a consistent checkout) + [255] + $ hg sum + parent: 0:538afb845929 + commit #0 + branch: default + commit: (interrupted update) + update: 1 new changesets (update) + $ rmdir b + $ hg up + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg sum + parent: 1:b8bb4a988f25 tip + commit #1 + branch: default + commit: (clean) + update: (current) + +Prepare a basic merge + + $ hg up 0 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo This is file c1 > c $ hg add c $ hg commit -m "commit #2"