Patchwork D493: dirstate: perform transactions with _copymap using single call, where possible

login
register
mail settings
Submitter phabricator
Date Aug. 28, 2017, 7:06 p.m.
Message ID <27ce69ef3598c1ffce365152efa0ca03@localhost.localdomain>
Download mbox | patch
Permalink /patch/23439/
State Not Applicable
Headers show

Comments

phabricator - Aug. 28, 2017, 7:06 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5cb0a8fe096e: dirstate: perform transactions with _copymap using single call, where possible (authored by mbolin).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D493?vs=1209&id=1366

REVISION DETAIL
  https://phab.mercurial-scm.org/D493

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: mbolin, rdamazio, durin42, quark, #hg-reviewers, dsp
Cc: dsp, mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -406,13 +406,15 @@ 
 
                 # Discard 'm' markers when moving away from a merge state
                 if s[0] == 'm':
-                    if f in self._copymap:
-                        copies[f] = self._copymap[f]
+                    source = self._copymap.get(f)
+                    if source:
+                        copies[f] = source
                     self.normallookup(f)
                 # Also fix up otherparent markers
                 elif s[0] == 'n' and s[2] == -2:
-                    if f in self._copymap:
-                        copies[f] = self._copymap[f]
+                    source = self._copymap.get(f)
+                    if source:
+                        copies[f] = source
                     self.add(f)
         return copies
 
@@ -518,8 +520,7 @@ 
             self._copymap[dest] = source
             self._updatedfiles.add(source)
             self._updatedfiles.add(dest)
-        elif dest in self._copymap:
-            del self._copymap[dest]
+        elif self._copymap.pop(dest, None):
             self._updatedfiles.add(dest)
 
     def copied(self, file):
@@ -568,8 +569,7 @@ 
         mtime = s.st_mtime
         self._addpath(f, 'n', s.st_mode,
                       s.st_size & _rangemask, mtime & _rangemask)
-        if f in self._copymap:
-            del self._copymap[f]
+        self._copymap.pop(f, None)
         if f in self._nonnormalset:
             self._nonnormalset.remove(f)
         if mtime > self._lastnormaltime:
@@ -597,8 +597,7 @@ 
             if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
                 return
         self._addpath(f, 'n', 0, -1, -1)
-        if f in self._copymap:
-            del self._copymap[f]
+        self._copymap.pop(f, None)
         if f in self._nonnormalset:
             self._nonnormalset.remove(f)
 
@@ -613,15 +612,12 @@ 
         else:
             # add-like
             self._addpath(f, 'n', 0, -2, -1)
-
-        if f in self._copymap:
-            del self._copymap[f]
+        self._copymap.pop(f, None)
 
     def add(self, f):
         '''Mark a file added.'''
         self._addpath(f, 'a', 0, -1, -1)
-        if f in self._copymap:
-            del self._copymap[f]
+        self._copymap.pop(f, None)
 
     def remove(self, f):
         '''Mark a file removed.'''
@@ -638,8 +634,8 @@ 
                 self._otherparentset.add(f)
         self._map[f] = dirstatetuple('r', 0, size, 0)
         self._nonnormalset.add(f)
-        if size == 0 and f in self._copymap:
-            del self._copymap[f]
+        if size == 0:
+            self._copymap.pop(f, None)
 
     def merge(self, f):
         '''Mark a file merged.'''
@@ -655,8 +651,7 @@ 
             del self._map[f]
             if f in self._nonnormalset:
                 self._nonnormalset.remove(f)
-            if f in self._copymap:
-                del self._copymap[f]
+            self._copymap.pop(f, None)
 
     def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
         if exists is None: