1. guillermooo
  2. SublimeHg

Commits

guillermooo  committed 5a56f42

[mq]: actions.patch

  • Participants
  • Parent commits 6edbb96
  • Branches default

Comments (0)

Files changed (5)

File Default.sublime-keymap

View file
 [
-	{"keys": ["enter"], "command": "sublime_hg_send_line",
-		"context": [
-			{"key": "selector", "operator": "equal", "operand": "source.sublime_hg_cli"}
-		]
-	}
+	{"keys": ["enter"], "command": "sublime_hg_send_line", "context": [{"key": "selector", "operand": "source.sublime_hg_cli"}]},
+	{"keys": ["ctrl+enter"], "command": "sublime_hg_diff_selected", "context": [{ "key": "selector", "operand": "text.mercurial-log" }]},
+	{"keys": ["ctrl+shift+enter"], "command": "sublime_hg_update_to_revision", "context": [{ "key": "selector", "operand": "text.mercurial-log" }]}
 ]

File README.rst

View file
 
 
 Restarting the Current Server
------------------------------
+=============================
 
 The Mercurial command server will not detect changes to the repository made
 from the outside (perhaps from a command line) while it is running. To restart
 *Kill Current Server* from the command palette.
 
 Tab Completion
---------------
+==============
 
 While in the command-line, top level commands will be autocompleted when you
 press ``Tab``.
+
+
+Quick Actions
+=============
+
+In some situations, you can perform quick actions.
+
+Log
+***
+
+In a log report (*text.mercurial-log*), select two commit numbers (*keyword.other.changeset-ref.short.mercurial-log*)
+and press *CTRL+ENTER* to **diff the two revisions** (*diff -rSMALLER_REV_NR:LARGER_REV_NR).
+
+If you want to update to a revision number, select a commit number and press *CTRL+SHIFT+ENTER* (*update REV_NO*).
+
+
+Donations
+=========
+
+You can tip me through www.gittip.com:
+
+.. raw:: html
+
+	<a href="http://www.gittip.com/guillermooo/">guillermooo</a> - <iframe style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/guillermooo/widget.html" width="48pt" height="20pt"></iframe>
+	

File hg_actions.py

View file
+import sublime
+import sublime_plugin
+
+from sublime_hg import run_hg_cmd
+from sublime_hg import running_servers
+
+
+class SublimeHgDiffSelectedCommand(sublime_plugin.TextCommand):
+    def is_enabled(self):
+        return self.view.match_selector(0, "text.mercurial-log")
+
+    def run(self, edit):
+        if len(self.view.sel()) > 2:
+            sublime.status_message("SublimeHg: Please select only two commits.")
+            return
+
+        sels = list(self.view.sel())
+        if not (self.view.match_selector(sels[0].begin(), "keyword.other.changeset-ref.short.mercurial-log") and
+                self.view.match_selector(sels[1].begin(), "keyword.other.changeset-ref.short.mercurial-log")):
+            sublime.status_message("SublimeHg: SublimeHg: Please select only two commits.")
+            return
+
+        commit_nrs = [int(self.view.substr(x)) for x in self.view.sel()]
+        older, newer = min(commit_nrs), max(commit_nrs)
+
+        w = self.view.window()
+        w.run_command("close")
+        # FIXME: We're assuming this is the correct view, and it might not be.
+        v = sublime.active_window().active_view()
+        path = v.file_name()
+        v.run_command("hg_command_runner", {"cmd": "diff -r%d:%d" % (older, newer),
+                                            "display_name": "diff",
+                                            "cwd": path})
+
+
+class SublimeHgUpdateToRevisionCommand(sublime_plugin.TextCommand):
+    def is_enabled(self):
+        return self.view.match_selector(0, "text.mercurial-log")
+
+    def run(self, edit):
+        if len(self.view.sel()) > 1:
+            sublime.status_message("SublimeHg: Please select only one commit.")
+            return
+
+        sels = list(self.view.sel())
+        if not (self.view.match_selector(sels[0].begin(), "keyword.other.changeset-ref.short.mercurial-log")):
+            sublime.status_message("SublimeHg: SublimeHg: Please select only one commit.")
+            return
+
+        w = self.view.window()
+        w.run_command("close")
+        # FIXME: We're assuming this is the correct view, and it might not be.
+        v = sublime.active_window().active_view()
+        path = v.file_name()
+
+        text, exit_code = run_hg_cmd(running_servers[path], "status")
+        if text:
+            msg = "SublimeHg: Don't update to a different revision with uncommited changes. Aborting."
+            print msg
+            sublime.status_message(msg)
+            return
+
+        v.run_command("hg_command_runner", {"cmd": "update %d" % int(self.view.substr(self.view.sel()[0])),
+                                            "display_name": "update",
+                                            "cwd": path})

File shglib/client.py

View file
                 self.shut_down()
                 print "Didn't expect such channel."
                 return
-
-
-if __name__ == '__main__':
-    foo = parsing.CommandLexer("foo -l100")
-    print list(foo)

File sublime_hg.py

View file
 from shglib.parsing import CommandLexer
 
 
-VERSION = '12.7.28'
+VERSION = '12.8.11'
 
 
 CMD_LINE_SYNTAX = 'Packages/SublimeHg/Support/SublimeHg Command Line.hidden-tmLanguage'