ZyX_I avatar ZyX_I committed 6405521

Added :AuName command

Comments (0)

Files changed (8)

 This plugin provides a vim <--> VCS (currently only mercurial) integration for 
 your projects. Features:
 
-  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line329-0)).
+  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line348-0)).
 
-  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line560-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line150-0)).
+  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line579-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line153-0)).
 
   - Viewing uncommited changes in a vimdiff, as well as changes between 
-    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line369-0)). It is also possible to open multiple 
+    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line388-0)). It is also possible to open multiple 
     tabs with all changes to all files viewed as side-by-side diffs.
 
-  - Viewing revisions log ([:AuLog](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line230-0)). Output is highly customizable.
+  - Viewing revisions log ([:AuLog](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line233-0)). Output is highly customizable.
 
-  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line333-0)).
+  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line352-0)).
 
-  - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line91-0)), commit messages are remembered in case of 
-    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line805-0)).
+  - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line94-0)), commit messages are remembered in case of 
+    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line824-0)).
 
   - Obtaining various URL’s out of remote repository URL (like URL of the HTML 
     version of the current file with URL fragment pointing to the current line 
-    attached: useful for sharing) ([:AuHyperlink](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line181-0)).
+    attached: useful for sharing) ([:AuHyperlink](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line184-0)).
 
   - aurum#changeset(), aurum#repository() and aurum#status() functions 
     that are to be used from modeline.
 
   - Frontends for various other VCS commands.
 
-Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line702-0)), 
+Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line721-0)), 
 all mappings are customizable.
 
 
     Note: you must either be at repository root (see |:cd|) or have all 
           arguments look like “path/to/repository/{meaningfulPart}”.
 
+AuName {name} {opts} [{rev}]                                         *:AuName*
+    Name (tag/bookmark/...) revision {rev} (default: working directory 
+    revision) as {name}. Possible options:
+    Option      Description ~
+    type        String, determines what will be done. Depends on repository 
+                object, for mercurial repositories it will be likely “tag” or 
+                “bookmark”.
+                Default: first item present in |aurum-repo.labeltypes|.
+    [no]delete  Flag. If enabled, then {rev} argument will be ignored and 
+                tag/bookmark/... will be deleted. Default: disabled.
+    [no]force   Flag. If enabled, given revision will be named even if another 
+                revision has the same name. Default: disabled.
+    [no]local   Flag. If enabled, then name will not be pushed.
+                Default: disabled.
+    repo        Path. Repository that should be operated upon.
+
 AuRecord {opts} [glob1 [...]]                                      *:AuRecord*
     Start record mode (|aurum-record|). Possible options are just the same as 
     |:AuCommit| has (except for “type” option that is absent).
         line       Line number (only inside “hline” and “aline” expressions).
     You should not normally use or alter this key, use |g:aurum_hypsites| if 
     you want to add support for particular remote repository.
+labeltypes :: [ String ]                               *aurum-repo.labeltypes*
+    List of label types supported by |aurum-rf-label|. First type will be 
+    default used by |:AuName|.
 functions :: {String : FRef}                            *aurum-repo.functions*
     Dictionary that contains all driver-specific functions. All functions 
     except |aurum-rf-repo|, |aurum-rf-checkdir| and |aurum-rf-checkremote| 
     tagslist, brancheslist, bookmarkslist
                    List of strings containing tags, branches and bookmarks 
                    present in current repo respectively. Is used for 
-                   completion in commands that accept {rev} argument.
+                   completion in commands that accept {rev} argument and by 
+                   |:AuBranch| and |:AuName| in order to check whether branch 
+                   can be created/revision can be named.
     url            Remote repository URL. For mercurial it is either 
                    paths.default-push or paths.default whichever is defined.
   getchangesets :: () -> [ cs ]                       *aurum-rf-getchangesets*
     Create new branch.
   label :: type, label, hex, force, local -> _                *aurum-rf-label*
     Label specific revision (if rev is 0 then remove label).
