Alexander Solovyov avatar Alexander Solovyov committed 5549bca

cleanup: remove unused variables, backslashes

Comments (0)

Files changed (4)

crecord/__init__.py

 
 '''text-gui based change selection during commit or qrefresh'''
 from mercurial.i18n import _
-from mercurial import commands, extensions
+from mercurial import commands, extensions, util
 
 from crecord_core import dorecord
 
     except KeyError:
         return
 
-    try:
-        qcmdtable = {
-        "qcrecord":
-            (qcrecord,
+    qnew = '^qnew'
+    if not qnew in mq.cmdtable:
+        # backwards compatible with pre 301633755dec
+        qnew = 'qnew'
 
-             # add qnew options, except '--force'
-             [opt for opt in mq.cmdtable['^qnew'][1] if opt[1] != 'force'],
+    qcmdtable = {
+    "qcrecord":
+        (qcrecord,
 
-             _('hg qcrecord [OPTION]... PATCH [FILE]...')),
-        }
-    except KeyError:
-        # backwards compatible with pre 301633755dec
-        qcmdtable = {
-        "qcrecord":
-            (qcrecord,
-             [opt for opt in mq.cmdtable['qnew'][1] if opt[1] != 'force'],
-             _('hg qcrecord [OPTION]... PATCH [FILE]...')),
-        }
+         # add qnew options, except '--force'
+         [opt for opt in mq.cmdtable[qnew][1] if opt[1] != 'force'],
+
+         _('hg qcrecord [OPTION]... PATCH [FILE]...')),
+    }
 
     cmdtable.update(qcmdtable)

crecord/chunk_selector.py

     # I have no idea if wcurses works with crecord...
     import wcurses as curses
 
-#from curses import textpad 
+#from curses import textpad
 import textpad # customized textpad
 
 try:
     curses
 except NameError:
     raise util.Abort(_('the python curses/wcurses module is not available/installed'))
-    
+
 
 orig_stdout = sys.__stdout__ # used by gethw()
 
     Magically get the current height and width of the window (without initscr)
 
     This is a rip-off of a rip-off - taken from the bpython code.  It is
-    useful / necessary because otherwise curses.initscr() must be called, 
+    useful / necessary because otherwise curses.initscr() must be called,
     which can leave the terminal in a nasty state after exiting.
 
     """
         the first HunkLine of a hunk is currently selected, then select the
         hunk itself.
 
-        If the currently selected item is already at the top of the screen, 
+        If the currently selected item is already at the top of the screen,
         scroll the screen down to show the new-selected item.
 
         """
         selected item.  Otherwise, select (if possible) the parent-item of the
         currently selected item.
 
-        If the currently selected item is already at the top of the screen, 
+        If the currently selected item is already at the top of the screen,
         scroll the screen down to show the new-selected item.
 
         """
         a hunk is currently selected, then select the next hunk, if one exists,
         or if not, the next header if one exists.
 
-        If the currently selected item is already at the bottom of the screen, 
+        If the currently selected item is already at the bottom of the screen,
         scroll the screen up to show the new-selected item.
 
         """
 
         """
         currentItem = self.currentSelectedItem
-        
+
         # try to fold the item
         if not isinstance(currentItem, HunkLine):
             if not currentItem.folded:
                 self.toggleFolded(item=currentItem)
                 return
-        
+
         # if it can't be folded, try to select the parent item
         nextItem = currentItem.parentItem()
-        
+
         if nextItem is None:
             # if no item on parent-level, then no change...
             nextItem = currentItem
         #selNumLines = selEnd - selStart
         padStart = self.firstLineOfPadToPrint
         padEnd = padStart + self.yScreenSize - self.numStatusLines - 1
-        screenMiddleLine = self.yScreenSize / 2
         # 'buffered' pad start/end values which scroll with a certain
         # top/bottom context margin
         padStartBuffered = padStart + 3
                 hunkLine.applied = item.applied
 
             siblingAppliedStatus = [hnk.applied for hnk in item.header.hunks]
-            allSiblingsApplied = not (False in siblingAppliedStatus) 
+            allSiblingsApplied = not (False in siblingAppliedStatus)
             noSiblingsApplied = not (True in siblingAppliedStatus)
 
             siblingsPartialStatus = [hnk.partial for hnk in item.header.hunks]
                     item.header.partial = False
             else: # some/all parent siblings are applied
                 item.header.applied = True
-                item.header.partial = (someSiblingsPartial or \
+                item.header.partial = (someSiblingsPartial or
                                         not allSiblingsApplied)
 
         elif isinstance(item, HunkLine):
             siblingAppliedStatus = [hnkln.applied for hnkln in item.hunk.changedLines]
-            allSiblingsApplied = not (False in siblingAppliedStatus) 
+            allSiblingsApplied = not (False in siblingAppliedStatus)
             noSiblingsApplied = not (True in siblingAppliedStatus)
 
             # if no 'sibling' lines are applied
             # set the applied and partial status of the header if needed
             else: # some/all parent siblings are applied
                 item.hunk.header.applied = True
-                item.hunk.header.partial = (someParentSiblingsPartial or \
+                item.hunk.header.partial = (someParentSiblingsPartial or
                                             not allParentSiblingsApplied)
 
     def toggleAll(self):
                 self.currentSelectedItem = item = item.parentItem()
             elif item.neverUnfolded:
                 item.neverUnfolded = False
-            
+
             # also fold any foldable children of the parent/current item
             if isinstance(item, header): # the original OR 'new' item
                 for child in item.allChildren():
         MAGENTA, RED, WHITE, YELLOW].  If pairName is provided, a color
         pair will be looked up in the self.colorPairNames dictionary.
 
-        attrList is a list containing text attributes in the form of 
+        attrList is a list containing text attributes in the form of
         curses.A_XXXX, where XXXX can be: [BOLD, DIM, NORMAL, STANDOUT,
         UNDERLINE].
-        
+
         If align == True, whitespace is added to the printed string such that
         the string stretches to the right border of the window.
-        
+
         If showWhtSpc == True, trailing whitespace of a string is highlighted.
 
         """
             text = text.rstrip(' \n') # tabs have already been expanded
             strippedLen = len(text)
             numTrailingSpaces = origLen - strippedLen
