Commits

Anonymous committed f5f8164

Added hg config files

  • Participants
  • Parent commits 54c2fa4
  • Branches testing
  • Tags 0.3

Comments (0)

Files changed (6)

 345545e2fb18253d6194ab14135526fed9191c9f 0.1a
 8242deff0d645b447602f812de69bbec38876cca 0.1b
+54c2fa4d1f030844320ced46b28b70f9edc4a5be 0.3
 """
 
 import os
-import time
+import re
 import yaml
 import shutil
+import filecmp
 import logging
 import logging.handlers
+from time import sleep
 from datetime import datetime
 from subprocess import Popen, PIPE
 from functools import wraps
     "Simple logging decorator."
     @wraps(func)
     def wrapper(*args, **kwargs):
-        #logging.basicConfig(filename=os.path.join(os.getcwd(), 'hgmon.log'),
-        #                    level=logging.INFO,
-        #                    format="[%(asctime)s] - %(message)s",)
         str_args = filter(lambda x: not isinstance(x, ui.ui), args)
         logging.debug("%s run with args %s" % (func.__name__, str_args))
         return func(*args, **kwargs)
     return wrapper
 
-def confirm_project_exists(project_dir):
+def make_project_dir(project_dir):
     "Make sure project directory actually exists and create one if it doesn't."
     if os.path.exists(project_dir):
         if not os.path.isdir(project_dir): 
     
 def hg_modify_config(project_dir):
     "Writes config to do auto update after hg push."
-    hgrc_src = 'hgrc_template'
-    hginnore_src = 'hgignore_template'
+    hgrc_src = 'hgrc.template'
+    hgignore_src = 'hgignore.template'
     hgrc_dst = os.path.join(project_dir, '.hg', 'hgrc')
-    hgignore_dst = os.path.join(project_dir, '.hg', 'hgignore')
+    hgignore_dst = os.path.join(project_dir, '.hgignore')
     configpairs = [(hgrc_src, hgrc_dst), (hgignore_src, hgignore_dst)]
     for src, dst in configpairs:
         if os.path.exists(src) and not os.path.exists(dst):
             shutil.copy(src, dst)
+        elif os.path.exists(src) and os.path.exists(dst):
+            if not filecmp.cmp(src, dst):
+                os.remove(dst)
+                shutil.copy(src, dst)
+        else: pass
 
 def load_project_config(configfile):
     "Project_dir_group_config_file -> dir group list"
         grouplist = load_project_config(configfile)
         for group in grouplist:
             for project_dir in group:
-                confirm_project_exists(project_dir)
+                make_project_dir(project_dir)
                 chflag = os.path.join(project_dir, changefile)
                 hgflag = os.path.join(project_dir, '.hg')
                 lockflag = os.path.join(project_dir, lockfile)
                     hg_commit(u, project_dir, comment)
                     syncgroup = group.copy()
                     autosync(u, project_dir, syncgroup)
-        time.sleep(10)
+        sleep(10)
 
 if __name__ == '__main__':
     main()
-KeePass: Copyright (c) 2010 Joel Wang <gastlygeml@gmail.com>.
+Hgsync: Copyright (c) 2010 Joel Wang <gastlygeml@gmail.com>.
 
 The software is distributed under the terms of the GNU General Public
 License version 2 or later.
 hg repos, synchronizing projects among different locations, and also tracks 
 project changes. 
 
-Currently only simple auto committing, synchronizing, and auto 
-branching are supported.
+Since there is no way to communicate directly between DOS and Linux, simple flag 
+files are used to exchange infomation. The server side script monitors for flag
+changes, then takes action specified by the flags.
 
-Simple logging is also supported. 
+Currently only simple auto committing, synchronizing, and auto branching are 
+supported.

hgignore.template

+syntax: glob
+*.orig
+*.rej
+*~
+*.o
+*.log
+*.err
+*.bak
+CHANGED.FLG
+LOCKED.FLG
+
+syntax: regexp
+# File extension longer than 3 letters.
+.*\.[A-Z0-9]{4,}
+[ui]
+verbose = True
+
+[extensions]