mercurial/localrepo.py
changeset 1726 56fb048b102c
parent 1721 801756d0ca84
child 1727 019e6a47a53e
equal deleted inserted replaced
1725:49004ad10cde 1726:56fb048b102c
    52         def runhook(name, cmd):
    52         def runhook(name, cmd):
    53             self.ui.note(_("running hook %s: %s\n") % (name, cmd))
    53             self.ui.note(_("running hook %s: %s\n") % (name, cmd))
    54             old = {}
    54             old = {}
    55             for k, v in args.items():
    55             for k, v in args.items():
    56                 k = k.upper()
    56                 k = k.upper()
       
    57                 old['HG_' + k] = os.environ.get(k, None)
    57                 old[k] = os.environ.get(k, None)
    58                 old[k] = os.environ.get(k, None)
       
    59                 os.environ['HG_' + k] = str(v)
    58                 os.environ[k] = str(v)
    60                 os.environ[k] = str(v)
    59 
    61 
    60             try:
    62             try:
    61                 # Hooks run in the repository root
    63                 # Hooks run in the repository root
    62                 olddir = os.getcwd()
    64                 olddir = os.getcwd()
    63                 os.chdir(self.root)
    65                 os.chdir(self.root)
    64                 r = os.system(cmd)
    66                 r = os.system(cmd)
    65             finally:
    67             finally:
    66                 for k, v in old.items():
    68                 for k, v in old.items():
    67                     if v != None:
    69                     if v is not None:
    68                         os.environ[k] = v
    70                         os.environ[k] = v
    69                     else:
    71                     else:
    70                         del os.environ[k]
    72                         del os.environ[k]
    71 
    73 
    72                 os.chdir(olddir)
    74                 os.chdir(olddir)