@@ -2,16 +2,13 @@ use std::convert::TryInto;
22
33use git_actor as actor;
44use git_hash:: ObjectId ;
5- use git_lock as lock;
65use git_ref:: {
76 transaction:: { Change , LogChange , PreviousValue , RefEdit , RefLog } ,
87 FullName , PartialNameRef , Target ,
98} ;
109
1110use crate :: { bstr:: BString , ext:: ReferenceExt , reference, Reference } ;
1211
13- const DEFAULT_LOCK_MODE : git_lock:: acquire:: Fail = git_lock:: acquire:: Fail :: Immediately ;
14-
1512/// Obtain and alter references comfortably
1613impl crate :: Repository {
1714 /// Create a lightweight tag with given `name` (and without `refs/tags/` prefix) pointing to the given `target`, and return it as reference.
@@ -35,7 +32,6 @@ impl crate::Repository {
3532 name : format ! ( "refs/tags/{}" , name. as_ref( ) ) . try_into ( ) ?,
3633 deref : false ,
3734 } ,
38- DEFAULT_LOCK_MODE ,
3935 self . committer_or_default ( ) ,
4036 ) ?;
4137 assert_eq ! ( edits. len( ) , 1 , "reference splits should ever happen" ) ;
@@ -109,7 +105,6 @@ impl crate::Repository {
109105 name,
110106 deref : false ,
111107 } ,
112- DEFAULT_LOCK_MODE ,
113108 self . committer_or_default ( ) ,
114109 ) ?;
115110 assert_eq ! (
@@ -126,33 +121,30 @@ impl crate::Repository {
126121 . attach ( self ) )
127122 }
128123
129- /// Edit a single reference as described in `edit`, handle locks via `lock_mode` and write reference logs as `log_committer`.
124+ /// Edit a single reference as described in `edit`, and write reference logs as `log_committer`.
130125 ///
131126 /// One or more `RefEdit`s are returned - symbolic reference splits can cause more edits to be performed. All edits have the previous
132127 /// reference values set to the ones encountered at rest after acquiring the respective reference's lock.
133128 pub fn edit_reference (
134129 & self ,
135130 edit : RefEdit ,
136- lock_mode : lock:: acquire:: Fail ,
137131 log_committer : actor:: SignatureRef < ' _ > ,
138132 ) -> Result < Vec < RefEdit > , reference:: edit:: Error > {
139- self . edit_references ( Some ( edit) , lock_mode , log_committer)
133+ self . edit_references ( Some ( edit) , log_committer)
140134 }
141135
142- /// Edit one or more references as described by their `edits`, with `lock_mode` deciding on how to handle competing
143- /// transactions. `log_committer` is the name appearing in reference logs.
136+ /// Edit one or more references as described by their `edits`. `log_committer` is the name appearing in reference logs.
144137 ///
145138 /// Returns all reference edits, which might be more than where provided due the splitting of symbolic references, and
146139 /// whose previous (_old_) values are the ones seen on in storage after the reference was locked.
147140 pub fn edit_references (
148141 & self ,
149142 edits : impl IntoIterator < Item = RefEdit > ,
150- lock_mode : lock:: acquire:: Fail ,
151143 log_committer : actor:: SignatureRef < ' _ > ,
152144 ) -> Result < Vec < RefEdit > , reference:: edit:: Error > {
153145 self . refs
154146 . transaction ( )
155- . prepare ( edits, lock_mode ) ?
147+ . prepare ( edits, self . config . lock_timeout ( ) ? . 0 ) ?
156148 . commit ( log_committer)
157149 . map_err ( Into :: into)
158150 }
0 commit comments