+    Note: if this function accepts label with type {type}, 
+          |aurum-rf-getrepoprop| must be able to list labels of this type in 
+          property "{type}slist".
 The following functions do not accept repo argument:
   repo :: path -> repo                                         *aurum-rf-repo*
     Creates new repository object using repository located at given path.
 
 @aurum/repo:
     1.0: Instead of depending on drivers, make drivers depend on @aurum/repo
+    1.1: Added repo.branch and repo.label
+@aurum:
+    0.1: Added :AuBranch and :AuName
 
 vim: ft=help:tw=78
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
     "▶2 frawor#Setup
-    execute frawor#Setup('0.0', {'@/commands': '0.0',
+    execute frawor#Setup('0.1', {'@/commands': '0.0',
                 \               '@/functions': '0.0',
                 \                   '@/table': '0.0',
                 \                '@/mappings': '0.0',
                 \             '@aurum/status': '0.0',
                 \                '@aurum/log': '0.0',
                 \             '@aurum/commit': '0.0',
-                \               '@aurum/repo': '1.0',
+                \               '@aurum/repo': '1.1',
                 \               '@aurum/edit': '0.0',
                 \            '@aurum/bufvars': '0.0',
                 \            '@aurum/vimdiff': '0.0',}, 0)
     " TODO :AuExplore
     let s:addargs={'Update': {'bang': 1}, 'Move': {'bang': 1}}
     for s:cmd in ['Update', 'Move', 'Junk', 'Track', 'Hyperlink', 'Grep',
-                \ 'Branch']
+                \ 'Branch', 'Name']
         let s:part=tolower(s:cmd[:3])
         if len(s:cmd)>4 && stridx('aeiouy', s:part[-1:])!=-1
             let s:part=s:part[:-2]
             \  'nrepo': 'Not a repository: %s',
             \ 'bexsts': 'Error while creating branch %s for repository %s: '.
             \           'branch already exists',
+            \ 'nunsup': 'Naming is not supported for repository %s',
+            \'ukntype': 'Unknown label type: %s. Supported types: %s',
+            \   'ldef': 'Label %s with type %s was alredy defined',
             \'_mvheader': ['Source', 'Destination'],
         \}
 let s:utypes=['html', 'raw', 'annotate', 'filehist', 'bundle', 'changeset',
             \           ' ?!force'.
             \           '}', 'filter']
 call add(s:brancomp, s:branfunc['@FWC'][0])
+"▶1 namefunc
+function s:namefunc.function(name, opts, ...)
+    let repo=s:_r.repo.get(a:opts.repo)
+    call s:_r.cmdutils.checkrepo(repo)
+    if !has_key(repo, 'labeltypes') || empty(repo.labeltypes)
+        call s:_f.throw('nunsup', repo.path)
+    endif
+    if get(a:opts, 'delete', 0)
+        let rev=0
+    else
+        let rev=repo.functions.getrevhex(repo, get(a:000, 0, '.'))
+    endif
+    if has_key(a:opts, 'type')
+        let type=a:opts.type
+        let lts=repo.labeltypes
+        if index(lts, type)==-1
+            let type=get(filter(copy(lts),
+                        \       'v:val[:'.(len(type)-1).'] is# type'), 0, 0)
+            if type is 0
+                call s:_f.throw('ukntype', a:opts.type, join(lts, ', '))
+            endif
+        endif
+    else
+        let type=repo.labeltypes[0]
+    endif
+    let force=get(a:opts, 'force', 0)
+    if rev isnot 0 && !force
+        try
+            let labels=repo.functions.getrepoprop(repo, type.'slist')
+            if index(labels, a:name)!=-1
+                let rev=0
+            endif
+        catch
+        endtry
+        if rev is 0
+            call s:_f.throw('ldef', a:name, type)
+        endif
+    endif
+    call repo.functions.label(repo, type, a:name, rev, force,
+                \             get(a:opts, 'local', 0))
+endfunction
+let s:namefunc['@FWC']=['-onlystrings '.
+            \           'type ""'.
+            \           '{  repo '.s:_r.cmdutils.nogetrepoarg.
+            \           ' ? type   type ""'.
+            \           ' ?!delete'.
+            \           ' ?!local'.
+            \           ' ?!force'.
+            \           '} '.
+            \           '+ type ""', 'filter']
+call add(s:namecomp, s:namefunc['@FWC'][0])
 "▶1
 call frawor#Lockvar(s:, '_pluginloaded,_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

