From: Joseph Reagle Date: Tue, 1 Feb 2011 15:59:25 +0000 (-0500) Subject: Fixes a bug, a performance issue, and use 'M' instead of 'U' to be consistent with... X-Git-Url: https://projects.mako.cc/source/mw/commitdiff_plain/9c86686c71b075082be6d3870266cd929ad67b89?ds=sidebyside Fixes a bug, a performance issue, and use 'M' instead of 'U' to be consistent with version control systems --- diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index 03c5581..b0fb8bc 100644 --- a/src/mw/clicommands.py +++ b/src/mw/clicommands.py @@ -210,7 +210,7 @@ class DiffCommand(CommandBase): self._die_if_no_init() status = self.metadir.working_dir_status() for file in status: - if status[file] == 'U': + if status[file] == 'M': print self.metadir.diff_rv_to_working( mw.metadir.filename_to_pagename(file[:-5])), @@ -236,7 +236,7 @@ class CommitCommand(CommandBase): nothing_to_commit = True for file in status: print '%s %s' % (status[file], file) - if status[file] in ['U']: + if status[file] in ['M']: nothing_to_commit = False if nothing_to_commit: print 'nothing to commit' @@ -246,8 +246,8 @@ class CommitCommand(CommandBase): edit_summary = raw_input() else: edit_summary = self.options.edit_summary - for file in status: - if status[file] in ['U']: + for file_num, file in enumerate(status): + if status[file] in ['M']: # get edit token data = { 'action': 'query', @@ -265,7 +265,7 @@ class CommitCommand(CommandBase): print 'warning: edit conflict detected on %s (%s -> %s) ' \ '-- skipping!' % (file, awaitedrevid, revid) continue - edittoken = pages['pages'][pageid]['edittoken'] + edittoken = pages[pageid]['edittoken'] filename = os.path.join(self.metadir.root, file) text = codecs.open(filename, 'r', 'utf-8').read() text = text.encode('utf-8') @@ -305,8 +305,9 @@ class CommitCommand(CommandBase): response = self.api.call(data)['query']['pages'] self.metadir.pages_add_rv(int(pageid), response[pageid]['revisions'][0]) - print 'waiting 10s before processing the next file' - time.sleep(10) + if file_num != len(status) - 1: + print 'waiting 10s before processing the next file' + time.sleep(10) else: print 'error: committing %s failed: %s' % \ (file, response['edit']['result']) diff --git a/src/mw/metadir.py b/src/mw/metadir.py index abcd687..6c3dc8b 100644 --- a/src/mw/metadir.py +++ b/src/mw/metadir.py @@ -167,7 +167,7 @@ class Metadir(object): if (len(cur_content) != 0) and (cur_content[-1] == '\n'): cur_content = cur_content[:-1] if cur_content != rv['content']: - status[os.path.relpath(full, self.root)] = 'U' + status[os.path.relpath(full, self.root)] = 'M' return status def diff_rv_to_working(self, pagename, oldrvid=0, newrvid=0):