largefiles: introduce a constant for 'lfmr' action
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 25 Jul 2020 14:44:29 +0530
changeset 45319 a3cd63d6005b
parent 45318 ab57793dec5b
child 45320 e98f7c5babd7
largefiles: introduce a constant for 'lfmr' action It's better to use a dedicated constant instead of a string which makes pretty less sense. Differential Revision: https://phab.mercurial-scm.org/D8836
hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Sat Jul 25 14:41:20 2020 +0530
+++ b/hgext/largefiles/overrides.py	Sat Jul 25 14:44:29 2020 +0530
@@ -52,6 +52,8 @@
 
 lfstatus = lfutil.lfstatus
 
+MERGE_ACTION_LARGEFILE_MARK_REMOVED = b'lfmr'
+
 # -- Utility functions: commonly/repeatedly needed functionality ---------------
 
 
@@ -495,11 +497,11 @@
         orig(ui, repo, *pats, **opts)
 
 
-# Register the `lfmr` merge action in emptyactions() return type
+# Register the MERGE_ACTION_LARGEFILE_MARK_REMOVED in emptyactions() return type
 @eh.wrapfunction(merge, b'emptyactions')
 def overrideemptyactions(origfn):
     ret = origfn()
-    ret[b'lfmr'] = []
+    ret[MERGE_ACTION_LARGEFILE_MARK_REMOVED] = []
     return ret
 
 
@@ -623,7 +625,10 @@
                     # "lfile" should be marked as "removed" without
                     # removal of itself
                     mresult.addfile(
-                        lfile, b'lfmr', None, b'forget non-standin largefile',
+                        lfile,
+                        MERGE_ACTION_LARGEFILE_MARK_REMOVED,
+                        None,
+                        b'forget non-standin largefile',
                     )
 
                     # linear-merge should treat this largefile as 're-added'
@@ -639,9 +644,9 @@
 
 @eh.wrapfunction(mergestatemod, b'recordupdates')
 def mergerecordupdates(orig, repo, actions, branchmerge, getfiledata):
-    if b'lfmr' in actions:
+    if MERGE_ACTION_LARGEFILE_MARK_REMOVED in actions:
         lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
-        for lfile, args, msg in actions[b'lfmr']:
+        for lfile, args, msg in actions[MERGE_ACTION_LARGEFILE_MARK_REMOVED]:
             # this should be executed before 'orig', to execute 'remove'
             # before all other actions
             repo.dirstate.remove(lfile)