Patchwork [1,of,3,evolve-ext,v2] prune: renaming local variables

login
register
mail settings
Submitter Shubhanshu Agrawal
Date Dec. 11, 2015, 8:28 p.m.
Message ID <f93f4e4374bad7eb2c2d.1449865711@shubhanshu-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/11976/
State Accepted
Headers show

Comments

Shubhanshu Agrawal - Dec. 11, 2015, 8:28 p.m.
# HG changeset patch
# User Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
# Date 1449859417 28800
#      Fri Dec 11 10:43:37 2015 -0800
# Node ID f93f4e4374bad7eb2c2d1853a98a1e6826cf789e
# Parent  ed63bf62ff02cf5a1c9c12841b3ed0dfa7eccf2c
prune: renaming local variables

Renaming local variables to be more precise, i want to store
a different list of bookmarks(input-list) and it would be hard to
understand what marks represents in that change therefore
renaming it to repomarks.
Renames mark to bookmark, which will make the changes in next
patch more understandable, when it is pluraized.
Also renames bookmarks (module) to bookmarksmod so as to
free up the name when bookmark gets pluralized.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -86,7 +86,7 @@ 
 # Flags for enabling optional parts of evolve
 commandopt = 'allnewcommands'
 
-from mercurial import bookmarks
+from mercurial import bookmarks as bookmarksmod
 from mercurial import cmdutil
 from mercurial import commands
 from mercurial import context
@@ -1018,14 +1018,14 @@ 
 ### bookmarks api compatibility layer ###
 def bmdeactivate(repo):
     try:
-        return bookmarks.deactivate(repo)
+        return bookmarksmod.deactivate(repo)
     except AttributeError:
-        return bookmarks.unsetcurrent(repo)
+        return bookmarksmod.unsetcurrent(repo)
 def bmactivate(repo, book):
     try:
-        return bookmarks.activate(repo, book)
+        return bookmarksmod.activate(repo, book)
     except AttributeError:
-        return bookmarks.setcurrent(repo, book)
+        return bookmarksmod.setcurrent(repo, book)
 
 def bmactive(repo):
     try:
@@ -2200,46 +2200,46 @@ 
         return 1
     return result
 
-def _reachablefrombookmark(repo, revs, mark):
+def _reachablefrombookmark(repo, revs, bookmark):
     """filter revisions and bookmarks reachable from the given bookmark
     yoinked from mq.py
     """
-    marks = repo._bookmarks
-    if mark not in marks:
-        raise error.Abort(_("bookmark '%s' not found") % mark)
+    repomarks = repo._bookmarks
+    if bookmark not in repomarks:
+        raise error.Abort(_("bookmark '%s' not found") % bookmark)
 
     # If the requested bookmark is not the only one pointing to a
     # a revision we have to only delete the bookmark and not strip
     # anything. revsets cannot detect that case.
     uniquebm = True
-    for m, n in marks.iteritems():
-        if m != mark and n == repo[mark].node():
+    for m, n in repomarks.iteritems():
+        if m != bookmark and n == repo[bookmark].node():
             uniquebm = False
             break
     if uniquebm:
         if util.safehasattr(repair, 'stripbmrevset'):
-            rsrevs = repair.stripbmrevset(repo, mark)
+            rsrevs = repair.stripbmrevset(repo, bookmark)
         else:
             rsrevs = repo.revs("ancestors(bookmark(%s)) - "
                                "ancestors(head() and not bookmark(%s)) - "
                                "ancestors(bookmark() and not bookmark(%s)) - "
                                "obsolete()",
-                               mark, mark, mark)
+                               bookmark, bookmark, bookmark)
         revs = set(revs)
         revs.update(set(rsrevs))
         revs = sorted(revs)
-    return marks, revs
-
-def _deletebookmark(repo, marks, mark):
+    return repomarks, revs
+
+def _deletebookmark(repo, repomarks, bookmark):
     wlock = lock = tr = None
     try:
         wlock = repo.wlock()
         lock = repo.lock()
         tr = repo.transaction('prune')
-        del marks[mark]
-        marks.recordchange(tr)
+        del repomarks[bookmark]
+        repomarks.recordchange(tr)
         tr.close()
-        repo.ui.write(_("bookmark '%s' deleted\n") % mark)
+        repo.ui.write(_("bookmark '%s' deleted\n") % bookmark)
     finally:
         lockmod.release(tr, lock, wlock)
 
@@ -2306,10 +2306,10 @@ 
         raise error.Abort(_("can only specify one of %s") % ', '.join(options))
 
     if bookmark:
-        marks, revs = _reachablefrombookmark(repo, revs, bookmark)
+        repomarks, revs = _reachablefrombookmark(repo, revs, bookmark)
         if not revs:
             # no revisions to prune - delete bookmark immediately
-            _deletebookmark(repo, marks, bookmark)
+            _deletebookmark(repo, repomarks, bookmark)
 
     if not revs:
         raise error.Abort(_('nothing to prune'))
@@ -2410,7 +2410,7 @@ 
 
         # update bookmarks
         if bookmark:
-            _deletebookmark(repo, marks, bookmark)
+            _deletebookmark(repo, repomarks, bookmark)
 
         # create markers
         obsolete.createmarkers(repo, relations, metadata=metadata)