* src/GrampsDb/_GrampsDBDir.py: revision control check in
* src/DbManager.py: revision control check in * src/glade/gramps.glade: revision control check in 2007-06-18 Don Allingham <don@gramps-project.org> svn: r8588
This commit is contained in:
parent
09d956ad4c
commit
3ec91e149b
@ -1,3 +1,8 @@
|
|||||||
|
2007-06-18 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/GrampsDb/_GrampsDBDir.py: revision control check in
|
||||||
|
* src/DbManager.py: revision control check in
|
||||||
|
* src/glade/gramps.glade: revision control check in
|
||||||
|
|
||||||
2007-06-18 Don Allingham <don@gramps-project.org>
|
2007-06-18 Don Allingham <don@gramps-project.org>
|
||||||
* src/DbManager.py: check for revisions
|
* src/DbManager.py: check for revisions
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ __revision__ = "$Revision: 8197 $"
|
|||||||
import const
|
import const
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import subprocess
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -108,6 +109,7 @@ class DbManager:
|
|||||||
self.dblist = self.glade.get_widget('dblist')
|
self.dblist = self.glade.get_widget('dblist')
|
||||||
self.rename = self.glade.get_widget('rename')
|
self.rename = self.glade.get_widget('rename')
|
||||||
self.repair = self.glade.get_widget('repair')
|
self.repair = self.glade.get_widget('repair')
|
||||||
|
self.rcs = self.glade.get_widget('rcs')
|
||||||
self.msg = self.glade.get_widget('msg')
|
self.msg = self.glade.get_widget('msg')
|
||||||
self.model = None
|
self.model = None
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
@ -135,6 +137,8 @@ class DbManager:
|
|||||||
self.new.connect('clicked', self.__new_db)
|
self.new.connect('clicked', self.__new_db)
|
||||||
self.rename.connect('clicked', self.__rename_db)
|
self.rename.connect('clicked', self.__rename_db)
|
||||||
self.repair.connect('clicked', self.__repair_db)
|
self.repair.connect('clicked', self.__repair_db)
|
||||||
|
if _rcs_found:
|
||||||
|
self.rcs.connect('clicked', self.__rcs)
|
||||||
self.selection.connect('changed', self.__selection_changed)
|
self.selection.connect('changed', self.__selection_changed)
|
||||||
self.dblist.connect('button-press-event', self.__button_press)
|
self.dblist.connect('button-press-event', self.__button_press)
|
||||||
|
|
||||||
@ -167,13 +171,28 @@ class DbManager:
|
|||||||
if not node:
|
if not node:
|
||||||
self.connect.set_sensitive(False)
|
self.connect.set_sensitive(False)
|
||||||
self.rename.set_sensitive(False)
|
self.rename.set_sensitive(False)
|
||||||
|
self.rcs.hide()
|
||||||
self.repair.hide()
|
self.repair.hide()
|
||||||
self.remove.set_sensitive(False)
|
self.remove.set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
is_rev = len(self.model.get_path(node)) > 1
|
||||||
|
|
||||||
|
if is_rev:
|
||||||
|
self.rcs.set_label(_("Check out"))
|
||||||
|
else:
|
||||||
|
self.rcs.set_label(_("Check in"))
|
||||||
|
|
||||||
if store.get_value(node, OPEN_COL):
|
if store.get_value(node, OPEN_COL):
|
||||||
self.connect.set_sensitive(False)
|
self.connect.set_sensitive(False)
|
||||||
|
if _rcs_found:
|
||||||
|
self.rcs.show()
|
||||||
else:
|
else:
|
||||||
self.connect.set_sensitive(True)
|
self.connect.set_sensitive(not is_rev)
|
||||||
|
if _rcs_found and is_rev:
|
||||||
|
self.rcs.show()
|
||||||
|
else:
|
||||||
|
self.rcs.hide()
|
||||||
self.rename.set_sensitive(True)
|
self.rename.set_sensitive(True)
|
||||||
if store.get_value(node, STOCK_COL) == gtk.STOCK_DIALOG_ERROR:
|
if store.get_value(node, STOCK_COL) == gtk.STOCK_DIALOG_ERROR:
|
||||||
path = store.get_value(node, PATH_COL)
|
path = store.get_value(node, PATH_COL)
|
||||||
@ -202,11 +221,6 @@ class DbManager:
|
|||||||
The last modified column simply displays the last modification time.
|
The last modified column simply displays the last modification time.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# build the icon column
|
|
||||||
render = gtk.CellRendererPixbuf()
|
|
||||||
icon_column = gtk.TreeViewColumn('', render, stock_id=STOCK_COL)
|
|
||||||
self.dblist.append_column(icon_column)
|
|
||||||
|
|
||||||
# build the database name column
|
# build the database name column
|
||||||
render = gtk.CellRendererText()
|
render = gtk.CellRendererText()
|
||||||
render.set_property('editable', True)
|
render.set_property('editable', True)
|
||||||
@ -216,6 +230,12 @@ class DbManager:
|
|||||||
self.column.set_sort_column_id(NAME_COL)
|
self.column.set_sort_column_id(NAME_COL)
|
||||||
self.dblist.append_column(self.column)
|
self.dblist.append_column(self.column)
|
||||||
|
|
||||||
|
# build the icon column
|
||||||
|
render = gtk.CellRendererPixbuf()
|
||||||
|
icon_column = gtk.TreeViewColumn(_('Status'), render,
|
||||||
|
stock_id=STOCK_COL)
|
||||||
|
self.dblist.append_column(icon_column)
|
||||||
|
|
||||||
# build the last modified cocolumn
|
# build the last modified cocolumn
|
||||||
render = gtk.CellRendererText()
|
render = gtk.CellRendererText()
|
||||||
column = gtk.TreeViewColumn(_('Last modified'), render, text=DATE_COL)
|
column = gtk.TreeViewColumn(_('Last modified'), render, text=DATE_COL)
|
||||||
@ -272,7 +292,7 @@ class DbManager:
|
|||||||
items[4], items[5], items[6]]
|
items[4], items[5], items[6]]
|
||||||
iter = self.model.append(None, data)
|
iter = self.model.append(None, data)
|
||||||
for rdata in find_revisions(os.path.join(items[1], "rev.gramps,v")):
|
for rdata in find_revisions(os.path.join(items[1], "rev.gramps,v")):
|
||||||
data = [rdata[0], "", "", rdata[1], 0, False, "" ]
|
data = [rdata[0], "", "", "", 0, False, "" ]
|
||||||
self.model.append(iter, data)
|
self.model.append(iter, data)
|
||||||
self.dblist.set_model(self.model)
|
self.dblist.set_model(self.model)
|
||||||
|
|
||||||
@ -312,6 +332,12 @@ class DbManager:
|
|||||||
_("Could not rename family tree"),
|
_("Could not rename family tree"),
|
||||||
str(msg))
|
str(msg))
|
||||||
|
|
||||||
|
def __rcs(self, obj):
|
||||||
|
store, node = self.selection.get_selected()
|
||||||
|
check_in(self.dbstate.db,
|
||||||
|
os.path.join(self.dbstate.db.get_save_path(), "rev.gramps"),
|
||||||
|
None)
|
||||||
|
|
||||||
def __remove_db(self, obj):
|
def __remove_db(self, obj):
|
||||||
"""
|
"""
|
||||||
Callback associated with the Remove button. Get the selected
|
Callback associated with the Remove button. Get the selected
|
||||||
@ -425,8 +451,8 @@ class DbManager:
|
|||||||
name_file.close()
|
name_file.close()
|
||||||
|
|
||||||
self.current_names.append(title)
|
self.current_names.append(title)
|
||||||
node = self.model.append([title, new_path, path_name,
|
node = self.model.append(None, [title, new_path, path_name,
|
||||||
_("Never"), 0, False, ''])
|
_("Never"), 0, False, ''])
|
||||||
self.selection.select_iter(node)
|
self.selection.select_iter(node)
|
||||||
|
|
||||||
path = self.model.get_path(node)
|
path = self.model.get_path(node)
|
||||||
@ -489,10 +515,13 @@ def icon_values(dirpath, active, open):
|
|||||||
|
|
||||||
def find_revisions(name):
|
def find_revisions(name):
|
||||||
import re
|
import re
|
||||||
import subprocess
|
|
||||||
|
|
||||||
rev = re.compile("\s*revision\s+([\d\.]+)")
|
rev = re.compile("\s*revision\s+([\d\.]+)")
|
||||||
date = re.compile("\s*date:\s+([^;]+);")
|
date = re.compile("\s*date:\s+([^;]+);")
|
||||||
|
|
||||||
|
if not os.path.isfile(name):
|
||||||
|
return []
|
||||||
|
|
||||||
rlog = [ "rlog" , name ]
|
rlog = [ "rlog" , name ]
|
||||||
|
|
||||||
proc = subprocess.Popen(rlog, stdout = subprocess.PIPE)
|
proc = subprocess.Popen(rlog, stdout = subprocess.PIPE)
|
||||||
@ -514,3 +543,30 @@ def find_revisions(name):
|
|||||||
revlist.append((rev_str, date_str))
|
revlist.append((rev_str, date_str))
|
||||||
|
|
||||||
return revlist
|
return revlist
|
||||||
|
|
||||||
|
def check_in(db, filename, callback):
|
||||||
|
init = [ "rcs", '-i', '-U', '-q', '-t'"GRAMPS database", ]
|
||||||
|
ci = [ "ci", '-m"update"', "-q" ]
|
||||||
|
|
||||||
|
proc = subprocess.Popen(init + [filename + ",v"], stderr = subprocess.PIPE)
|
||||||
|
status = proc.wait()
|
||||||
|
message = "\n".join(proc.stderr.readlines())
|
||||||
|
proc.stderr.close()
|
||||||
|
del proc
|
||||||
|
|
||||||
|
xmlwrite = GrampsDbUtils.XmlWriter(db, callback,
|
||||||
|
False, False)
|
||||||
|
xmlwrite.write(filename)
|
||||||
|
|
||||||
|
cmd = ci + [filename]
|
||||||
|
|
||||||
|
proc = subprocess.Popen(
|
||||||
|
cmd,
|
||||||
|
stdin = subprocess.PIPE,
|
||||||
|
stderr = subprocess.PIPE )
|
||||||
|
proc.stdin.write("comment")
|
||||||
|
proc.stdin.close()
|
||||||
|
message = "\n".join(proc.stderr.readlines())
|
||||||
|
proc.stderr.close()
|
||||||
|
status = proc.wait()
|
||||||
|
del proc
|
||||||
|
@ -449,7 +449,7 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
|||||||
for base in [ FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, EVENTS_TBL,
|
for base in [ FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, EVENTS_TBL,
|
||||||
PERSON_TBL, REPO_TBL, NOTE_TBL, REF_MAP, META ]:
|
PERSON_TBL, REPO_TBL, NOTE_TBL, REF_MAP, META ]:
|
||||||
path = os.path.join(name, base + ".db")
|
path = os.path.join(name, base + ".db")
|
||||||
if not os.access(path, os.W_OK):
|
if os.path.isfile(path) and not os.access(path, os.W_OK):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -15758,6 +15758,17 @@ Very High</property>
|
|||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="rcs">
|
||||||
|
<property name="can_default">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label" translatable="yes">Check In</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
<property name="focus_on_click">True</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user