Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hggtk: remove obsolete files

Changeset 37b1f7742759

Parent cd0ea18a8a90

by Steve Borho

Changes to 6 files · Browse files at 37b1f7742759 Showing diff from parent cd0ea18a8a90 Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​addremove.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,50 +0,0 @@
-# -# Add/Remove dialog for TortoiseHg -# -# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com> -# - -try: - import pygtk - pygtk.require("2.0") -except: - pass - -import gtk -import gobject -from mercurial import ui, util, hg -from mercurial.i18n import _ -from status import GStatus - -def run(hgcmd='add', root='', cwd='', files=[], **opts): - u = ui.ui() - u.updateopts(debug=False, traceback=False) - repo = hg.repository(u, path=root) - - cmdoptions = { - 'all':False, 'clean':False, 'ignored':False, 'modified':False, - 'added':True, 'removed':True, 'deleted':True, 'unknown':False, 'rev':[], - 'exclude':[], 'include':[], 'debug':True,'verbose':True - } - - if hgcmd == 'add': - cmdoptions['unknown'] = True - elif hgcmd == 'remove': - cmdoptions['clean'] = True - else: - raise "Invalid command '%s'" % hgcmd - - dialog = GStatus(u, repo, cwd, files, cmdoptions, True) - - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - dialog.display() - gtk.main() - gtk.gdk.threads_leave() - -if __name__ == "__main__": - import sys - opts = {} - opts['hgcmd'] = 'adda' - opts['root'] = len(sys.argv) > 1 and sys.argv[1] or '' - run(**opts)
Change 1 of 1 Show Entire File hggtk/​diff.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,196 +0,0 @@
-#!/usr/bin/python -# -*- coding: UTF-8 -*- -"""Difference window. - -This module contains the code to manage the diff window which shows -the changes made between two revisions on a branch. -""" - -__copyright__ = "Copyright © 2005 Canonical Ltd." -__author__ = "Scott James Remnant <scott@ubuntu.com>" - -import gtk -import pango -import sys -from hglib import gettabwidth, RepoError -from mercurial import hg, ui, cmdutil, util, patch -from mercurial.i18n import _ -from shlib import set_tortoise_icon - -class NoSuchFile(Exception): - def __init__(self, filename): - self.filename = filename - -class DiffWindow(gtk.Window): - """Diff window. - - This object represents and manages a single window containing the - differences between two revisions on a branch. - """ - - def __init__(self): - gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) - set_tortoise_icon(self, 'menudiff.ico') - self.set_border_width(0) - self.set_title("diff") - - # Use two thirds of the screen by default - screen = self.get_screen() - monitor = screen.get_monitor_geometry(0) - width = int(monitor.width * 0.66) - height = int(monitor.height * 0.66) - self.set_default_size(width, height) - - self.construct() - - def construct(self): - """Construct the window contents.""" - # The window consists of a pane containing: the - # hierarchical list of files on the left, and the diff - # for the currently selected file on the right. - pane = gtk.HPaned() - self.add(pane) - pane.show() - - # The file hierarchy: a scrollable treeview - scrollwin = gtk.ScrolledWindow() - scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) - scrollwin.set_shadow_type(gtk.SHADOW_IN) - pane.pack1(scrollwin) - scrollwin.show() - - self.model = gtk.TreeStore(str, str) - self.treeview = gtk.TreeView(self.model) - self.treeview.set_headers_visible(False) - self.treeview.set_search_column(1) - self.treeview.connect("cursor-changed", self._treeview_cursor_cb) - scrollwin.add(self.treeview) - self.treeview.show() - - cell = gtk.CellRendererText() - cell.set_property("width-chars", 20) - column = gtk.TreeViewColumn() - column.pack_start(cell, expand=True) - column.add_attribute(cell, "text", 0) - self.treeview.append_column(column) - - # The diffs of the selected file: a scrollable source or - # text view - scrollwin = gtk.ScrolledWindow() - scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrollwin.set_shadow_type(gtk.SHADOW_IN) - pane.pack2(scrollwin) - scrollwin.show() - self.tabwidth = gettabwidth(self.ui) - - try: - import gtksourceview - self.buffer = gtksourceview.SourceBuffer() - slm = gtksourceview.SourceLanguagesManager() - gsl = slm.get_language_from_mime_type("text/x-patch") - self.buffer.set_language(gsl) - self.buffer.set_highlight(True) - - sourceview = gtksourceview.SourceView(self.buffer) - except ImportError: - self.buffer = gtk.TextBuffer() - sourceview = gtk.TextView(self.buffer) - - sourceview.set_editable(False) - sourceview.modify_font(pango.FontDescription("Monospace")) - scrollwin.add(sourceview) - sourceview.show() - - def set_diff(self, root='', files=[], description=''): - """Set the differences showed by this window. - - Compares the two trees and populates the window with the - differences. - """ - self.root = root - self.files = files - - # open Hg repo - self.ui = ui.ui() - try: - self.repo = hg.repository(self.ui, path=self.root) - except RepoError: - return None - - matcher = cmdutil.match(self.repo, self.files) - modified, added, removed = self.repo.status(match=matcher)[0:3] - self.files = matcher.files() - - self.model.clear() - self.model.append(None, [ "Complete Diff", "" ]) - - if len(added): - titer = self.model.append(None, [ "Added", None ]) - for path in added: - self.model.append(titer, [ path, path ]) - - if len(removed): - titer = self.model.append(None, [ "Removed", None ]) - for path in removed: - self.model.append(titer, [ path, path ]) - - if len(modified): - titer = self.model.append(None, [ "Modified", None ]) - for path in modified: - self.model.append(titer, [ path, path ]) - - self.treeview.expand_all() - self.set_title("TortoseHg diff - " + description) - - def set_file(self, file_path): - tv_path = None - for data in self.model: - for child in data.iterchildren(): - if child[0] == file_path or child[1] == file_path: - tv_path = child.path - break - if tv_path is None: - raise NoSuchFile(file_path) - self.treeview.set_cursor(tv_path) - self.treeview.scroll_to_cell(tv_path) - - def _treeview_cursor_cb(self, *args): - """Callback for when the treeview cursor changes.""" - (path, col) = self.treeview.get_cursor() - specific_files = [ self.model[path][1] ] - if specific_files == [ None ]: - return - elif specific_files == [ "" ]: - specific_files = self.files - - diff = self._get_hg_diff(specific_files) - diff = diff.decode(sys.getdefaultencoding(), 'replace') - if self.tabwidth: - diff = diff.expandtabs(self.tabwidth) - self.buffer.set_text(diff) - - def _get_hg_diff(self, files): - self.repo.ui.pushbuffer() - patch.diff(self.repo, files=files) - difflines = self.repo.ui.popbuffer() - return difflines - - def _set_as_window(self): - self.connect("destroy", gtk.main_quit) - - def _set_as_dialog(self, modal=False): - self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) - self.set_modal(modal) - -def run(root='', files=[], **opts): - diff = DiffWindow() - diff.set_diff(root, files) - diff._set_as_window() - diff.show() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() - -if __name__ == "__main__": - run(**{})
Change 1 of 1 Show Entire File hggtk/​gtools.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,203 +0,0 @@
-# gtools.py - Graphical diff and status extension for Mercurial -# -# Copyright 2007 Brad Schick, brad at gmail . com -# -# This software may be used and distributed according to the terms -# of the GNU General Public License, incorporated herein by reference. -# -"""gtools extension provides graphical status and commit dialogs - -The gtools extension provides gtk+ based graphical status, log, -and commit dialogs. Each dialogs provides a convenient way to see what -has changed in a repository. Data is displayed in a list that can be -sorted, selected, and double-clicked to launch diff and editor tools. -Right-click context menus and toolbars provide operations like commit, -add, view, delete, ignore, remove, revert, and refresh. - -Files are diff'ed and edited in place whenever possible, so you can -make changes within external tools and save them directly back to the -working copy. To enable gtools: - - [extensions] - hgext.gtools = - - [gtools] - # external diff tool and options - diffcmd = gdiff - diffopts = -Nprc5 - - # editor, if not specified [ui] editor is used - editor = scite - - # set the fonts for the comments, diffs, and lists - fontcomment = courier 10 - fontdiff = courier 10 - fontlist = courier 9 - - # make the integrated diff window appear at the bottom or side - diffbottom = False - -The external diff tool is run as shown below. Unless specified otherwise, -file_rev1 and file_rev2 are the parent revision and the working copy -respectively: - -diffcmd diffopts file_rev1 file_rev2 -""" - -import mercurial.demandimport; mercurial.demandimport.disable() - -import os - -import pygtk -pygtk.require('2.0') -import gtk - -from mercurial.i18n import _ -from mercurial.node import * -from mercurial import cmdutil, util, ui, hg, commands, patch - -def gcommit(ui, repo, *pats, **opts): - """graphical display for committing outstanding changes - - Displays a list of either all or specified files that can be committed - and provides a entry field for the commit message. If a list of - files is omitted, all changes reported by "hg status" will be - committed. - - Each file in the list can be double-clicked to launch a diff or editor - tool. Right-click context menus allow for single file operations. - """ - from commit import GCommit - dialog = GCommit(ui, repo, pats, opts, True) - run(dialog) - -def gstatus(ui, repo, *pats, **opts): - """graphical display of changed files in the working directory - - Displays the status of files in the repository. If names are given, - only files that match are shown. Clean and ignored files are not - shown by default, but the can be added from within the dialog or the - command-line (with -c, -i or -A) - - NOTE: status may appear to disagree with diff if permissions have - changed or a merge has occurred. The standard diff format does not - report permission changes and diff only reports changes relative - to one merge parent. - - If one revision is given, it is used as the base revision. - If two revisions are given, the difference between them is shown. - - The codes used to show the status of files are: - M = modified - A = added - R = removed - C = clean - ! = deleted, but still tracked - ? = not tracked - I = ignored - - Each file in the list can be double-clicked to launch a diff or editor - tool. Right-click context menus allow for single file operations. - """ - from status import GStatus - dialog = GStatus(ui, repo, pats, opts, True) - run(dialog) - -def glog(ui, repo, *pats, **opts): - """display revision history of entire repository or files - - Displays the revision history of the specified files or the entire - project. - - File history is shown without following rename or copy history of - files. Use -f/--follow with a file name to follow history across - renames and copies. --follow without a file name will only show - ancestors or descendants of the starting revision. --follow-first - only follows the first parent of merge revisions. - - If no revision range is specified, the default is tip:0 unless - --follow is set, in which case the working directory parent is - used as the starting revision. - - Each log entry in the list can be double-clicked to launch a status - view of that revision. Diff options like --git are passed to the - status view when a log entry is activated. - """ - from history import GLog - dialog = GLog(ui, repo, pats, opts, True) - run(dialog) - -def run(dialog): - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - dialog.display() - gtk.main() - gtk.gdk.threads_leave() - - -cmdtable = { -'gcommit|gci': -(gcommit, - [('A', 'addremove', None, _('skip prompt for marking new/missing files as added/removed')), - ('d', 'date', '', _('record datecode as commit date')), - ('u', 'user', '', _('record user as commiter')), - ('m', 'message', '', _('use <text> as commit message')), - ('l', 'logfile', '', _('read commit message from <file>')), - ('g', 'git', None, _('use git extended diff format')), - ('c', 'check', False, _('automatically check commitable files'))] + commands.walkopts, - _('hg gcommit [OPTION]... [FILE]...')), -'gstatus|gst': -(gstatus, - [('A', 'all', None, _('show status of all files')), - ('m', 'modified', None, _('show only modified files')), - ('a', 'added', None, _('show only added files')), - ('r', 'removed', None, _('show only removed files')), - ('d', 'deleted', None, _('show only deleted (but tracked) files')), - ('c', 'clean', None, _('show only files without changes')), - ('u', 'unknown', None, _('show only unknown (not tracked) files')), - ('i', 'ignored', None, _('show only ignored files')), - ('', 'rev', [], _('show difference from revision')), - ('g', 'git', None, _('use git extended diff format')), - ('c', 'check', False, _('automatically check displayed files'))] + commands.walkopts, - _('hg gstat [OPTION]... [FILE]...')), -'glog|ghistory': -(glog, - [('f', 'follow', None, - _('follow changeset history, or file history across copies and renames')), - ('', 'follow-first', None, - _('only follow the first parent of merge changesets')), - ('d', 'date', '', _('show revs matching date spec')), - ('C', 'copies', None, _('show copied files')), - ('k', 'keyword', [], _('do case-insensitive search for a keyword')), - ('l', 'limit', '', _('limit number of changes displayed')), - ('r', 'rev', [], _('show the specified revision or range')), - ('', 'removed', None, _('include revs where files were removed')), - ('M', 'no-merges', None, _('do not show merges')), - ('m', 'only-merges', None, _('show only merges')), - ('P', 'prune', [], _('do not display revision or any of its ancestors')), - ('g', 'git', None, _('use git extended diff format'))] + commands.walkopts, -_('hg glog [OPTION]... [FILE]')), -} - -def findrepo(): - p = os.getcwd() - while not os.path.isdir(os.path.join(p, '.hg')): - oldp, p = p, os.path.dirname(p) - if p == oldp: - return None - return p - -if __name__ == '__main__': - u = ui.ui() - u.updateopts(debug=False, traceback=False) - repo = hg.repository(u, findrepo()) - gstatus(u, repo, all=False, clean=False, ignored=False, modified=True, - added=True, removed=True, deleted=True, unknown=True, rev=[], - exclude=[], include=[], debug=True, - verbose=True ) -# logparams = {'follow_first': None, 'style': '', 'include': [], 'verbose': True, -# 'only_merges': None, 'keyword': [], 'rev': [], 'copies': None, 'template': '', -# 'patch': None, 'limit': 20, 'no_merges': None, 'exclude': [], 'date': '', -# 'follow': None, 'removed': None, 'prune': [], 'verbose':True } -# glog(u, repo, **logparams ) -
Change 1 of 1 Show Entire File hggtk/​revisions.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,149 +0,0 @@
-# -# revision dialog for TortoiseHg dialogs -# -# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com> -# - -try: - import pygtk - pygtk.require("2.0") -except: - pass - -import gtk -from mercurial import hg, ui, cmdutil, util -from mercurial.i18n import _ -from mercurial.node import * -from dialog import error_dialog, question_dialog -from revtree import RevisionTree -from shlib import set_tortoise_icon -from hglib import RepoError - -class RevisionDialog(gtk.Dialog): - def __init__(self, root=''): - """ Initialize the Dialog. """ - gtk.Dialog.__init__(self, title="TortoiseHg Revisions - %s" % root, - parent=None, - flags=0, - buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) - - set_tortoise_icon(self, 'menurepobrowse.ico') - self.root = root - self.connect('response', gtk.main_quit) - - self._button_refresh = gtk.Button(_("Refresh")) - self._button_refresh.connect('clicked', self._button_refresh_clicked) - self._button_refresh.set_flags(gtk.CAN_DEFAULT) - self.action_area.pack_end(self._button_refresh) - - # Create a new notebook, place the position of the tabs - self.notebook = notebook = gtk.Notebook() - notebook.set_tab_pos(gtk.POS_TOP) - self.vbox.pack_start(notebook) - notebook.show() - self.show_tabs = True - self.show_border = True - - # create pages for each type of revision info - self.pages = [] - self.tip_tree = self.add_page(notebook, 'Tip') - self.parents_tree = self.add_page(notebook, 'Parents') - self.heads_tree = self.add_page(notebook, 'Heads') - - self.vbox.show_all() - - # populate revision data - self._get_revisions() - - def add_page(self, notebook, tab): - self.pages.append(tab) - - frame = gtk.Frame() - frame.set_border_width(10) - frame.set_size_request(500, 250) - frame.show() - - tree = RevisionTree() - frame.add(tree) - - label = gtk.Label(tab) - notebook.append_page(frame, label) - - return tree - - def select_page(self, name): - try: - # do case-insentive search on page name - lpages = [x.lower() for x in self.pages] - page_num = lpages.index(name.lower()) - - # show select page - self.notebook.set_current_page(page_num) - except: - pass - - def _button_refresh_clicked(self, button): - """ Refresh button clicked handler. """ - self._get_revisions() - print "refreshed" - - def _get_revisions(self): - """ retrieve repo revisions """ - u = ui.ui() - try: - repo = hg.repository(u, path=self.root) - except RepoError: - return None - self.repo = repo - - text = self.tip(repo) - self.tip_tree.set_history(_(text)) - text = self.parents(repo) - self.parents_tree.set_history(_(text)) - text = self.heads(repo) - self.heads_tree.set_history(_(text)) - - def tip(self, repo): - """ Show the tip revision """ - repo.ui.pushbuffer() - cmdutil.show_changeset(repo.ui, repo, {}).show(nullrev+len(repo.changelog)) - text = repo.ui.popbuffer() - return text - - def parents(self, repo): - """ Show the parent revisions """ - p = repo.dirstate.parents() - repo.ui.pushbuffer() - displayer = cmdutil.show_changeset(repo.ui, repo, {}) - for n in p: - if n != nullid: - displayer.show(changenode=n) - text = repo.ui.popbuffer() - return text - - def heads(self, repo): - """ Show the head revisions """ - heads = repo.heads() - repo.ui.pushbuffer() - displayer = cmdutil.show_changeset(repo.ui, repo, {}) - for n in heads: - displayer.show(changenode=n) - text = repo.ui.popbuffer() - return text - -def run(root='', hgcmd='', **opts): - dialog = RevisionDialog(root) - if hgcmd: - dialog.select_page(hgcmd) - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() - -if __name__ == "__main__": - import sys - opts = {} - opts['root'] = len(sys.argv) > 1 and sys.argv[1] or '' - opts['hgcmd'] = 'tip' - run(**opts)
Change 1 of 1 Show Entire File hggtk/​revtree.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,133 +0,0 @@
-# -# revtree.py - a revision tree widget class for TortoiseHg -# -# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com> -# - -import pygtk -pygtk.require("2.0") - -import gtk - -class RevisionTree(gtk.ScrolledWindow): - def __init__(self, log=''): - super(gtk.ScrolledWindow, self).__init__() - self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self.treeview = gtk.TreeView() - self._create_treestore() - self.add(self.treeview) - if log: self.set_history(log) - - self.show_all() - - def _create_treestore(self): - """ create history display """ - - # add treeview to list change files - self.model = gtk.TreeStore(str, str) - self.treeview.connect("cursor-changed", self._cursor_changed) - #self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) - self.treeview.set_headers_visible(False) - self.treeview.set_model(self.model) - - cell = gtk.CellRendererText() - - column = gtk.TreeViewColumn() - column.pack_start(cell, expand=True) - column.add_attribute(cell, "text", 0) - self.treeview.append_column(column) - - column = gtk.TreeViewColumn() - column.pack_start(cell, expand=True) - column.add_attribute(cell, "text", 1) - self.treeview.append_column(column) - - def set_history(self, log): - self.history = self._parse_history(log) - self._update_tree() - - def _parse_history(self, log): - """ conver hg log output into list of revision structures """ - import re - histlist = [] - cs = {} - for x in log.splitlines(): - if x == "": - if cs: - histlist.append(cs) - cs = {} - else: - name, value = re.split(':\s+', x, 1) - if name not in cs: - cs[name] = [] - cs[name].append(value) - if cs: - histlist.append(cs) - - return histlist - - def _update_tree(self): - # clear changed files display - self.model.clear() - - # display history - for cs in self.history: - titer = self.model.append(None, [ 'changeset:', cs['changeset'][0] ]) - for fld in ('parent', 'tag', 'branch', 'user', 'date', 'summary'): - if fld not in cs: - continue - vlist = type(cs[fld])==type([]) and cs[fld] or [cs[fld]] - for v in vlist: - self.model.append(titer, [ fld + ":", v ]) - - self.treeview.expand_all() - - def _cursor_changed(self, tv): - model, selpaths = tv.get_selection().get_selected_rows() - if not selpaths: return - cs = model[selpaths[0]][1] - rev, csid = cs.split(':') - self.selected = (rev, csid) - - def get_revision(self, index): - import string - try: - cs = self.history[index] - revpair = cs['changeset'][0] - revnum, csid = revpair.split(':') - return string.atoi(revnum), csid - except: - return None - -# sample hg log output for testing purpose -testlog ="""\ -changeset: 218:72299521b0e9 -tag: tip -user: TK Soh <teekaysoh@yahoo.com> -date: Sun Jun 17 12:33:58 2007 -0500 -summary: hgproc: use new gtk dialog for merge command -""" - -# simple dialog for testing RevisionTree class -class TestDialog(gtk.Dialog): - def __init__(self, root='', log=''): - """ Initialize the Dialog """ - buttons = (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) - super(TestDialog, self).__init__(flags=gtk.DIALOG_MODAL, - buttons=buttons) - - self.set_default_size(500, 300) - - self.root = root - self.revtree = RevisionTree() - self.vbox.pack_start(self.revtree) - self.vbox.show_all() - self.revtree.set_history(testlog) - -def test(root=''): - dialog = TestDialog(root=root) - dialog.run() - return - -if __name__ == "__main__": - test()
Change 1 of 1 Show Entire File hggtk/​tags.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,125 +0,0 @@
-# -# tags dialog for TortoiseHg -# -# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com> -# - -try: - import pygtk - pygtk.require("2.0") -except: - pass - -import gtk -import gobject -from mercurial import hg, ui, cmdutil, util, node -from mercurial.i18n import _ -from hglib import RepoError, LookupError - -def get_tag_list(path): - root = path - u = ui.ui() - try: - repo = hg.repository(u, path=root) - except RepoError: - return None - - l = repo.tagslist() - l.reverse() - hexfunc = node.hex - taglist = [] - for t, n in l: - try: - hn = hexfunc(n) - r, c = repo.changelog.rev(n), hexfunc(n) - except LookupError: - r, c = "?", hn - - taglist.append((t, r, c)) - - return taglist - -class TagsDialog(gtk.Dialog): - """ TortoiseHg dialog to add/remove files """ - def __init__(self, root='', select=False): - if select: - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, - gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) - else: - buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) - super(TagsDialog, self).__init__(flags=gtk.DIALOG_MODAL, - buttons=buttons) - - self.root = root - - # set dialog title - title = "hg tags " - if root: title += " - %s" % root - self.set_title(title) - - # build dialog - self.set_default_size(500, 300) - scrolledwindow = gtk.ScrolledWindow() - scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self._treeview = gtk.TreeView() - self._treeview.connect("cursor-changed", self._get_selected_tag) - scrolledwindow.add(self._treeview) - self._create_file_view() - self.vbox.pack_start(scrolledwindow, True, True) - self.vbox.show_all() - - # Generate status output - self._get_tags() - - def _create_file_view(self): - self._file_store = gtk.ListStore( - gobject.TYPE_STRING, # tag name - gobject.TYPE_STRING, # revision - gobject.TYPE_STRING, # cset id - ) - self._treeview.set_model(self._file_store) - self._treeview.append_column(gtk.TreeViewColumn(_('Tag'), - gtk.CellRendererText(), text=0)) - self._treeview.append_column(gtk.TreeViewColumn(_('Revision'), - gtk.CellRendererText(), text=1)) - self._treeview.append_column(gtk.TreeViewColumn(_('ID'), - gtk.CellRendererText(), text=2)) - - def _get_tags(self): - """ Generate 'hg status' output. """ - tags = get_tag_list(self.root) - - for t, r, c in tags: - self._file_store.append([ t, r, c ]) - self._treeview.expand_all() - - def _get_selected_tag(self, tv): - treeselection = tv.get_selection() - model, paths = treeselection.get_selected_rows() - if paths: - self.selected = model[paths[0]][0] - -def run(root='', **opts): - dialog = TagsDialog(root=root) - - # the dialog maybe called by another window/dialog, so we only - # enable the close dialog handler if dialog is run as mainapp - dialog.connect('response', gtk.main_quit) - - dialog.show_all() - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() - gtk.gdk.threads_leave() - -def select(root=''): - dialog = TagsDialog(root=root, select=True) - resp = dialog.run() - rev = None - if resp == gtk.RESPONSE_ACCEPT: - rev = dialog.selected - dialog.hide() - return rev - -if __name__ == "__main__": - run(**{})