Patchwork shelve: avoid writing file that is never read from

login
register
mail settings
Submitter Martin von Zweigbergk
Date Sept. 30, 2014, 6:47 a.m.
Message ID <5b622f7900f0f06521d7.1412059632@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6035/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Sept. 30, 2014, 6:47 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1412058224 25200
#      Mon Sep 29 23:23:44 2014 -0700
# Node ID 5b622f7900f0f06521d771739e488ea43cb66c31
# Parent  4109cc16279ef0e04dc70e7f4c9ab7415e6a22d3
shelve: avoid writing file that is never read from

The contents of the .files file has not been used since 1d7a36ff2615
(shelve: use rebase instead of merge (issue4068), 2013-10-23), so stop
writing it. Where we currently use the presence of the file as a check
for a valid shelve name, switch to checking for the .patch file.
Pierre-Yves David - Sept. 30, 2014, 4:13 p.m.
On 09/30/2014 01:47 AM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@gmail.com>
> # Date 1412058224 25200
> #      Mon Sep 29 23:23:44 2014 -0700
> # Node ID 5b622f7900f0f06521d771739e488ea43cb66c31
> # Parent  4109cc16279ef0e04dc70e7f4c9ab7415e6a22d3
> shelve: avoid writing file that is never read from

Pushed to the clowncopter thanks.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -37,7 +37,7 @@ 
 class shelvedfile(object):
     """Helper for the file storing a single shelve
 
-    Handles common functions on shelve files (.hg/.files/.patch) using
+    Handles common functions on shelve files (.hg/.patch) using
     the vfs layer"""
     def __init__(self, repo, name, filetype=None):
         self.repo = repo
@@ -169,12 +169,7 @@ 
         for i in xrange(1, 100):
             yield '%s-%02d' % (label, i)
 
-    shelvedfiles = []
-
     def commitfunc(ui, repo, message, match, opts):
-        # check modified, added, removed, deleted only
-        for flist in repo.status(match=match)[:4]:
-            shelvedfiles.extend(flist)
         hasmq = util.safehasattr(repo, 'mq')
         if hasmq:
             saved, repo.mq.checkapplied = repo.mq.checkapplied, False
@@ -239,9 +234,6 @@ 
                 ui.status(_("nothing changed\n"))
             return 1
 
-        fp = shelvedfile(repo, name, 'files').opener('wb')
-        fp.write('\0'.join(shelvedfiles))
-
         bases = list(publicancestors(repo[node]))
         cg = changegroup.changegroupsubset(repo, bases, [node], 'shelve')
         shelvedfile(repo, name, 'hg').writebundle(cg)
@@ -271,7 +263,7 @@ 
         wlock = repo.wlock()
         for (name, _type) in repo.vfs.readdir('shelved'):
             suffix = name.rsplit('.', 1)[-1]
-            if suffix in ('hg', 'files', 'patch'):
+            if suffix in ('hg', 'patch'):
                 shelvedfile(repo, name).unlink()
     finally:
         lockmod.release(wlock)
@@ -285,7 +277,7 @@ 
         wlock = repo.wlock()
         try:
             for name in pats:
-                for suffix in 'hg files patch'.split():
+                for suffix in 'hg patch'.split():
                     shelvedfile(repo, name, suffix).unlink()
         except OSError, err:
             if err.errno != errno.ENOENT:
@@ -424,7 +416,7 @@ 
 def unshelvecleanup(ui, repo, name, opts):
     """remove related files after an unshelve"""
     if not opts['keep']:
-        for filetype in 'hg files patch'.split():
+        for filetype in 'hg patch'.split():
             shelvedfile(repo, name, filetype).unlink()
 
 def unshelvecontinue(ui, repo, state, opts):
@@ -533,7 +525,7 @@ 
     else:
         basename = shelved[0]
 
-    if not shelvedfile(repo, basename, 'files').exists():
+    if not shelvedfile(repo, basename, 'patch').exists():
         raise util.Abort(_("shelved change '%s' not found") % basename)
 
     oldquiet = ui.quiet