Patchwork [7,of,7] largefiles: start by finding files of interest

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 10, 2014, 9:09 p.m.
Message ID <07fcb956212223676b35.1418245745@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7047/
State Accepted
Commit 42ae1b1f048ffeeef02f29805a8c855bf9d33731
Headers show

Comments

Martin von Zweigbergk - Dec. 10, 2014, 9:09 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1418191851 28800
#      Tue Dec 09 22:10:51 2014 -0800
# Node ID 07fcb956212223676b35055d39dddac88ca990b6
# Parent  6527416436b7cfb801924e898783791a65a2e912
largefiles: start by finding files of interest

Instead of iterating over 'g' action, first find the set of all files
that are largefiles in p1. Then iterate over these files. This
prepares for considering actions other than 'g'.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -426,22 +426,24 @@ 
         return actions, diverge, renamedelete
 
     # Convert to dictionary with filename as key and action as value.
+    lfiles = set()
     actionbyfile = {}
     for m, l in actions.iteritems():
         for f, args, msg in l:
             actionbyfile[f] = m, args, msg
+            splitstandin = f and lfutil.splitstandin(f)
+            if splitstandin in p1:
+                lfiles.add(splitstandin)
+            elif lfutil.standin(f) in p1:
+                lfiles.add(f)
 
-    removes = set(a[0] for a in actions['r'])
-
-    for action in actions['g']:
-        f, args, msg = action
-        splitstandin = f and lfutil.splitstandin(f)
-        if (splitstandin is not None and
-            splitstandin in p1 and splitstandin not in removes):
+    for lfile in lfiles:
+        standin = lfutil.standin(lfile)
+        lm = actionbyfile.get(lfile, (None, None, None))[0]
+        sm = actionbyfile.get(standin, (None, None, None))[0]
+        if sm == 'g' and lm != 'r':
             # Case 1: normal file in the working copy, largefile in
             # the second parent
-            lfile = splitstandin
-            standin = f
             usermsg = _('remote turned local normal file %s into a largefile\n'
                         'use (l)argefile or keep (n)ormal file?'
                         '$$ &Largefile $$ &Normal file') % lfile
@@ -454,11 +456,9 @@ 
                 else:
                     actionbyfile[standin] = ('r', None,
                                              'replaced by non-standin')
-        elif lfutil.standin(f) in p1 and lfutil.standin(f) not in removes:
+        elif lm == 'g' and sm != 'r':
             # Case 2: largefile in the working copy, normal file in
             # the second parent
-            standin = lfutil.standin(f)
-            lfile = f
             usermsg = _('remote turned local largefile %s into a normal file\n'
                     'keep (l)argefile or use (n)ormal file?'
                     '$$ &Largefile $$ &Normal file') % lfile