comparison hgext/mq.py @ 43640:2d5b991c2192

mq: use field names instead of field numbers on scmutil.status As part of my pytype adventures I want to make scmutil.status no longer a subclass of tuple. This is part of that process. Differential Revision: https://phab.mercurial-scm.org/D7392
author Augie Fackler <augie@google.com>
date Thu, 14 Nov 2019 15:25:40 -0500
parents 9f70512ae2cf
children ce37b35d4843
comparison
equal deleted inserted replaced
43639:52a73fb498a4 43640:2d5b991c2192
1249 raise error.Abort(_(b"working directory revision is not qtip")) 1249 raise error.Abort(_(b"working directory revision is not qtip"))
1250 return top, patch 1250 return top, patch
1251 return None, None 1251 return None, None
1252 1252
1253 def putsubstate2changes(self, substatestate, changes): 1253 def putsubstate2changes(self, substatestate, changes):
1254 for files in changes[:3]: 1254 if isinstance(changes, list):
1255 if b'.hgsubstate' in files: 1255 mar = changes[:3]
1256 return # already listed up 1256 else:
1257 mar = (changes.modified, changes.added, changes.removed)
1258 if any((b'.hgsubstate' in files for files in mar)):
1259 return # already listed up
1257 # not yet listed up 1260 # not yet listed up
1258 if substatestate in b'a?': 1261 if substatestate in b'a?':
1259 changes[1].append(b'.hgsubstate') 1262 mar[1].append(b'.hgsubstate')
1260 elif substatestate in b'r': 1263 elif substatestate in b'r':
1261 changes[2].append(b'.hgsubstate') 1264 mar[2].append(b'.hgsubstate')
1262 else: # modified 1265 else: # modified
1263 changes[0].append(b'.hgsubstate') 1266 mar[0].append(b'.hgsubstate')
1264 1267
1265 def checklocalchanges(self, repo, force=False, refresh=True): 1268 def checklocalchanges(self, repo, force=False, refresh=True):
1266 excsuffix = b'' 1269 excsuffix = b''
1267 if refresh: 1270 if refresh:
1268 excsuffix = b', qrefresh first' 1271 excsuffix = b', qrefresh first'
1375 match = scmutil.match(repo[None], pats, opts, badfn=badfn) 1378 match = scmutil.match(repo[None], pats, opts, badfn=badfn)
1376 changes = repo.status(match=match) 1379 changes = repo.status(match=match)
1377 else: 1380 else:
1378 changes = self.checklocalchanges(repo, force=True) 1381 changes = self.checklocalchanges(repo, force=True)
1379 commitfiles = list(inclsubs) 1382 commitfiles = list(inclsubs)
1380 for files in changes[:3]: 1383 commitfiles.extend(changes.modified)
1381 commitfiles.extend(files) 1384 commitfiles.extend(changes.added)
1385 commitfiles.extend(changes.removed)
1382 match = scmutil.matchfiles(repo, commitfiles) 1386 match = scmutil.matchfiles(repo, commitfiles)
1383 if len(repo[None].parents()) > 1: 1387 if len(repo[None].parents()) > 1:
1384 raise error.Abort(_(b'cannot manage merge changesets')) 1388 raise error.Abort(_(b'cannot manage merge changesets'))
1385 self.checktoppatch(repo) 1389 self.checktoppatch(repo)
1386 insert = self.fullseriesend() 1390 insert = self.fullseriesend()
1816 # we know there are no local changes, so we can make a simplified 1820 # we know there are no local changes, so we can make a simplified
1817 # form of hg.update. 1821 # form of hg.update.
1818 if update: 1822 if update:
1819 qp = self.qparents(repo, rev) 1823 qp = self.qparents(repo, rev)
1820 ctx = repo[qp] 1824 ctx = repo[qp]
1821 m, a, r, d = repo.status(qp, b'.')[:4] 1825 st = repo.status(qp, b'.')
1826 m, a, r, d = st.modified, st.added, st.removed, st.deleted
1822 if d: 1827 if d:
1823 raise error.Abort(_(b"deletions found between repo revs")) 1828 raise error.Abort(_(b"deletions found between repo revs"))
1824 1829
1825 tobackup = set(a + m + r) & tobackup 1830 tobackup = set(a + m + r) & tobackup
1826 if keepchanges and tobackup: 1831 if keepchanges and tobackup:
1908 1913
1909 # update the dirstate in place, strip off the qtip commit 1914 # update the dirstate in place, strip off the qtip commit
1910 # and then commit. 1915 # and then commit.
1911 # 1916 #
1912 # this should really read: 1917 # this should really read:
1913 # mm, dd, aa = repo.status(top, patchparent)[:3] 1918 # st = repo.status(top, patchparent)
1914 # but we do it backwards to take advantage of manifest/changelog 1919 # but we do it backwards to take advantage of manifest/changelog
1915 # caching against the next repo.status call 1920 # caching against the next repo.status call
1916 mm, aa, dd = repo.status(patchparent, top)[:3] 1921 st = repo.status(patchparent, top)
1922 mm, aa, dd = st.modified, st.added, st.removed
1917 ctx = repo[top] 1923 ctx = repo[top]
1918 aaa = aa[:] 1924 aaa = aa[:]
1919 match1 = scmutil.match(repo[None], pats, opts) 1925 match1 = scmutil.match(repo[None], pats, opts)
1920 # in short mode, we only diff the files included in the 1926 # in short mode, we only diff the files included in the
1921 # patch already plus specified files 1927 # patch already plus specified files
1925 match = scmutil.matchfiles(repo, mm + aa + dd + match1.files()) 1931 match = scmutil.matchfiles(repo, mm + aa + dd + match1.files())
1926 # filter with include/exclude options 1932 # filter with include/exclude options
1927 match1 = scmutil.match(repo[None], opts=opts) 1933 match1 = scmutil.match(repo[None], opts=opts)
1928 else: 1934 else:
1929 match = scmutil.matchall(repo) 1935 match = scmutil.matchall(repo)
1930 m, a, r, d = repo.status(match=match)[:4] 1936 stb = repo.status(match=match)
1937 m, a, r, d = stb.modified, stb.added, stb.removed, stb.deleted
1931 mm = set(mm) 1938 mm = set(mm)
1932 aa = set(aa) 1939 aa = set(aa)
1933 dd = set(dd) 1940 dd = set(dd)
1934 1941
1935 # we might end up with files that were added between 1942 # we might end up with files that were added between
1964 r = list(dd) 1971 r = list(dd)
1965 a = list(aa) 1972 a = list(aa)
1966 1973
1967 # create 'match' that includes the files to be recommitted. 1974 # create 'match' that includes the files to be recommitted.
1968 # apply match1 via repo.status to ensure correct case handling. 1975 # apply match1 via repo.status to ensure correct case handling.
1969 cm, ca, cr, cd = repo.status(patchparent, match=match1)[:4] 1976 st = repo.status(patchparent, match=match1)
1977 cm, ca, cr, cd = st.modified, st.added, st.removed, st.deleted
1970 allmatches = set(cm + ca + cr + cd) 1978 allmatches = set(cm + ca + cr + cd)
1971 refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)] 1979 refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)]
1972 1980
1973 files = set(inclsubs) 1981 files = set(inclsubs)
1974 for x in refreshchanges: 1982 for x in refreshchanges: