[PATCH 7 of 8] largefiles: update largefiles even if transplant is aborted by conflict

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Aug 24 09:54:53 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1408891646 -32400
#      Sun Aug 24 23:47:26 2014 +0900
# Node ID ade8e834be33b2f9c02112d68bf1dfabfbd4d28d
# Parent  469040d865588aed62c394654d87f7cd9db145d5
largefiles: update largefiles even if transplant is aborted by conflict

Before this patch, largefiles in the working directory aren't updated
correctly, if transplant is aborted by conflict. This prevents users
from viewing appropriate largefiles while resolving conflicts.

While transplant, largefiles in the working directory are updated only
at successful committing in the special code path of
"lfilesrepo.commit()".

To update largefiles even if transplant is aborted by conflict, this
patch wraps "scmutil.marktouched", which is invoked from "patch.patch"
with "files" list of added/modified/deleted files.

This patch invokes "updatelfiles" with:

  - "printmessage=False", to suppress "getting changed largefiles ..."
    messages while automated committing by transplant

  - "normallookup=True", because "patch.patch" doesn't update dirstate
    for modified files

    in such case, "normallookup=False" may cause marking modified
    largefiles as "clean" unexpectedly

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1318,3 +1318,13 @@
         return result
     finally:
         wlock.release()
+
+def scmutilmarktouched(orig, repo, files, *args, **kwargs):
+    result = orig(repo, files, *args, **kwargs)
+
+    filelist = [lfutil.splitstandin(f) for f in files if lfutil.isstandin(f)]
+    if filelist:
+        lfcommands.updatelfiles(repo.ui, repo, filelist=filelist,
+                                printmessage=False, normallookup=True)
+
+    return result
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -125,6 +125,9 @@
     extensions.wrapfunction(cmdutil, 'bailifchanged',
                             overrides.overridebailifchanged)
 
+    extensions.wrapfunction(scmutil, 'marktouched',
+                            overrides.scmutilmarktouched)
+
     # create the new wireproto commands ...
     wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
     wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -485,4 +485,35 @@
   $ hg rebase -q --abort
   rebase aborted
 
+Test that transplant updates largefiles, of which standins are safely
+changed, even if it is aborted by conflict of other.
+
+  $ hg update -q -C 5
+  $ cat .hglf/large1
+  e5bb990443d6a92aaf7223813720f7566c9dd05b
+  $ cat large1
+  large1 in #3
+  $ hg diff -c 4 .hglf/largeX | grep '^[+-][0-9a-z]'
+  +fa44618ea25181aff4f48b70428294790cec9f61
+  $ hg transplant 4
+  applying 07d6153b5c04
+  patching file .hglf/large1
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file .hglf/large1.rej
+  patch failed to apply
+  abort: fix up the merge and run hg transplant --continue
+  [255]
+  $ hg status -A large1
+  C large1
+  $ cat .hglf/large1
+  e5bb990443d6a92aaf7223813720f7566c9dd05b
+  $ cat large1
+  large1 in #3
+  $ hg status -A largeX
+  A largeX
+  $ cat .hglf/largeX
+  fa44618ea25181aff4f48b70428294790cec9f61
+  $ cat largeX
+  largeX
+
   $ cd ..


More information about the Mercurial-devel mailing list