Patchwork [10,of,16,V3] record: access status fields by name rather than index

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 10, 2014, 10:20 p.m.
Message ID <94982fdcee6eff5a43a9.1412979642@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6200/
State Superseded
Headers show

Comments

Martin von Zweigbergk - Oct. 10, 2014, 10:20 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1412358247 25200
#      Fri Oct 03 10:44:07 2014 -0700
# Node ID 94982fdcee6eff5a43a9d25c702102f52080bdf6
# Parent  6aa0450f62f0411799bebba8e44a747c4afeb154
record: access status fields by name rather than index

It is safe to pass the full status to patch.diff() since it does its
own slicing.

Patch

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -519,12 +519,12 @@ 
             raise util.Abort(_('cannot partially commit a merge '
                                '(use "hg commit" instead)'))
 
-        changes = repo.status(match=match)[:3]
+        status = repo.status(match=match)
         diffopts = opts.copy()
         diffopts['nodates'] = True
         diffopts['git'] = True
         diffopts = patch.diffopts(ui, opts=diffopts)
-        chunks = patch.diff(repo, changes=changes, opts=diffopts)
+        chunks = patch.diff(repo, changes=status, opts=diffopts)
         fp = cStringIO.StringIO()
         fp.write(''.join(chunks))
         fp.seek(0)
@@ -544,13 +544,13 @@ 
             except AttributeError:
                 pass
 
-        changed = changes[0] + changes[1] + changes[2]
+        changed = status.modified + status.added + status.removed
         newfiles = [f for f in changed if f in contenders]
         if not newfiles:
             ui.status(_('no changes to record\n'))
             return 0
 
-        modified = set(changes[0])
+        modified = set(status.modified)
 
         # 2. backup changed files, so we can restore them in the end
         if backupall: