[PATCH 3 of 4 shelve-ext v2] shelve: move node-cleaning functionality to be a member of shelvedstate

Kostia Balytskyi ikostia at fb.com
Mon Apr 10 12:04:51 EDT 2017


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1491838663 25200
#      Mon Apr 10 08:37:43 2017 -0700
# Node ID 5c5d69830d176d7eb096c6ccb2f72377e13ace97
# Parent  73c4ca5490a9b5202ffb00ea0bea76c171491e4a
shelve: move node-cleaning functionality to be a member of shelvedstate

This is just a piece of refactoring that I'd like to get in. It seems
harmless to me and will still be valualbe in future, when better
hiding mechanism is introduced.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -275,6 +275,11 @@ class shelvedstate(object):
     def clear(cls, repo):
         repo.vfs.unlinkpath(cls._filename, ignoremissing=True)
 
+    def removenodes(self, ui, repo):
+        """Cleanup temporary nodes from the repo"""
+        repair.strip(ui, repo, self.nodestoprune, backup=False,
+                     topic='shelve')
+
 def cleanupoldbackups(repo):
     vfs = vfsmod.vfs(repo.vfs.join(backupdir))
     maxbackups = repo.ui.configint('shelve', 'maxbackups', 10)
@@ -624,8 +629,7 @@ def unshelveabort(ui, repo, state, opts)
                 raise
 
             mergefiles(ui, repo, state.wctx, state.pendingctx)
-            repair.strip(ui, repo, state.nodestoprune, backup=False,
-                         topic='shelve')
+            state.removenodes(ui, repo)
         finally:
             shelvedstate.clear(repo)
             ui.warn(_("unshelve of '%s' aborted\n") % state.name)
@@ -696,7 +700,7 @@ def unshelvecontinue(ui, repo, state, op
         mergefiles(ui, repo, state.wctx, shelvectx)
         restorebranch(ui, repo, state.branchtorestore)
 
-        repair.strip(ui, repo, state.nodestoprune, backup=False, topic='shelve')
+        state.removenodes(ui, repo)
         _restoreactivebookmark(repo, state.activebookmark)
         shelvedstate.clear(repo)
         unshelvecleanup(ui, repo, state.name, opts)


More information about the Mercurial-devel mailing list