Patchwork [3,of,3] update: don't overwrite untracked ignored files on update

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 3, 2014, 1:42 a.m.
Message ID <e837bee59fc3df279161.1417570976@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6967/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Dec. 3, 2014, 1:42 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1416210104 28800
#      Sun Nov 16 23:41:44 2014 -0800
# Node ID e837bee59fc3df279161982e1c651e89aad934cc
# Parent  580066d004512f5fabbf83d1a47d09af1546edd5
update: don't overwrite untracked ignored files on update

When looking for untracked files that would conflict with a tracked
file in the target revision (or the remote side of a merge), we
explcitly exclude ignored files. The code was added in 7e30f5f2285f
(merge: refactor unknown file conflict checking, 2012-02-09), but it
seems like only unknown, not ignored, files were considered since the
beginning of time.

Although ignored files are mostly build outputs and backup files, we
should still not overwrite them. Fix by simply removing the explicit
check.
Martin von Zweigbergk - Dec. 3, 2014, 1:56 a.m.
On Tue Dec 02 2014 at 5:42:58 PM Martin von Zweigbergk <
martinvonz@google.com> wrote:

> diff --git a/tests/test-up-local-change.t b/tests/test-up-local-change.t
> --- a/tests/test-up-local-change.t
> +++ b/tests/test-up-local-change.t
> @@ -196,9 +196,9 @@
>    $ echo untracked > ignored
>    $ hg st
>    $ hg up 'desc("add ignored file")'
> -  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> -  $ cat ignored
> -  ignored
> +  ignored: untracked file differs
> +  abort: untracked files in working directory differ from files in
> requested revision
> +  [255]
>

This test case is no longer broken, so please remove the "BROKEN:" line in
flight if you don't mind.
Matt Mackall - Dec. 5, 2014, 12:36 a.m.
On Tue, 2014-12-02 at 17:42 -0800, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1416210104 28800
> #      Sun Nov 16 23:41:44 2014 -0800
> # Node ID e837bee59fc3df279161982e1c651e89aad934cc
> # Parent  580066d004512f5fabbf83d1a47d09af1546edd5
> update: don't overwrite untracked ignored files on update

This looks like a bug fix, so I'm going to queue these two for stable
(with the BROKEN line dropped).

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -298,8 +298,7 @@ 
         return r
 
 def _checkunknownfile(repo, wctx, mctx, f):
-    return (not repo.dirstate._ignore(f)
-        and os.path.isfile(repo.wjoin(f))
+    return (os.path.isfile(repo.wjoin(f))
         and repo.wopener.audit.check(f)
         and repo.dirstate.normalize(f) not in repo.dirstate
         and mctx[f].cmp(wctx[f]))
diff --git a/tests/test-up-local-change.t b/tests/test-up-local-change.t
--- a/tests/test-up-local-change.t
+++ b/tests/test-up-local-change.t
@@ -196,9 +196,9 @@ 
   $ echo untracked > ignored
   $ hg st
   $ hg up 'desc("add ignored file")'
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cat ignored
-  ignored
+  ignored: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
+  [255]
 
 test a local add