Upgrading a direct mode repository to v6 has changed to enter an adjusted unlocked branch.
This makes the direct mode to v6 upgrade able to be performed in one clone of a repository without affecting other clones, which can continue using v5 and direct mode.
This commit is contained in:
parent
c7b06b879b
commit
c3e0859846
7 changed files with 54 additions and 43 deletions
|
@ -14,6 +14,7 @@ module Annex.AdjustedBranch (
|
||||||
fromAdjustedBranch,
|
fromAdjustedBranch,
|
||||||
getAdjustment,
|
getAdjustment,
|
||||||
enterAdjustedBranch,
|
enterAdjustedBranch,
|
||||||
|
adjustBranch,
|
||||||
adjustToCrippledFileSystem,
|
adjustToCrippledFileSystem,
|
||||||
updateAdjustedBranch,
|
updateAdjustedBranch,
|
||||||
propigateAdjustedCommits,
|
propigateAdjustedCommits,
|
||||||
|
|
|
@ -184,21 +184,21 @@ commitTree commitmode message parentrefs tree repo =
|
||||||
forcePush :: String -> String
|
forcePush :: String -> String
|
||||||
forcePush b = "+" ++ b
|
forcePush b = "+" ++ b
|
||||||
|
|
||||||
{- Updates a branch (or other ref) to a new Sha. -}
|
{- Updates a branch (or other ref) to a new Sha or branch Ref. -}
|
||||||
update :: String -> Branch -> Sha -> Repo -> IO ()
|
update :: String -> Branch -> Ref -> Repo -> IO ()
|
||||||
update message branch sha = run
|
update message branch r = run
|
||||||
[ Param "update-ref"
|
[ Param "update-ref"
|
||||||
, Param "-m"
|
, Param "-m"
|
||||||
, Param message
|
, Param message
|
||||||
, Param $ fromRef branch
|
, Param $ fromRef branch
|
||||||
, Param $ fromRef sha
|
, Param $ fromRef r
|
||||||
]
|
]
|
||||||
|
|
||||||
update' :: Branch -> Sha -> Repo -> IO ()
|
update' :: Branch -> Ref -> Repo -> IO ()
|
||||||
update' branch sha = run
|
update' branch r = run
|
||||||
[ Param "update-ref"
|
[ Param "update-ref"
|
||||||
, Param $ fromRef branch
|
, Param $ fromRef branch
|
||||||
, Param $ fromRef sha
|
, Param $ fromRef r
|
||||||
]
|
]
|
||||||
|
|
||||||
{- Checks out a branch, creating it if necessary. -}
|
{- Checks out a branch, creating it if necessary. -}
|
||||||
|
|
|
@ -18,6 +18,12 @@ import Data.Char (chr)
|
||||||
headRef :: Ref
|
headRef :: Ref
|
||||||
headRef = Ref "HEAD"
|
headRef = Ref "HEAD"
|
||||||
|
|
||||||
|
headFile :: Repo -> FilePath
|
||||||
|
headFile r = localGitDir r </> "HEAD"
|
||||||
|
|
||||||
|
setHeadRef :: Ref -> Repo -> IO ()
|
||||||
|
setHeadRef ref r = writeFile (headFile r) ("ref: " ++ fromRef ref)
|
||||||
|
|
||||||
{- Converts a fully qualified git ref into a user-visible string. -}
|
{- Converts a fully qualified git ref into a user-visible string. -}
|
||||||
describe :: Ref -> String
|
describe :: Ref -> String
|
||||||
describe = fromRef . base
|
describe = fromRef . base
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex v5 -> v6 upgrade support
|
{- git-annex v5 -> v6 upgrade support
|
||||||
-
|
-
|
||||||
- Copyright 2015 Joey Hess <id@joeyh.name>
|
- Copyright 2015-2016 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -23,7 +23,9 @@ import qualified Git.Branch
|
||||||
import Git.FilePath
|
import Git.FilePath
|
||||||
import Git.FileMode
|
import Git.FileMode
|
||||||
import Git.Config
|
import Git.Config
|
||||||
|
import Git.Ref
|
||||||
import Utility.InodeCache
|
import Utility.InodeCache
|
||||||
|
import Annex.AdjustedBranch
|
||||||
|
|
||||||
upgrade :: Bool -> Annex Bool
|
upgrade :: Bool -> Annex Bool
|
||||||
upgrade automatic = do
|
upgrade automatic = do
|
||||||
|
@ -37,19 +39,27 @@ upgrade automatic = do
|
||||||
setConfig (annexConfig "thin") (boolConfig True)
|
setConfig (annexConfig "thin") (boolConfig True)
|
||||||
Annex.changeGitConfig $ \c -> c { annexThin = True }
|
Annex.changeGitConfig $ \c -> c { annexThin = True }
|
||||||
{- Since upgrade from direct mode changes how files
|
{- Since upgrade from direct mode changes how files
|
||||||
- are represented in git, commit any changes in the
|
- are represented in git, by checking out an adjusted
|
||||||
- work tree first. -}
|
- branch, commit any changes in the work tree first. -}
|
||||||
whenM stageDirect $ do
|
whenM stageDirect $ do
|
||||||
unless automatic $
|
unless automatic $
|
||||||
showAction "committing first"
|
showAction "committing first"
|
||||||
upgradeDirectCommit automatic
|
upgradeDirectCommit automatic
|
||||||
"commit before upgrade to annex.version 6"
|
"commit before upgrade to annex.version 6"
|
||||||
setDirect False
|
setDirect False
|
||||||
|
cur <- fromMaybe (error "Somehow no branch is checked out")
|
||||||
|
<$> inRepo Git.Branch.current
|
||||||
upgradeDirectWorkTree
|
upgradeDirectWorkTree
|
||||||
removeDirectCruft
|
removeDirectCruft
|
||||||
showLongNote "Upgraded repository out of direct mode."
|
{- Create adjusted branch where all files are unlocked.
|
||||||
showLongNote "Changes have been staged for all annexed files in this repository; you should run `git commit` to commit these changes."
|
- This should have the same content for each file as
|
||||||
showLongNote "Any other clones of this repository that use direct mode need to be upgraded now, too."
|
- have been staged in upgradeDirectWorkTree. -}
|
||||||
|
adjbranch <- adjustBranch UnlockAdjustment cur
|
||||||
|
{- Since the work tree was already set up by
|
||||||
|
- upgradeDirectWorkTree, and contains unlocked file
|
||||||
|
- contents too, don't use git checkout to check out the
|
||||||
|
- adjust branch. Instead, update HEAD manually. -}
|
||||||
|
inRepo $ setHeadRef adjbranch
|
||||||
configureSmudgeFilter
|
configureSmudgeFilter
|
||||||
-- Inode sentinal file was only used in direct mode and when
|
-- Inode sentinal file was only used in direct mode and when
|
||||||
-- locking down files as they were added. In v6, it's used more
|
-- locking down files as they were added. In v6, it's used more
|
||||||
|
|
4
debian/changelog
vendored
4
debian/changelog
vendored
|
@ -2,6 +2,10 @@ git-annex (6.20160319) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* adjust --unlock: Enters an adjusted branch in which all annexed files
|
* adjust --unlock: Enters an adjusted branch in which all annexed files
|
||||||
are unlocked. The v6 equivilant of direct mode, but much cleaner!
|
are unlocked. The v6 equivilant of direct mode, but much cleaner!
|
||||||
|
* Upgrading a direct mode repository to v6 has changed to enter
|
||||||
|
an adjusted unlocked branch. This makes the direct mode to v6 upgrade
|
||||||
|
able to be performed in one clone of a repository without affecting
|
||||||
|
other clones, which can continue using v5 and direct mode.
|
||||||
* init --version=6: Automatically enter the adjusted unlocked branch
|
* init --version=6: Automatically enter the adjusted unlocked branch
|
||||||
when filesystem doesn't support symlinks.
|
when filesystem doesn't support symlinks.
|
||||||
* ddar remote: fix ssh calls
|
* ddar remote: fix ssh calls
|
||||||
|
|
|
@ -347,7 +347,6 @@ into adjusted view worktrees.]
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
* Interface in webapp to enable adjustments.
|
* Interface in webapp to enable adjustments.
|
||||||
* Upgrade from direct mode to v6 in unlocked branch.
|
|
||||||
* Honor annex.thin when entering an adjusted branch.
|
* Honor annex.thin when entering an adjusted branch.
|
||||||
* Cloning a repo that has an adjusted branch checked out gets into an ugly
|
* Cloning a repo that has an adjusted branch checked out gets into an ugly
|
||||||
state.
|
state.
|
||||||
|
|
|
@ -45,47 +45,38 @@ The upgrade events, so far:
|
||||||
|
|
||||||
## v5 -> v6 (git-annex version 6.x)
|
## v5 -> v6 (git-annex version 6.x)
|
||||||
|
|
||||||
The upgrade from v5 to v6 is handled manually. Run `git-annex upgrade`
|
The upgrade from v5 to v6 is handled manually for now.
|
||||||
performs the upgrade.
|
Run `git-annex upgrade` to perform the upgrade.
|
||||||
|
|
||||||
Warning: All places that a direct mode repository is cloned to should be
|
A v6 git-annex repository can have some files locked while other files are
|
||||||
running git-annex version 6.x before you upgrade the repository.
|
|
||||||
This is necessary because the contents of the repository are changed
|
|
||||||
in the upgrade, and the old version of git-annex won't be able to
|
|
||||||
access files after the repo is upgraded.
|
|
||||||
|
|
||||||
This upgrade does away with the direct mode/indirect mode distinction.
|
|
||||||
A v6 git-annex repository can have some files locked and other files
|
|
||||||
unlocked, and all git and git-annex commands can be used on both locked and
|
unlocked, and all git and git-annex commands can be used on both locked and
|
||||||
unlocked files. (Although for locked files to work, the filesystem
|
unlocked files. (Although for locked files to be accessible, the filesystem
|
||||||
must support symbolic links..)
|
must support symbolic links..
|
||||||
|
|
||||||
|
Direct mode repositories are upgraded to instead use the new
|
||||||
|
[[adjusted branches feature|git-annex-adjust]], which transparently unlocks
|
||||||
|
all locked files in the local repository.
|
||||||
|
|
||||||
The behavior of some commands changes in an upgraded repository:
|
The behavior of some commands changes in an upgraded repository:
|
||||||
|
|
||||||
* `git add` will add files to the annex, in unlocked mode, rather than
|
* `git add` will add files to the annex, rather than adding them directly
|
||||||
adding them directly to the git repository. To cause some files to be
|
to the git repository. To cause some files to be added directly
|
||||||
added directly to git, you can configure `annex.largefiles`. For
|
to git, you can configure `annex.largefiles`. For example:
|
||||||
example:
|
|
||||||
|
|
||||||
git config annex.largefiles "largerthan=100kb and not (include=*.c or include=*.h)"
|
git config annex.largefiles "largerthan=100kb and not (include=*.c or include=*.h)"
|
||||||
|
|
||||||
* `git annex unlock` and `git annex lock` change how the pointer to
|
* `git annex unlock` and `git annex lock` change how the pointer to
|
||||||
the annexed content is stored in git.
|
the annexed content is stored in git.
|
||||||
|
|
||||||
There is also a new `annex.thin` setting, which makes unlocked files in v6 repositories
|
There is also a new `annex.thin` setting, which makes unlocked files in v6
|
||||||
be hard linked to their content, instead of a copy. This saves disk
|
repositories be hard linked to their content, instead of a copy. This saves
|
||||||
space but means any modification of an unlocked file will lose the local
|
disk space but means any modification of an unlocked file will lose the
|
||||||
(and possibly only) copy of the old version.
|
local (and possibly only) copy of the old version. This is automatically
|
||||||
|
enabled when upgrading a direct mode repository, since direct mode made the
|
||||||
|
same tradeoff.
|
||||||
|
|
||||||
On upgrade, all files in a direct mode repository will be converted to
|
See [[tips/unlocked_files/]] for more details about locked files and thin
|
||||||
unlocked files with the `annex.thin` setting enabled.
|
mode.
|
||||||
The upgrade will stage changes to all annexed files in
|
|
||||||
the git repository, which you can then commit.
|
|
||||||
|
|
||||||
If a repository has some clones using direct mode and some using indirect
|
|
||||||
mode, all the files will end up unlocked in all clones after the upgrade.
|
|
||||||
|
|
||||||
See [[tips/unlocked_files/]] for more details about locked files and thin mode.
|
|
||||||
|
|
||||||
## v4 -> v5 (git-annex version 5.x)
|
## v4 -> v5 (git-annex version 5.x)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue