diff options
author | Erwan Mahe <erwan.mahe@intel.com> | 2011-08-19 13:56:09 +0200 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2012-05-24 09:03:10 -0700 |
commit | a94f162b9fe85389f3e1c9555628d9229105e15d (patch) | |
tree | da3852d6ede787a8d1974cddab3db8c98e4fc39e | |
parent | e5a2122e6429b5eee861807e7050eb02045a7d4f (diff) | |
download | git-repo-a94f162b9fe85389f3e1c9555628d9229105e15d.tar.gz |
repo download: add --revert option
BZ: 4779
Allows to revert a gerrit patch
This patch is necessary for the on-demand creation of
engineering builds using buildbot
You can now use:
repo download [--revert|-r project changeid/patchnumber
This is useful to automate reverting of a patch
in the context of build automation, and regression bisection
Change-Id: I3985e80e4b2a230f83526191ea1379765a54bdcf
Signed-off-by: Erwan Mahe <erwan.mahe@intel.com>
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
-rw-r--r-- | project.py | 9 | ||||
-rw-r--r-- | subcmds/download.py | 7 |
2 files changed, 15 insertions, 1 deletions
@@ -1645,6 +1645,15 @@ class Project(object): | |||
1645 | if self._allrefs: | 1645 | if self._allrefs: |
1646 | raise GitError('%s cherry-pick %s ' % (self.name, rev)) | 1646 | raise GitError('%s cherry-pick %s ' % (self.name, rev)) |
1647 | 1647 | ||
1648 | def _Revert(self, rev, quiet=False): | ||
1649 | cmd = ['revert'] | ||
1650 | cmd.append('--no-edit') | ||
1651 | cmd.append(rev) | ||
1652 | cmd.append('--') | ||
1653 | if GitCommand(self, cmd).Wait() != 0: | ||
1654 | if self._allrefs: | ||
1655 | raise GitError('%s revert %s ' % (self.name, rev)) | ||
1656 | |||
1648 | def _ResetHard(self, rev, quiet=True): | 1657 | def _ResetHard(self, rev, quiet=True): |
1649 | cmd = ['reset', '--hard'] | 1658 | cmd = ['reset', '--hard'] |
1650 | if quiet: | 1659 | if quiet: |
diff --git a/subcmds/download.py b/subcmds/download.py index 79d0192d..f79f485b 100644 --- a/subcmds/download.py +++ b/subcmds/download.py | |||
@@ -36,6 +36,9 @@ makes it available in your project's local working directory. | |||
36 | p.add_option('-c','--cherry-pick', | 36 | p.add_option('-c','--cherry-pick', |
37 | dest='cherrypick', action='store_true', | 37 | dest='cherrypick', action='store_true', |
38 | help="cherry-pick instead of checkout") | 38 | help="cherry-pick instead of checkout") |
39 | p.add_option('-r','--revert', | ||
40 | dest='revert', action='store_true', | ||
41 | help="revert instead of checkout") | ||
39 | 42 | ||
40 | def _ParseChangeIds(self, args): | 43 | def _ParseChangeIds(self, args): |
41 | if not args: | 44 | if not args: |
@@ -68,7 +71,7 @@ makes it available in your project's local working directory. | |||
68 | % (project.name, change_id, ps_id) | 71 | % (project.name, change_id, ps_id) |
69 | sys.exit(1) | 72 | sys.exit(1) |
70 | 73 | ||
71 | if not dl.commits: | 74 | if not opt.revert and not dl.commits: |
72 | print >>sys.stderr, \ | 75 | print >>sys.stderr, \ |
73 | '[%s] change %d/%d has already been merged' \ | 76 | '[%s] change %d/%d has already been merged' \ |
74 | % (project.name, change_id, ps_id) | 77 | % (project.name, change_id, ps_id) |
@@ -82,5 +85,7 @@ makes it available in your project's local working directory. | |||
82 | print >>sys.stderr, ' %s' % (c) | 85 | print >>sys.stderr, ' %s' % (c) |
83 | if opt.cherrypick: | 86 | if opt.cherrypick: |
84 | project._CherryPick(dl.commit) | 87 | project._CherryPick(dl.commit) |
88 | elif opt.revert: | ||
89 | project._Revert(dl.commit) | ||
85 | else: | 90 | else: |
86 | project._Checkout(dl.commit) | 91 | project._Checkout(dl.commit) |