]> projects.mako.cc - mw/commitdiff
Fixes a bug, a performance issue, and use 'M' instead of 'U' to be consistent with...
authorJoseph Reagle <joseph@reagle.org>
Tue, 1 Feb 2011 15:59:25 +0000 (10:59 -0500)
committerIan Weller <ian@ianweller.org>
Tue, 1 Feb 2011 17:10:27 +0000 (10:10 -0700)
src/mw/clicommands.py
src/mw/metadir.py

index 03c558176d86027fbcb68cf39de6ddba92dac99a..b0fb8bc1f2235aadf85f45975ec16bcb442e7c64 100644 (file)
@@ -210,7 +210,7 @@ class DiffCommand(CommandBase):
         self._die_if_no_init()
         status = self.metadir.working_dir_status()
         for file in status:
         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])),
 
                 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)
         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'
                 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
             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',
                 # 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
                     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')
                 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])
                     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'])
                 else:
                     print 'error: committing %s failed: %s' % \
                             (file, response['edit']['result'])
index abcd6874d5059244a54a108bf2486b701e04f7a5..6c3dc8b0e4c299868d52864ab15f0d77dea5f97e 100644 (file)
@@ -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']:
                     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):
         return status
 
     def diff_rv_to_working(self, pagename, oldrvid=0, newrvid=0):

Benjamin Mako Hill || Want to submit a patch?