Patchwork [14,of,15,v2] strip: make checklocalchanges() return full status tuple

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 5, 2014, 6:08 a.m.
Message ID <f198246698e1d923fe55.1412489291@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6139/
State Superseded
Commit 68df36ce3d8a3097d146c462f3ff9abdaf7f3944
Headers show

Comments

Martin von Zweigbergk - Oct. 5, 2014, 6:08 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1412481185 25200
#      Sat Oct 04 20:53:05 2014 -0700
# Node ID f198246698e1d923fe556d9b68bb7ff91f224365
# Parent  44c1180cf459fbaa68adf8bfc5226797f5d9962e
strip: make checklocalchanges() return full status tuple

By making checklocalchanges() return the full instance of the status
class instead of just the first 4 elements of it, we can take
advantage of the field names and not require the caller to remember
the element indices.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1360,11 +1360,12 @@ 
 
             tobackup = set()
             if (not nobackup and force) or keepchanges:
-                m, a, r, d = self.checklocalchanges(repo, force=True)
+                status = self.checklocalchanges(repo, force=True)
                 if keepchanges:
-                    tobackup.update(m + a + r + d)
+                    tobackup.update(status.modified + status.added +
+                                    status.removed + status.deleted)
                 else:
-                    tobackup.update(m + a)
+                    tobackup.update(status.modified + status.added)
 
             s = self.series[start:end]
             all_files = set()
@@ -1448,13 +1449,13 @@ 
 
             tobackup = set()
             if update:
-                m, a, r, d = self.checklocalchanges(
-                    repo, force=force or keepchanges)
+                s = self.checklocalchanges(repo, force=force or keepchanges)
                 if force:
                     if not nobackup:
-                        tobackup.update(m + a)
+                        tobackup.update(s.modified + s.added)
                 elif keepchanges:
-                    tobackup.update(m + a + r + d)
+                    tobackup.update(s.modified + s.added +
+                                    s.removed + s.deleted)
 
             self.applieddirty = True
             end = len(self.applied)
diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -32,15 +32,15 @@ 
 
 def checklocalchanges(repo, force=False, excsuffix=''):
     cmdutil.checkunfinished(repo)
-    m, a, r, d = repo.status()[:4]
+    s = repo.status()
     if not force:
-        if (m or a or r or d):
+        if s.modified or s.added or s.removed or s.deleted:
             _("local changes found") # i18n tool detection
             raise util.Abort(_("local changes found" + excsuffix))
         if checksubstate(repo):
             _("local changed subrepos found") # i18n tool detection
             raise util.Abort(_("local changed subrepos found" + excsuffix))
-    return m, a, r, d
+    return s
 
 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
     wlock = lock = None