##// END OF EJS Templates
cmdutil: add class to restore dirstate during unexpected failure...
cmdutil: add class to restore dirstate during unexpected failure Before this patch, after "dirstate.write()" execution, there was no way to restore dirstate to the original status before "dirstate.write()". In some code paths, "dirstate.invalidate()" is used as a kind of "restore .hg/dirstate to the original status", but it just avoids writing changes in memory out, and doesn't actually restore the ".hg/dirstate" file. To fix the issue that the recent (in memory) dirstate isn't visible to external processes (e.g. "precommit" hooks), "dirstate.write()" should be invoked before invocation of external processes. But at the same time, ".hg/dirstate" should be restored to its content before "dirstate.write()" during an unexpected failure in some cases. This patch adds the class "dirstateguard" to easily restore ".hg/dirstate" during unexpected failures. Typical usecase of it is: # (1) build dirstate up .... # (2) write dirstate out, and backup ".hg/dirstate" dsguard = dirstateguard(repo, 'scopename') try: # (3) execute somethig to do: # this may imply making some additional changes on dirstate .... # (4) unlink backed-up dirstate file at the end of dsguard scope dsguard.close() finally: # (5) if execution is aborted before "dsguard.close()", # ".hg/dirstate" is restored from the backup dsguard.release() For this kind of issue, an "extending transaction" approach (in https://titanpad.com/mercurial32-sprint) seems to not be suitable, because: - transaction nesting occurs in some cases (e.g. "shelve => rebase"), and - "dirstate" may be already modified since the beginning of OUTER transaction scope, then - dirstate should be backed up into the file other than "dirstate.journal" at the beginning of INNER transaction scope, but - such alternative backup files are useless for transaction itself, and increases complication of its implementation "transaction" and "dirstateguard" differ from each other also in "what it should do for .hg/dirstate" in cases other than success. ============== ======= ======== ============= type success fail "hg rollback" ============== ======= ======== ============= transaction keep keep restore dirstateguard keep restore (not implied) ============== ======= ======== ============= Some collaboration between transaction and dirstate will probably be introduced in the future. But this layer is needed in all cases.

File last commit:

r23930:97393540 stable
r24991:4169a4f8 default
Show More
Readme.html
37 lines | 1.8 KiB | text/html | HtmlLexer
Vadim Gelfer
make stuff for macos x binary package....
r1686 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Bryan O'Sullivan
Update binary installer files.
r4723 <!-- This is the second screen displayed during the install. -->
Vadim Gelfer
make stuff for macos x binary package....
r1686 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
Mads Kiilerich
osx: update "Read Me" "Important Information" text in the package installer...
r23930 <title>Read Me - Important Information</title>
Vadim Gelfer
make stuff for macos x binary package....
r1686 <style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000fed}
span.s1 {text-decoration: underline}
span.s2 {font: 12.0px Courier}
</style>
</head>
<body>
<p class="p1"><b>Before you install</b></p>
<p class="p2"><br></p>
Mads Kiilerich
osx: update "Read Me" "Important Information" text in the package installer...
r23930 <p class="p3">This is an OS X version of Mercurial that depends on the default Python installation.</p>
Vadim Gelfer
make stuff for macos x binary package....
r1686 <p class="p2"><br></p>
<p class="p1"><b>After you install</b></p>
<p class="p2"><br></p>
Mads Kiilerich
osx: update "Read Me" "Important Information" text in the package installer...
r23930 <p class="p3">This package installs the <span class="s2">hg</span> executable as <span class="s2">/usr/local/bin/hg</span>. See <span class="s2">hg debuginstall</span> for more info on file locations.</p>
Vadim Gelfer
make stuff for macos x binary package....
r1686 <p class="p2"><br></p>
Bryan O'Sullivan
Update binary installer files.
r4723 <p class="p1"><b>Documentation</b></p>
<p class="p2"><br></p>
Dirkjan Ochtman
change wiki/bts URLs to point to new hostname
r8936 <p class="p3">Visit the <a href="http://mercurial.selenic.com/">Mercurial web site and wiki</a></p>
Bryan O'Sullivan
Update binary installer files.
r4723 <p class="p2"><br></p>
<p class="p3">There's also a free book, <a href="http://hgbook.red-bean.com/">Distributed revision control with Mercurial</a></p>
<p class="p2"><br></p>
Vadim Gelfer
make stuff for macos x binary package....
r1686 <p class="p1"><b>Reporting problems</b></p>
<p class="p2"><br></p>
<p class="p3">If you run into any problems, please file a bug online:</p>
Mads Kiilerich
osx: update "Read Me" "Important Information" text in the package installer...
r23930 <p class="p3"><a href="http://bz.selenic.com/">http://bz.selenic.com/</a></p>
Vadim Gelfer
make stuff for macos x binary package....
r1686 </body>
</html>