def setUp(self): # Set up commits to build self.commits = [] sequence = 0 for commit_info in commits: comm = commit.Commit(commit_info[0]) comm.subject = commit_info[1] comm.return_code = commit_info[2] comm.error_list = commit_info[3] comm.sequence = sequence sequence += 1 self.commits.append(comm) # Set up boards to build self.boards = board.Boards() for brd in boards: self.boards.AddBoard(board.Board(*brd)) self.boards.SelectBoards([]) # Add some test settings bsettings.Setup(None) bsettings.AddFile(settings_data) # Set up the toolchains self.toolchains = toolchain.Toolchains() self.toolchains.Add('arm-linux-gcc', test=False) self.toolchains.Add('sparc-linux-gcc', test=False) self.toolchains.Add('powerpc-linux-gcc', test=False) self.toolchains.Add('gcc', test=False) # Avoid sending any output terminal.SetPrintTestMode() self._col = terminal.Color()
def from_string(cls, repo, line): """ Create a new Head instance from the given string. ``repo`` is the Repo ``line`` is the formatted head information Format:: name: [a-zA-Z_/]+ <null byte> id: [0-9A-Fa-f]{40} Returns git.Head """ full_name, ids = line.split("\x00") if full_name.startswith('refs/heads/'): name = full_name[len('refs/heads/'):] else: name = full_name c = commit.Commit(repo, id=ids) return Head(name, c)
def setUp(self): # Set up commits to build self.commits = [] sequence = 0 for commit_info in commits: comm = commit.Commit(commit_info[0]) comm.subject = commit_info[1] comm.return_code = commit_info[2] comm.error_list = commit_info[3] comm.sequence = sequence sequence += 1 self.commits.append(comm) # Set up boards to build self.boards = board.Boards() for brd in boards: self.boards.AddBoard(board.Board(*brd)) self.boards.SelectBoards([]) # Set up the toolchains bsettings.Setup() self.toolchains = toolchain.Toolchains() self.toolchains.Add('arm-linux-gcc', test=False) self.toolchains.Add('sparc-linux-gcc', test=False) self.toolchains.Add('powerpc-linux-gcc', test=False) self.toolchains.Add('gcc', test=False)
def _update_diff(self): current_commit = commit.Commit(self._git, self._id) diff_text = current_commit.diff(self._diff_lines_count_edit.value()) self._diff_veiw.setPlainText(diff_text) self._files_list.clear() for file_name in current_commit.changed_files(): self._files_list.addItem(QtGui.QListWidgetItem(file_name))
def run_commit(self): sys.stdout = self ## sys.stderr = self try: del (sys.modules["commit"]) except: ## Yeah, it's a real ugly solution... pass import commit commit.Commit('initial Commit') sys.stdout = sys.__stdout__
def __init__(self, repo, a_path, b_path, a_commit, b_commit, a_mode, b_mode, new_file, deleted_file, rename_from, rename_to, diff): self.repo = repo self.a_path = a_path self.b_path = b_path if not a_commit or re.search(r'^0{40}$', a_commit): self.a_commit = None else: self.a_commit = commit.Commit(repo, id=a_commit) if not b_commit or re.search(r'^0{40}$', b_commit): self.b_commit = None else: self.b_commit = commit.Commit(repo, id=b_commit) self.a_mode = a_mode self.b_mode = b_mode self.new_file = new_file self.deleted_file = deleted_file self.rename_from = rename_from self.rename_to = rename_to self.renamed = rename_from != rename_to self.diff = diff
def __init__(self): self._options = {} #Add menu classes self._optionLookup = {} #Add/order your menu option here self._options = [ addSubproject.AddSubproject(), bundle.Bundle(), bundle.Unbundle(), branches.Branches(), status.Status(), stash.Stash(), checkout.Checkout(), push.Push(), pull.Pull(), commit.Commit(), publish.Publish(), clone.Clone(), config.Config(), grapeConfig.WriteConfig(), foreach.ForEach(), merge.Merge(), mergeDevelop.MergeDevelop(), mergeRemote.MergeRemote(), deleteBranch.DeleteBranch(), newWorkingTree.NewWorkingTree(), resolveConflicts.ResolveConflicts(), review.Review(), test.Test(), updateLocal.UpdateLocal(), updateSubproject.UpdateSubproject(), hooks.InstallHooks(), hooks.RunHook(), updateView.UpdateView(), version.Version(), walkthrough.Walkthrough(), quit.Quit() ] #Add/order the menu sections here self._sections = [ 'Getting Started', 'Code Reviews', 'Workspace', 'Merge', 'Gitflow Tasks', 'Hooks', 'Patches', 'Project Management', 'Other' ]
def _Logstring2Commit(self, str): """Create an instance of commit.Commit from a given log string. Must be implemented by every VCS. Turns a string from the list returned by getCommitIDsLL into a commit.Commit instance""" match = self.logPattern.search(str) if not (match): log.critical("_Logstring2Commit could not parse log string!") raise Error("_Logstring2Commit could not parse log string!") cmt = commit.Commit() cmt.cdate = match.group(1) cmt.id = match.group(2) cmt.adate = match.group(3) # This integer is not really a number, rather a representation of the # hour:minute offset to UTC. E.g. "+0200" becomes 200. To extract the # hourly offset, use integer division. cmt.adate_tz = int(match.group(4)) return cmt
def merge_for_upload(self, *args, **kwargs): current_head = self.rev_parse('HEAD') try: self.merge("--no-ff %s" % (" ".join(args)), **kwargs) except: raise else: new_head = self.rev_parse('HEAD') if not new_head == current_head: # New merge commit is created. commit_obj = commit.Commit(self, 'HEAD') change_id = commit_obj.change_id() if not change_id: # Ammend the commit message to insert the change-id commit_msg = commit_obj.get_commit_msg_only() with NamedTemporaryFile('w', delete=False) as tmp_file: tmp_file.write(commit_msg) tmp_file.close() tmp_file_name = tmp_file.name self.commit("--amend --reset-author -F %s" % tmp_file_name) os.remove(tmp_file_name)
def commites(self): result = [] for line in self.execute_command(["log", "--pretty=%H"], False): result.append(commit.Commit(self, line)) return result
def ProcessLine(self, line): """Process a single line of a patch file or commit log This process a line and returns a list of lines to output. The list may be empty or may contain multiple output lines. This is where all the complicated logic is located. The class's state is used to move between different states and detect things properly. We can be in one of two modes: self.is_log == True: This is 'git log' mode, where most output is indented by 4 characters and we are scanning for tags self.is_log == False: This is 'patch' mode, where we already have all the tags, and are processing patches to remove junk we don't want, and add things we think are required. Args: line: text line to process Returns: list of output lines, or [] if nothing should be output """ # Initially we have no output. Prepare the input line string out = [] line = line.rstrip('\n') commit_match = re_commit.match(line) if self.is_log else None if self.is_log: if line[:4] == ' ': line = line[4:] # Handle state transition and skipping blank lines series_tag_match = re_series_tag.match(line) change_id_match = re_change_id.match(line) commit_tag_match = re_commit_tag.match(line) cover_match = re_cover.match(line) cover_cc_match = re_cover_cc.match(line) signoff_match = re_signoff.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = re_tag.match(line) is_blank = not line.strip() if is_blank: if (self.state == STATE_MSG_HEADER or self.state == STATE_PATCH_SUBJECT): self.state += 1 # We don't have a subject in the text stream of patch files # It has its own line with a Subject: tag if not self.is_log and self.state == STATE_PATCH_SUBJECT: self.state += 1 elif commit_match: self.state = STATE_MSG_HEADER # If a tag is detected, or a new commit starts if series_tag_match or commit_tag_match or change_id_match or \ cover_match or cover_cc_match or signoff_match or \ self.state == STATE_MSG_HEADER: # but we are already in a section, this means 'END' is missing # for that section, fix it up. if self.in_section: self.warn.append("Missing 'END' in section '%s'" % self.in_section) if self.in_section == 'cover': self.series.cover = self.section elif self.in_section == 'notes': if self.is_log: self.series.notes += self.section elif self.in_section == 'commit-notes': if self.is_log: self.commit.notes += self.section else: self.warn.append("Unknown section '%s'" % self.in_section) self.in_section = None self.skip_blank = True self.section = [] # but we are already in a change list, that means a blank line # is missing, fix it up. if self.in_change: self.warn.append( "Missing 'blank line' in section 'Series-changes'") self.in_change = 0 # If we are in a section, keep collecting lines until we see END if self.in_section: if line == 'END': if self.in_section == 'cover': self.series.cover = self.section elif self.in_section == 'notes': if self.is_log: self.series.notes += self.section elif self.in_section == 'commit-notes': if self.is_log: self.commit.notes += self.section else: self.warn.append("Unknown section '%s'" % self.in_section) self.in_section = None self.skip_blank = True self.section = [] else: self.section.append(line) # Detect the commit subject elif not is_blank and self.state == STATE_PATCH_SUBJECT: self.commit.subject = line # Detect the tags we want to remove, and skip blank lines elif re_remove.match(line) and not commit_tag_match: self.skip_blank = True # TEST= should be the last thing in the commit, so remove # everything after it if line.startswith('TEST='): self.found_test = True elif self.skip_blank and is_blank: self.skip_blank = False # Detect the start of a cover letter section elif cover_match: self.in_section = 'cover' self.skip_blank = False elif cover_cc_match: value = cover_cc_match.group(1) self.AddToSeries(line, 'cover-cc', value) # If we are in a change list, key collected lines until a blank one elif self.in_change: if is_blank: # Blank line ends this change list self.in_change = 0 elif line == '---': self.in_change = 0 out = self.ProcessLine(line) else: if self.is_log: self.series.AddChange(self.in_change, self.commit, line) self.skip_blank = False # Detect Series-xxx tags elif series_tag_match: name = series_tag_match.group(1) value = series_tag_match.group(2) if name == 'changes': # value is the version number: e.g. 1, or 2 try: value = int(value) except ValueError as str: raise ValueError("%s: Cannot decode version info '%s'" % (self.commit.hash, line)) self.in_change = int(value) else: self.AddToSeries(line, name, value) self.skip_blank = True # Detect Change-Id tags elif change_id_match: value = change_id_match.group(1) if self.is_log: if self.commit.change_id: raise ValueError( "%s: Two Change-Ids: '%s' vs. '%s'" % (self.commit.hash, self.commit.change_id, value)) self.commit.change_id = value self.skip_blank = True # Detect Commit-xxx tags elif commit_tag_match: name = commit_tag_match.group(1) value = commit_tag_match.group(2) if name == 'notes': self.AddToCommit(line, name, value) self.skip_blank = True # Detect the start of a new commit elif commit_match: self.CloseCommit() self.commit = commit.Commit(commit_match.group(1)) # Detect tags in the commit message elif tag_match: # Remove Tested-by self, since few will take much notice if (tag_match.group(1) == 'Tested-by' and tag_match.group(2).find(os.getenv('USER') + '@') != -1): self.warn.append("Ignoring %s" % line) elif tag_match.group(1) == 'Patch-cc': self.commit.AddCc(tag_match.group(2).split(',')) else: out = [line] # Suppress duplicate signoffs elif signoff_match: if (self.is_log or not self.commit or self.commit.CheckDuplicateSignoff( signoff_match.group(1))): out = [line] # Well that means this is an ordinary line else: # Look for space before tab m = re_space_before_tab.match(line) if m: self.warn.append('Line %d/%d has space before tab' % (self.linenum, m.start())) # OK, we have a valid non-blank line out = [line] self.linenum += 1 self.skip_blank = False if self.state == STATE_DIFFS: pass # If this is the start of the diffs section, emit our tags and # change log elif line == '---': self.state = STATE_DIFFS # Output the tags (signeoff first), then change list out = [] log = self.series.MakeChangeLog(self.commit) out += [line] if self.commit: out += self.commit.notes out += [''] + log elif self.found_test: if not re_allowed_after_test.match(line): self.lines_after_test += 1 return out
def ProcessLine(self, line): """Process a single line of a patch file or commit log This process a line and returns a list of lines to output. The list may be empty or may contain multiple output lines. This is where all the complicated logic is located. The class's state is used to move between different states and detect things properly. We can be in one of two modes: self.is_log == True: This is 'git log' mode, where most output is indented by 4 characters and we are scanning for tags self.is_log == False: This is 'patch' mode, where we already have all the tags, and are processing patches to remove junk we don't want, and add things we think are required. Args: line: text line to process Returns: list of output lines, or [] if nothing should be output """ # Initially we have no output. Prepare the input line string out = [] line = line.rstrip('\n') if self.is_log: if line[:4] == ' ': line = line[4:] # Handle state transition and skipping blank lines series_match = re_series.match(line) commit_match = re_commit.match(line) if self.is_log else None tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = re_tag.match(line) is_blank = not line.strip() if is_blank: if (self.state == STATE_MSG_HEADER or self.state == STATE_PATCH_SUBJECT): self.state += 1 # We don't have a subject in the text stream of patch files # It has its own line with a Subject: tag if not self.is_log and self.state == STATE_PATCH_SUBJECT: self.state += 1 elif commit_match: self.state = STATE_MSG_HEADER # If we are in a section, keep collecting lines until we see END if self.in_section: if line == 'END': if self.in_section == 'cover': self.series.cover = self.section elif self.in_section == 'notes': if self.is_log: self.series.notes += self.section else: self.warn.append("Unknown section '%s'" % self.in_section) self.in_section = None self.skip_blank = True self.section = [] else: self.section.append(line) # Detect the commit subject elif not is_blank and self.state == STATE_PATCH_SUBJECT: self.commit.subject = line # Detect the tags we want to remove, and skip blank lines elif re_remove.match(line): self.skip_blank = True # TEST= should be the last thing in the commit, so remove # everything after it if line.startswith('TEST='): self.found_test = True elif self.skip_blank and is_blank: self.skip_blank = False # Detect the start of a cover letter section elif re_cover.match(line): self.in_section = 'cover' self.skip_blank = False # If we are in a change list, key collected lines until a blank one elif self.in_change: if is_blank: # Blank line ends this change list self.in_change = 0 else: self.series.AddChange(self.in_change, self.commit, line) self.skip_blank = False # Detect Series-xxx tags elif series_match: name = series_match.group(1) value = series_match.group(2) if name == 'changes': # value is the version number: e.g. 1, or 2 try: value = int(value) except ValueError as str: raise ValueError("%s: Cannot decode version info '%s'" % (self.commit.hash, line)) self.in_change = int(value) else: self.AddToSeries(line, name, value) self.skip_blank = True # Detect the start of a new commit elif commit_match: self.CloseCommit() self.commit = commit.Commit(commit_match.group(1)[:7]) # Detect tags in the commit message elif tag_match: # Onlly allow a single signoff tag if tag_match.group(1) == 'Signed-off-by': if self.signoff: self.warn.append('Patch has more than one Signed-off-by ' 'tag') self.signoff += [line] # Remove Tested-by self, since few will take much notice elif (tag_match.group(1) == 'Tested-by' and tag_match.group(2).find(os.getenv('USER') + '@') != -1): self.warn.append("Ignoring %s" % line) elif tag_match.group(1) == 'Cc': self.commit.AddCc(tag_match.group(2).split(',')) else: self.tags.append(line) # Well that means this is an ordinary line else: pos = 1 # Look for ugly ASCII characters for ch in line: # TODO: Would be nicer to report source filename and line if ord(ch) > 0x80: self.warn.append("Line %d/%d ('%s') has funny ascii char" % (self.linenum, pos, line)) pos += 1 # Look for space before tab m = re_space_before_tab.match(line) if m: self.warn.append('Line %d/%d has space before tab' % (self.linenum, m.start())) # OK, we have a valid non-blank line out = [line] self.linenum += 1 self.skip_blank = False if self.state == STATE_DIFFS: pass # If this is the start of the diffs section, emit our tags and # change log elif line == '---': self.state = STATE_DIFFS # Output the tags (signeoff first), then change list out = [] if self.signoff: out += self.signoff log = self.series.MakeChangeLog(self.commit) out += self.FormatTags(self.tags) out += [line] + log elif self.found_test: if not re_allowed_after_test.match(line): self.lines_after_test += 1 return out
def testBasic(self): """Test basic filter operation""" data = ''' From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001 From: Simon Glass <*****@*****.**> Date: Thu, 28 Apr 2011 09:58:51 -0700 Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support This adds functions to enable/disable clocks and reset to on-chip peripherals. cmd/pci.c:152:11: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘u64 {aka long unsigned int}’ [-Wformat=] BUG=chromium-os:13875 TEST=build U-Boot for Seaboard, boot Change-Id: I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413 Review URL: http://codereview.chromium.org/6900006 Signed-off-by: Simon Glass <*****@*****.**> --- arch/arm/cpu/armv7/tegra2/Makefile | 2 +- arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++---- arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++ ''' expected = '''Message-Id: <19991231235959.0.I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413@changeid> From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001 From: Simon Glass <*****@*****.**> Date: Thu, 28 Apr 2011 09:58:51 -0700 Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support This adds functions to enable/disable clocks and reset to on-chip peripherals. cmd/pci.c:152:11: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘u64 {aka long unsigned int}’ [-Wformat=] Signed-off-by: Simon Glass <*****@*****.**> --- arch/arm/cpu/armv7/tegra2/Makefile | 2 +- arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++---- arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++ ''' out = '' inhandle, inname = tempfile.mkstemp() infd = os.fdopen(inhandle, 'w', encoding='utf-8') infd.write(data) infd.close() exphandle, expname = tempfile.mkstemp() expfd = os.fdopen(exphandle, 'w', encoding='utf-8') expfd.write(expected) expfd.close() # Normally by the time we call FixPatch we've already collected # metadata. Here, we haven't, but at least fake up something. # Set the "count" to -1 which tells FixPatch to use a bogus/fixed # time for generating the Message-Id. com = commit.Commit('') com.change_id = 'I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413' com.count = -1 patchstream.FixPatch(None, inname, series.Series(), com) rc = os.system('diff -u %s %s' % (inname, expname)) self.assertEqual(rc, 0) os.remove(inname) os.remove(expname)
def set_old_message(self): id = self.sender().objectName() text = commit.Commit(self._git, id).full_name() self._commit_name_edit.setText(text.splitlines()[0]) self._commit_description_edit.setPlainText("\n".join( text.splitlines()[1:]))