Commits

Eduardo Robles Elvira committed b98aac5

bugfix: when hg ci fails, do not reset time count

Comments (0)

Files changed (1)

 
 
 def uisetup(ui):
-    entry = extensions.wrapcommand(commands.table, 'commit', wrap_commit)
     extensions.wrapfunction(localrepo.localrepository, "commit", wrap_localrepo_commit)
 
 def readconfig(repo):
         next_time_str = timedelta_str(currently_total_timespent)
         print "%-50s %s" % ("time spent in next commit", next_time_str)
 
+def wrap_localrepo_commit(origfunc, self, *args, **kwargs):
 
-
-def wrap_commit(orig, ui, repo, *pats, **opts):
-    '''
-    Adds the timespent extra metadata to the changeset of this commit
-    '''
     # do a stop
-    extra, config = readconfig(repo)
-    if extra.get("time-spent-start", False):
-        start = extra.pop("time-spent-start")
+    extra_config, config = readconfig(self)
+    if extra_config.get("time-spent-start", False):
+        start = extra_config.pop("time-spent-start")
         delta = datetime.now() - start
-        if extra.get("time-spent", False):
-            extra["time-spent"] += delta
+        if extra_config.get("time-spent", False):
+            extra_config["time-spent"] += delta
         else:
-            extra["time-spent"] = delta
-        saveconfig(config, extra, repo)
-
-    return orig(ui, repo, *pats, **opts)
-
-def wrap_localrepo_commit(origfunc, self, *args, **kwargs):
-    extra_config, config = readconfig(self)
+            extra_config["time-spent"] = delta
 
     # only adds time-spent extra if timetracker was put to use for this commit
     if extra_config.get("time-spent", False):
         else:
             kwargs["extra"].update(extra_update)
     ret = origfunc(self, *args, **kwargs)
-
-    extra_config = {} # starts again from zero, once the commit has been done
-    saveconfig(config, extra_config, self)
+    if ret:
+        extra_config = {} # starts again from zero, once the commit has been done
+        saveconfig(config, extra_config, self)
 
     return ret