mercurial/localrepo.py
changeset 25270 61b3529e2377
parent 25237 7504a7325e4c
parent 25268 a973b050621d
child 25274 144085249c3f
equal deleted inserted replaced
25269:46bf4983cf31 25270:61b3529e2377
    14 import scmutil, util, extensions, hook, error, revset
    14 import scmutil, util, extensions, hook, error, revset
    15 import match as matchmod
    15 import match as matchmod
    16 import merge as mergemod
    16 import merge as mergemod
    17 import tags as tagsmod
    17 import tags as tagsmod
    18 from lock import release
    18 from lock import release
    19 import weakref, errno, os, time, inspect
    19 import weakref, errno, os, time, inspect, random
    20 import branchmap, pathutil
    20 import branchmap, pathutil
    21 import namespaces
    21 import namespaces
    22 propertycache = util.propertycache
    22 propertycache = util.propertycache
    23 filecache = scmutil.filecache
    23 filecache = scmutil.filecache
    24 
    24 
   957         if self.svfs.exists("journal"):
   957         if self.svfs.exists("journal"):
   958             raise error.RepoError(
   958             raise error.RepoError(
   959                 _("abandoned transaction found"),
   959                 _("abandoned transaction found"),
   960                 hint=_("run 'hg recover' to clean up transaction"))
   960                 hint=_("run 'hg recover' to clean up transaction"))
   961 
   961 
   962         self.hook('pretxnopen', throw=True, txnname=desc)
   962         idbase = "%.40f#%f" % (random.random(), time.time())
       
   963         txnid = 'TXN:' + util.sha1(idbase).hexdigest()
       
   964         self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
   963 
   965 
   964         self._writejournal(desc)
   966         self._writejournal(desc)
   965         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
   967         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
   966         if report:
   968         if report:
   967             rp = report
   969             rp = report
   981                                      "undo",
   983                                      "undo",
   982                                      aftertrans(renames),
   984                                      aftertrans(renames),
   983                                      self.store.createmode,
   985                                      self.store.createmode,
   984                                      validator=validate)
   986                                      validator=validate)
   985 
   987 
   986         trid = 'TXN:' + util.sha1("%s#%f" % (id(tr), time.time())).hexdigest()
   988         tr.hookargs['txnid'] = txnid
   987         tr.hookargs['txnid'] = trid
       
   988         # note: writing the fncache only during finalize mean that the file is
   989         # note: writing the fncache only during finalize mean that the file is
   989         # outdated when running hooks. As fncache is used for streaming clone,
   990         # outdated when running hooks. As fncache is used for streaming clone,
   990         # this is not expected to break anything that happen during the hooks.
   991         # this is not expected to break anything that happen during the hooks.
   991         tr.addfinalize('flush-fncache', self.store.write)
   992         tr.addfinalize('flush-fncache', self.store.write)
   992         def txnclosehook(tr2):
   993         def txnclosehook(tr2):