Patchwork [2,of,6,misc] largefiles: don't prompt when one side of merge was changed but didn't change

login
register
mail settings
Submitter Mads Kiilerich
Date April 7, 2014, 9:11 p.m.
Message ID <578f5c46a3389f5096c0.1396905094@mk-desktop>
Download mbox | patch
Permalink /patch/4272/
State Accepted
Commit 40800668e01921e41db1eb97d19e473971e93f5e
Headers show

Comments

Mads Kiilerich - April 7, 2014, 9:11 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1396905020 -7200
#      Mon Apr 07 23:10:20 2014 +0200
# Node ID 578f5c46a3389f5096c05822f868c08905e23fb7
# Parent  ac4eb6bcdb81df536110ab0b09026539749599a0
largefiles: don't prompt when one side of merge was changed but didn't change

This can happen after backout or grafts or criss cross merges. We already do
the same (but slightly different) thing in manifestmerge and filemerge.
Matt Mackall - April 11, 2014, 10:07 p.m.
On Mon, 2014-04-07 at 23:11 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1396905020 -7200
> #      Mon Apr 07 23:10:20 2014 +0200
> # Node ID 578f5c46a3389f5096c05822f868c08905e23fb7
> # Parent  ac4eb6bcdb81df536110ab0b09026539749599a0
> largefiles: don't prompt when one side of merge was changed but didn't change

I've queued this one for default, thanks.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -420,16 +420,18 @@  def overridefilemerge(origfn, repo, myno
     if not lfutil.isstandin(orig):
         return origfn(repo, mynode, orig, fcd, fco, fca)
 
-    if not fco.cmp(fcd): # files identical?
-        return None
-
-    if repo.ui.promptchoice(
-        _('largefile %s has a merge conflict\nancestor was %s\n'
-          'keep (l)ocal %s or\ntake (o)ther %s?'
-          '$$ &Local $$ &Other') %
-          (lfutil.splitstandin(orig),
-           fca.data().strip(), fcd.data().strip(), fco.data().strip()),
-        0) == 1:
+    ahash = fca.data().strip().lower()
+    dhash = fcd.data().strip().lower()
+    ohash = fco.data().strip().lower()
+    if (ohash != ahash and
+        ohash != dhash and
+        (dhash == ahash or
+         repo.ui.promptchoice(
+             _('largefile %s has a merge conflict\nancestor was %s\n'
+               'keep (l)ocal %s or\ntake (o)ther %s?'
+               '$$ &Local $$ &Other') %
+               (lfutil.splitstandin(orig), ahash, dhash, ohash),
+             0) == 1)):
         repo.wwrite(fcd.path(), fco.data(), fco.flags())
     return 0
 
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -2226,6 +2226,79 @@  merge action 'd' for 'local renamed dire
   0 largefiles updated, 0 removed
   $ cd ..
 
+
+Merge conflicts:
+
+  $ hg init merge
+  $ cd merge
+  $ echo 0 > f-different
+  $ echo 0 > f-same
+  $ echo 0 > f-unchanged-1
+  $ echo 0 > f-unchanged-2
+  $ hg add --large *
+  $ hg ci -m0
+  Invoking status precommit hook
+  A f-different
+  A f-same
+  A f-unchanged-1
+  A f-unchanged-2
+  $ echo tmp1 > f-unchanged-1
+  $ echo tmp1 > f-unchanged-2
+  $ echo tmp1 > f-same
+  $ hg ci -m1
+  Invoking status precommit hook
+  M f-same
+  M f-unchanged-1
+  M f-unchanged-2
+  $ echo 2 > f-different
+  $ echo 0 > f-unchanged-1
+  $ echo 1 > f-unchanged-2
+  $ echo 1 > f-same
+  $ hg ci -m2
+  Invoking status precommit hook
+  M f-different
+  M f-same
+  M f-unchanged-1
+  M f-unchanged-2
+  $ hg up -qr0
+  $ echo tmp2 > f-unchanged-1
+  $ echo tmp2 > f-unchanged-2
+  $ echo tmp2 > f-same
+  $ hg ci -m3
+  Invoking status precommit hook
+  M f-same
+  M f-unchanged-1
+  M f-unchanged-2
+  created new head
+  $ echo 1 > f-different
+  $ echo 1 > f-unchanged-1
+  $ echo 0 > f-unchanged-2
+  $ echo 1 > f-same
+  $ hg ci -m4
+  Invoking status precommit hook
+  M f-different
+  M f-same
+  M f-unchanged-1
+  M f-unchanged-2
+  $ hg merge
+  largefile f-different has a merge conflict
+  ancestor was 09d2af8dd22201dd8d48e5dcfcaed281ff9422c7
+  keep (l)ocal e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e or
+  take (o)ther 7448d8798a4380162d4b56f9b452e2f6f9e24e7a? l
+  0 files updated, 4 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  getting changed largefiles
+  1 largefiles updated, 0 removed
+  $ cat f-different
+  1
+  $ cat f-same
+  1
+  $ cat f-unchanged-1
+  1
+  $ cat f-unchanged-2
+  1
+  $ cd ..
+
 Check whether "largefiles" feature is supported only in repositories
 enabling largefiles extension.