Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

archive: set default archive name based on repo name & rev

Changeset 4f8676d8cd06

Parent 567a825b36da

by Yuki KODAMA

Changes to one file · Browse files at 4f8676d8cd06 Showing diff from parent 567a825b36da Diff from another changeset...

 
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
 
97
98
99
 
 
 
100
 
101
102
103
 
141
142
143
144
 
 
 
 
145
146
147
148
149
150
151
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
156
157
 
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
 
95
96
97
98
99
100
101
102
103
104
105
 
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
@@ -52,29 +52,27 @@
    ## revision combo   self.combo = gtk.combo_box_entry_new_text() - combo = self.combo - entry = combo.child - entry.set_width_chars(24) - entry.connect('activate', lambda b: self.response(gtk.RESPONSE_OK)) + self.combo.child.set_width_chars(24) + self.combo.child.connect('activate', + lambda b: self.response(gtk.RESPONSE_OK))   if rev: - combo.append_text(str(rev)) + self.combo.append_text(str(rev))   else: - combo.append_text(WD_PARENT) - combo.set_active(0) + self.combo.append_text(WD_PARENT) + self.combo.set_active(0)   for b in repo.branchtags(): - combo.append_text(b) + self.combo.append_text(b)   tags = list(repo.tags())   tags.sort()   tags.reverse()   for t in tags: - combo.append_text(t) + self.combo.append_text(t)   - table.add_row(_('Archive revision:'), combo) + table.add_row(_('Archive revision:'), self.combo)     ## dest combo & browse button   destcombo = gtk.combo_box_entry_new_text()   self.destentry = destcombo.get_child() - self.destentry.set_text(repo.root)   self.destentry.set_width_chars(46)     destbrowse = gtk.Button(_('Browse...')) @@ -97,7 +95,11 @@
  self.uzipradio = add_type(_('Uncompressed zip archive'))   self.zipradio = add_type(_('Zip archive compressed using deflate'))   + # register signal handlers + self.combo.connect('changed', lambda c: self.update_path()) +   # prepare to show + self.update_path(hglib.toutf(repo.root))   self.archivebtn.grab_focus()   gobject.idle_add(self.after_init)   @@ -141,17 +143,35 @@
  def type_changed(self, radio):   if not radio.get_active():   return - def remove_exts(path): + self.update_path() + + def update_path(self, path=None): + def remove_ext(path):   for ext in ('.tar', '.tar.bz2', '.tar.gz', '.zip'):   if path.endswith(ext):   return path.replace(ext, '')   return path - select = self.get_selected_archive_type() - path = self.destentry.get_text() - newpath = remove_exts(path) - if select['type'] != 'files': - newpath += select['ext'] - self.destentry.set_text(newpath) + def remove_rev(path): + model = self.combo.get_model() + for rev in ['_' + rev[0] for rev in model]: + if path.endswith(rev): + return path.replace(rev, '') + return path + def add_rev(path): + rev = self.combo.get_active_text() + return '%s_%s' % (path, rev) + def add_ext(path): + select = self.get_selected_archive_type() + if select['type'] != 'files': + path += select['ext'] + return path + if path is None: + path = self.destentry.get_text() + path = remove_ext(path) + path = remove_rev(path) + path = add_rev(path) + path = add_ext(path) + self.destentry.set_text(path)     def get_selected_archive_type(self):   """Return a dictionary describing the selected archive type"""