plugin/aurum/drivers/mercurial.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {      '@/python': '0.0',
+    execute frawor#Setup('0.1', {      '@/python': '0.0',
                 \                   '@aurum/repo': '1.0',
                 \                          '@/os': '0.0',
                 \'@aurum/drivers/common/hypsites': '0.0'}, 0)

plugin/aurum/repo.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('1.0', {'@/resources': '0.0',
+    execute frawor#Setup('1.1', {'@/resources': '0.0',
                 \                       '@/os': '0.0',
                 \                  '@/options': '0.0',
                 \             '@aurum/bufvars': '0.0',}, 0)
+:command -nargs=0 SWT :WT silent %sm/\(Added tag \w\+ for changeset\) \x\+/\1/e
+:W{{{1 D
+:R silent AuName D
+:SWT
+:W{{{1 force D
+:R silent AuName D force
+:SWT
+:W{{{1 type E
+:R silent AuName E type t
+:SWT
+:W{{{1 local F
+:R silent AuName F local
+:SWT
+:W{{{1 delete F
+:R silent AuName F delete local
+:SWT
+:W{{{1 delete E
+:R silent AuName E delete
+:SWT
+:W{{{1 D
+:R try | AuName D | catch | endtry
+:SWT
+:W{{{1 Unknown type
+:R try | AuName G type unknown | catch | endtry
+:SWT
+:source addmessages.vim
+{{{1 D
+@  Changeset 27
+|  Tags: tip
+|  @ Added tag D for changeset
+{{{1 force D
+@  Changeset 28
+|  Tags: tip
+|  @ Added tag D for changeset
+{{{1 type E
+@  Changeset 29
+|  Tags: tip
+|  @ Added tag E for changeset
+{{{1 local F
+@  Changeset 29
+|  Tags: F, tip
+|  @ Added tag E for changeset
+{{{1 delete F
+@  Changeset 29
+|  Tags: tip
+|  @ Added tag E for changeset
+{{{1 delete E
+@  Changeset 30
+|  Tags: tip
+|  @ Removed tag E
+{{{1 D
+@  Changeset 30
+|  Tags: tip
+|  @ Removed tag E
+{{{1 Unknown type
+@  Changeset 30
+|  Tags: tip
+|  @ Removed tag E
+>>> Messages:
+Frawor:plugin/aurum:ldef:Label D with type tag was alredy defined
+Frawor:plugin/aurum:ukntype:Unknown label type: unknown. Supported types: tag, bookmark
+<<< Messages^
     return ''
 endfunction
 command -nargs=1 -bar W call WriteFile(<q-args>)
-function s:WriteTip(writecom)
+function s:WriteTip(writecom, cmd)
     R AuLog revrange tip tip
     setlocal modifiable noreadonly
     if !a:writecom
         g/Commited/delete _
     endif
     normal! gg0f:"_de
+    if !empty(a:cmd)
+        execute a:cmd
+    endif
     call WriteFile(getline(1, line('$')-1))
     bwipeout!
 endfunction
-command -nargs=0 -bar -bang WT :call s:WriteTip(<bang>0)
+command -nargs=? -bar -bang WT :call s:WriteTip(<bang>0, <q-args>)
 function s:WriteWindows()
     let wcur=winnr()
     let wprev=winnr('#')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.