-        
+
         if toWin:
             window.addstr(text, colorPair)
         t += text
                     for i in range(numTrailingSpaces):
                         window.addch(curses.ACS_CKBOARD, wsColorPair)
                 t += " " * numTrailingSpaces
-        
+
         if align:
             if toWin:
                 extraWhiteSpace = self.alignString("", window)
                 # need to use t, since the x position hasn't incremented
                 extraWhiteSpace = self.alignString(t, window)
             t += extraWhiteSpace
-        
+
         # is reset to 0 at the beginning of printItem()
-        
+
         linesPrinted = (xStart + len(t)) / self.xScreenSize
         self.linesPrintedToPadSoFar += linesPrinted
         return t
         self.statuswin.erase()
         self.chunkpad.erase()
 
-        width = self.xScreenSize
-        alignString = self.alignString
         printString = self.printString
 
         # print out the status lines at the top
                 if isinstance(item, header):
                     # one of "M", "A", or "D" (modified, added, deleted)
                     fileStatus = item.changetype
-                 
+
                     checkBox += fileStatus + " "
             else:
                 checkBox += "  "
             if recurseChildren:
                 for hnk in item.hunks:
                     self.__printItem(hnk, ignoreFolding, recurseChildren, toWin)
-        elif isinstance(item, hunk) and \
-        ((not item.header.folded) or ignoreFolding):
+        elif (isinstance(item, hunk) and
+              ((not item.header.folded) or ignoreFolding)):
             # print the hunk data which comes before the changed-lines
             outStr += self.printHunkLinesBefore(item, selected, toWin=toWin, ignoreFolding=ignoreFolding)
             if recurseChildren:
 
     def initColorPair(self, *args, **kwargs):
         "Same as getColorPair."
-        self.getColorPair(*args, **kwargs)    
+        self.getColorPair(*args, **kwargs)
 
     def helpWindow(self):
         "Print a help window to the screen.  Exit after any keypress."
             else:
                 return key
         statusline = curses.newwin(2,0,0,0)
-        statusLineText = \
-        " Begin/resume editing commit message. CTRL-C/-X returns to patch view."
+        statusLineText = (" Begin/resume editing commit message."
+                          " CTRL-C/-X returns to patch view.")
         self.printString(statusline, statusLineText, pairName="legend")
         statusline.refresh()
         helpwin = curses.newwin(self.yScreenSize-1,0,1,0)
     def confirmCommit(self, review=False):
         "Ask for 'Y' to be pressed to confirm commit. Return True if confirmed."
         if review:
-            confirmText = \
+            confirmText = (
 """If you answer yes to the following, the your currently chosen patch chunks
 will be loaded into an editor.  You may modify the patch from the editor, and
 save the changes if you wish to change the patch.  Otherwise, you can just
 NOTE: don't add/remove lines unless you also modify the range information.
       Failing to follow this rule will result in the commit aborting.
 
-Are you sure you want to review/edit and commit the selected changes [yN]? """
+Are you sure you want to review/edit and commit the selected changes [yN]? """)
         else:
             confirmText = "Are you sure you want to commit the selected changes [yN]? "
 
 
         # initialize selecteItemEndLine (initial start-line is 0)
         self.selectedItemEndLine = self.getNumLinesDisplayed(self.currentSelectedItem, recurseChildren=False)
-        
+
         # option which enables/disables patch-review (in editor) step
-        opts['crecord_reviewpatch'] = False 
+        opts['crecord_reviewpatch'] = False
 
         try:
             self.commentText = opts['message']

crecord/crecord_core.py

 
 '''text-gui based change selection during commit or qrefresh'''
 from mercurial.i18n import _
-from mercurial import cmdutil, commands, extensions, hg, mdiff, patch
+from mercurial import cmdutil, hg, mdiff, patch
 from mercurial import util
 import cStringIO
 import errno

crecord/crpatch.py

             delta -= 1
         fromlen = delta + self.removed
         tolen = delta + self.added
-        fromToLine = '@@ -%d,%d +%d,%d @@%s\n' % \
-                 (self.fromline, fromlen, self.toline, tolen,
-                  self.proc and (' ' + self.proc))
+        fromToLine = '@@ -%d,%d +%d,%d @@%s\n' % (
+            self.fromline, fromlen, self.toline, tolen,
+            self.proc and (' ' + self.proc))
         return fromToLine
 
     def write(self, fp):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.