evolve: renaming local variables
authorShubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
Thu, 10 Dec 2015 15:55:07 -0800
changeset 1561 dbf1532ee868
parent 1560 59d47a9f633d
child 1562 b1158ce4ec50
evolve: 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.
hgext/evolve.py
--- a/hgext/evolve.py	Thu Dec 10 15:34:34 2015 -0800
+++ b/hgext/evolve.py	Thu Dec 10 15:55:07 2015 -0800
@@ -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:
@@ -2208,46 +2208,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)
 
@@ -2314,10 +2314,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'))
@@ -2418,7 +2418,7 @@
 
         # update bookmarks
         if bookmark:
-            _deletebookmark(repo, marks, bookmark)
+            _deletebookmark(repo, repomarks, bookmark)
 
         # create markers
         obsolete.createmarkers(repo, relations, metadata=metadata)