Add checkout and cherry-pick to change list
Add the checkout and cherry-pick commands directly to the change list. This is motivated by a desire to be able to re-base and create patch series quickly directly from a list of changes. Change-Id: I22d3014673479db4381daad715b1c4ced3bcf340
This commit is contained in:
parent
7e162dd3c1
commit
110ee234d0
@ -528,6 +528,32 @@ class App(object):
|
||||
self.updateStatusQueries()
|
||||
return ret
|
||||
|
||||
def localCheckoutCommit(self, project_name, commit_sha):
|
||||
repo = self.getRepo(project_name)
|
||||
try:
|
||||
repo.checkout(commit_sha)
|
||||
dialog = mywid.MessageDialog('Checkout', 'Change checked out in %s' % repo.path)
|
||||
min_height=8
|
||||
except gitrepo.GitCheckoutError as e:
|
||||
dialog = mywid.MessageDialog('Error', e.msg)
|
||||
min_height=12
|
||||
urwid.connect_signal(dialog, 'close',
|
||||
lambda button: self.backScreen())
|
||||
self.popup(dialog, min_height=min_height)
|
||||
|
||||
def localCherryPickCommit(self, project_name, commit_sha):
|
||||
repo = self.getRepo(project_name)
|
||||
try:
|
||||
repo.cherryPick(commit_sha)
|
||||
dialog = mywid.MessageDialog('Cherry-Pick', 'Change cherry-picked in %s' % repo.path)
|
||||
min_height=8
|
||||
except gitrepo.GitCheckoutError as e:
|
||||
dialog = mywid.MessageDialog('Error', e.msg)
|
||||
min_height=12
|
||||
urwid.connect_signal(dialog, 'close',
|
||||
lambda button: self.backScreen())
|
||||
self.popup(dialog, min_height=min_height)
|
||||
|
||||
|
||||
def version():
|
||||
return "Gertty version: %s" % gertty.version.version_info.version_string()
|
||||
|
@ -310,30 +310,10 @@ class RevisionRow(urwid.WidgetWrap):
|
||||
self.change_view.diff(self.revision_key)
|
||||
|
||||
def checkout(self, button):
|
||||
repo = self.app.getRepo(self.project_name)
|
||||
try:
|
||||
repo.checkout(self.commit_sha)
|
||||
dialog = mywid.MessageDialog('Checkout', 'Change checked out in %s' % repo.path)
|
||||
min_height=8
|
||||
except gitrepo.GitCheckoutError as e:
|
||||
dialog = mywid.MessageDialog('Error', e.msg)
|
||||
min_height=12
|
||||
urwid.connect_signal(dialog, 'close',
|
||||
lambda button: self.app.backScreen())
|
||||
self.app.popup(dialog, min_height=min_height)
|
||||
self.app.localCheckoutCommit(self.project_name, self.commit_sha)
|
||||
|
||||
def cherryPick(self, button):
|
||||
repo = self.app.getRepo(self.project_name)
|
||||
try:
|
||||
repo.cherryPick(self.commit_sha)
|
||||
dialog = mywid.MessageDialog('Cherry-Pick', 'Change cherry-picked in %s' % repo.path)
|
||||
min_height=8
|
||||
except gitrepo.GitCheckoutError as e:
|
||||
dialog = mywid.MessageDialog('Error', e.msg)
|
||||
min_height=12
|
||||
urwid.connect_signal(dialog, 'close',
|
||||
lambda button: self.app.backScreen())
|
||||
self.app.popup(dialog, min_height=min_height)
|
||||
self.app.localCherryPickCommit(self.project_name, self.commit_sha)
|
||||
|
||||
class ChangeButton(mywid.FixedButton):
|
||||
button_left = urwid.Text(u' ')
|
||||
|
@ -108,6 +108,8 @@ class ChangeRow(urwid.Button):
|
||||
self.number.set_text(str(change.number))
|
||||
self.project.set_text(change.project.name.split('/')[-1])
|
||||
self.owner.set_text(change.owner_name)
|
||||
self.project_name = change.project.name
|
||||
self.commit_sha = change.revisions[-1].commit
|
||||
today = self.app.time(datetime.datetime.utcnow()).date()
|
||||
updated_time = self.app.time(change.updated)
|
||||
if today == updated_time.date():
|
||||
@ -158,6 +160,8 @@ class ChangeListView(urwid.WidgetWrap):
|
||||
return [
|
||||
(key(keymap.TOGGLE_HELD),
|
||||
"Toggle the held flag for the currently selected change"),
|
||||
(key(keymap.LOCAL_CHECKOUT),
|
||||
"Checkout the most recent revision of the selected change into the local repo"),
|
||||
(key(keymap.TOGGLE_HIDDEN),
|
||||
"Toggle the hidden flag for the currently selected change"),
|
||||
(key(keymap.TOGGLE_LIST_REVIEWED),
|
||||
@ -173,7 +177,9 @@ class ChangeListView(urwid.WidgetWrap):
|
||||
(key(keymap.SORT_BY_UPDATED),
|
||||
"Sort changes by how recently the change was updated"),
|
||||
(key(keymap.SORT_BY_REVERSE),
|
||||
"Reverse the sort")
|
||||
"Reverse the sort"),
|
||||
(key(keymap.LOCAL_CHERRY_PICK),
|
||||
"Cherry-pick the most recent revision of the selected change onto the local repo"),
|
||||
]
|
||||
|
||||
def __init__(self, app, query, query_desc=None, project_key=None,
|
||||
@ -480,6 +486,20 @@ class ChangeListView(urwid.WidgetWrap):
|
||||
self.clearChangeList()
|
||||
self.refresh()
|
||||
return None
|
||||
if keymap.LOCAL_CHECKOUT in commands:
|
||||
if not len(self.listbox.body):
|
||||
return None
|
||||
pos = self.listbox.focus_position
|
||||
row = self.listbox.body[pos]
|
||||
self.app.localCheckoutCommit(row.project_name, row.commit_sha)
|
||||
return None
|
||||
if keymap.LOCAL_CHERRY_PICK in commands:
|
||||
if not len(self.listbox.body):
|
||||
return None
|
||||
pos = self.listbox.focus_position
|
||||
row = self.listbox.body[pos]
|
||||
self.app.localCherryPickCommit(row.project_name, row.commit_sha)
|
||||
return None
|
||||
return key
|
||||
|
||||
def onSelect(self, button, change_key):
|
||||
|
Loading…
x
Reference in New Issue
Block a user