summaryrefslogtreecommitdiff
path: root/Annex/AdjustedBranch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-03-03 16:38:56 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-03-03 16:38:56 -0400
commit9b8225baa1c5fde927b0c6239a7bd479a7b30a6e (patch)
tree02352511da9f92b62e1565eb0740af7725045faa /Annex/AdjustedBranch.hs
parentce7e52101cda2715bc4ca0a758884d67fb40669e (diff)
change name of adjusted branches to eg adjusted/master(unlocked)
Using adjusted/unlocked/master made lots of git stuff dealing with "master" complain that it was ambiguous. This new appoach is more like view branch names, and shows the adjustment right there in the branch display even if only the basename of the branch is shown.
Diffstat (limited to 'Annex/AdjustedBranch.hs')
-rw-r--r--Annex/AdjustedBranch.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs
index 30d4e7c09..6ba229b9c 100644
--- a/Annex/AdjustedBranch.hs
+++ b/Annex/AdjustedBranch.hs
@@ -74,22 +74,24 @@ adjustedBranchPrefix :: String
adjustedBranchPrefix = "refs/heads/adjusted/"
serialize :: Adjustment -> String
-serialize UnlockAdjustment = "unlock"
+serialize UnlockAdjustment = "unlocked"
deserialize :: String -> Maybe Adjustment
-deserialize "unlock" = Just UnlockAdjustment
+deserialize "unlocked" = Just UnlockAdjustment
deserialize _ = Nothing
originalToAdjusted :: OrigBranch -> Adjustment -> AdjBranch
-originalToAdjusted orig adj = Git.Ref.under base orig
+originalToAdjusted orig adj = Ref $
+ adjustedBranchPrefix ++ base ++ '(' : serialize adj ++ ")"
where
- base = adjustedBranchPrefix ++ serialize adj
+ base = fromRef (Git.Ref.basename orig)
adjustedToOriginal :: AdjBranch -> Maybe (Adjustment, OrigBranch)
adjustedToOriginal b
| adjustedBranchPrefix `isPrefixOf` bs = do
- adj <- deserialize (takeWhile (/= '/') (drop prefixlen bs))
- Just (adj, Git.Ref.basename b)
+ let (base, as) = separate (== '(') (drop prefixlen bs)
+ adj <- deserialize (takeWhile (/= ')') as)
+ Just (adj, Git.Ref.under "refs/heads" (Ref base))
| otherwise = Nothing
where
bs = fromRef b
@@ -217,7 +219,7 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode =
-}
propigateAdjustedCommits :: OrigBranch -> (Adjustment, AdjBranch) -> Annex ()
propigateAdjustedCommits origbranch (adj, currbranch) = do
- v <- inRepo $ Git.Ref.sha (Git.Ref.under "refs/heads/" origbranch)
+ v <- inRepo $ Git.Ref.sha (Git.Ref.under "refs/heads" origbranch)
case v of
Just origsha -> go origsha False =<< newcommits
Nothing -> return ()