Permalink
Browse files

Version 1.4.9

Added :AuOther push/pull/incoming/outgoing commandFixed :AuFile replaceFixed repo.functions.grep in newer mercurial versions
  • Loading branch information...
1 parent a3efc5e commit cb744d9da21644e959cbf8ca2cf3bbd43328a9e7 @ZyX-I ZyX-I committed with Mar 10, 2012
Showing with 167 additions and 31 deletions.
  1. +9 −9 README
  2. +7 −7 README.markdown
  3. +25 −1 doc/aurum.txt
  4. +30 −4 plugin/aurum.vim
  5. +35 −0 plugin/aurum/drivers/git.vim
  6. +32 −1 plugin/aurum/drivers/mercurial.vim
  7. +3 −0 plugin/aurum/file.vim
  8. +10 −3 plugin/aurum/record.vim
  9. +3 −2 plugin/aurum/repo.vim
  10. +13 −4 python/aurum.py
View
@@ -38,17 +38,17 @@ Note: aurum supports VAM (https://github.com/MarcWeber/vim-addon-manager). It
Project page: https://bitbucket.org/ZyX_I/aurum
Documentation: http://vimpluginloader.sourceforge.net/doc/aurum.txt.html
-[1] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line359-0 (:AuRecord)
-[2] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line601-0 (aurum://file)
+[1] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line372-0 (:AuRecord)
+[2] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line614-0 (aurum://file)
[3] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line158-0 (:AuFile)
-[4] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line402-0 (:AuVimDiff)
+[4] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line415-0 (:AuVimDiff)
[5] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line239-0 (:AuLog)
-[6] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line363-0 (:AuStatus)
+[6] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line376-0 (:AuStatus)
[7] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line99-0 (:AuCommit)
-[8] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line883-0 (g:aurum_remembermsg)
+[8] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line896-0 (g:aurum_remembermsg)
[9] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line189-0 (:AuHyperlink)
-[10] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line450-0 (aurum#changeset())
-[11] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line446-0 (aurum#repository())
-[12] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line454-0 (aurum#status())
-[13] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line756-0 (aurum-mappings)
+[10] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line463-0 (aurum#changeset())
+[11] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line459-0 (aurum#repository())
+[12] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line467-0 (aurum#status())
+[13] http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line769-0 (aurum-mappings)
View
@@ -2,31 +2,31 @@
This plugin provides a vim <--> VCS (currently mercurial, git and subversion)
integration for your projects. Features:
- - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line359-0)).
+ - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line372-0)).
- - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line601-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line158-0)).
+ - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line614-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line158-0)).
- Viewing uncommited changes in a vimdiff, as well as changes between
- specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line402-0)). It is also possible to open multiple
+ specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line415-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#line239-0)). Output is highly customizable.
- - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line363-0)).
+ - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line376-0)).
- Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line99-0)), commit messages are remembered in case of
- rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line883-0)).
+ rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line896-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#line189-0)).
- - [aurum#changeset()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line450-0), [aurum#repository()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line446-0) and [aurum#status()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line454-0) functions
+ - [aurum#changeset()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line463-0), [aurum#repository()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line459-0) and [aurum#status()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line467-0) 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#line756-0)),
+Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line769-0)),
all mappings are customizable.
View
@@ -356,6 +356,19 @@ AuName[!] {name} {opts} [{rev}] *:AuName*
Default: disabled.
repo Path. Repository that should be operated upon.
+AuOther[!] {action} [{rev}[ {url}[ {repo}]]] *:AuOther*
+ Push, pull or view what will be pushed or pulled. {rev} determines
+ revision to be pushed/pulled, {url} determines where it should be pushed
+ to/pulled from. If bang is present, then push even to unrelated
+ repositories. Use ":" instead of any optional argument to get the same
+ behavior as if it was not specified.
+ Possible actions:
+ Action Description ~
+ push Push
+ pull Pull
+ outgoing View what will be pushed if you replace “outgoing” with “push”
+ incoming View what will be pulled if you replace “incoming” with “pull”
+
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).
@@ -1466,6 +1479,15 @@ functions :: {String : FRef} *aurum-repo.functions*
reltorepo :: path -> path *aurum-rf-reltorepo*
Turn absolute or relative to current directory path into relative to
repository root one.
+ push :: dryrun, force[, url[, rev]] -> _ *aurum-rf-push*
+ pull :: dryrun, force[, url[, rev]] -> _ *aurum-rf-pull*
+ Push or pull to given or default URL. If {rev} argument is present, then
+ push/pull only this revision. {dryrun} designates that nothing should be
+ actually done, only what will be done should be shown.
+ Note: unlike other functions, this should expect any possible revision
+ specification.
+ Note 2: if URL is a directory, it is supposed to be related to repository
+ root, not to current working directory.
The following functions do not accept repo argument:
repo :: path -> repo *aurum-rf-repo*
Creates new repository object using repository located at given path.
@@ -1678,8 +1700,10 @@ Python driver was not tested under windows (wine) at all.
2.4: Added {requiresclean} argument to |aurum-rf-status|.
2.5: Added parsecmdarg and crnl resources
3.0: Moved setlines and some other functions to @aurum/lineutils
+ 3.1: Added |aurum-rf-push| and |aurum-rf-pull|
@aurum:
- 0.1: Added :AuBranch and :AuName.
+ 0.1: Added |:AuBranch| and |:AuName|.
+ 0.2: Added |:AuOther|.
@aurum/edit:
1.0: Removed setlines function (moved it to @aurum/repo).
1.1: Added “requiresbvar” _f.newcommand option.
View
@@ -2,15 +2,15 @@
scriptencoding utf-8
if !exists('s:_pluginloaded')
"▶2 frawor#Setup
- execute frawor#Setup('0.1', {'@/commands': '0.0',
+ execute frawor#Setup('0.2', {'@/commands': '0.0',
\ '@/functions': '0.0',
\ '@/table': '0.0',
\ '@/mappings': '0.0',
\ '@/options': '0.0',
\ '@/os': '0.1',
\ '@aurum/cmdutils': '0.0',
\ '@/fwc': '0.2',
- \ '@aurum/repo': '3.0',
+ \ '@aurum/repo': '3.1',
\ '@aurum/edit': '1.0',
\ '@aurum/bufvars': '0.0',}, 0)
"▶2 Команды
@@ -20,9 +20,10 @@ if !exists('s:_pluginloaded')
" TODO :AuMerge ?
" TODO :AuExplore
let s:addargs={'Update': {'bang': 1}, 'Move': {'bang': 1},
- \ 'Branch': {'bang': 1}, 'Name': {'bang': 1}}
+ \ 'Branch': {'bang': 1}, 'Name': {'bang': 1},
+ \ 'Other': {'bang': 1}}
for s:cmd in ['Update', 'Move', 'Junk', 'Track', 'Hyperlink', 'Grep',
- \ 'Branch', 'Name']
+ \ 'Branch', 'Name', 'Other']
let s:part=tolower(s:cmd[:3])
if len(s:cmd)>4 && stridx('aeiouy', s:part[-1:])!=-1
let s:part=s:part[:-2]
@@ -591,6 +592,31 @@ let s:namefunc['@FWC']=['-onlystrings _ '.
\ '} '.
\ '+ type ""', 'filter']
call add(s:namecomp, s:namefunc['@FWC'][0])
+"▶1 othfunc
+let s:pushactions=['push', 'outgoing']
+let s:pullactions=['pull', 'incoming']
+let s:ppactions=s:pushactions+s:pullactions
+function s:othfunc.function(bang, action, rev, url, repo)
+ let repo=s:_r.repo.get(a:repo)
+ call s:_r.cmdutils.checkrepo(repo)
+ if a:url isnot# ':' && stridx(a:url, '://')==-1 && isdirectory(a:url)
+ let url=s:_r.os.path.realpath(a:url)
+ else
+ let url=a:url
+ endif
+ let key=((index(s:pushactions, a:action)==-1)?('pull'):('push'))
+ return repo.functions[key](repo, (a:action[0] isnot# 'p'), a:bang,
+ \ (( url is# ':')?(0):( url)),
+ \ ((a:rev is# ':')?(0):(a:rev)))
+endfunction
+let s:othfunc['@FWC']=['-onlystrings _ '.
+ \ 'in ppactions ~ smart '.
+ \ '[:":" type "" '.
+ \ '[:":" type "" '.
+ \ '['.s:_r.cmdutils.nogetrepoarg.']]]', 'filter']
+call add(s:othcomp, substitute(substitute(s:othfunc['@FWC'][0],
+ \'\V_ ', '', ''),
+ \'\Vtype ""', s:_r.comp.rev, ''))
"▶1
call frawor#Lockvar(s:, '_pluginloaded,_r')
" vim: ft=vim ts=4 sts=4 et fmr=▶,▲
@@ -49,6 +49,7 @@ let s:_messages={
\ 'nocfg': 'Failed to get property %s of repository %s',
\ 'invrng': 'Range %s..%s is invalid for the repository %s, '.
\ 'as well as reverse',
+ \ 'ppf': 'Failed to run “git %s” for the repository %s: %s',
\}
let s:git={}
"▶1 s:hypsites
@@ -653,6 +654,40 @@ function s:git.getrepoprop(repo, prop)
endif
call s:_f.throw('nocfg', a:prop, a:repo.path)
endfunction
+"▶1 pushpull :: cmd, repo, dryrun, force[, URL[, rev]] → + ?
+function s:F.pushpull(cmd, repo, dryrun, force, ...)
+ let kwargs={'all': 1}
+ let args=[]
+ if a:0
+ if a:1 isnot 0
+ let args+=['--', a:1]
+ endif
+ if a:0>1 && a:2 isnot 0
+ if empty(args)
+ let args+=['--', 'origin']
+ endif
+ let args+=[a:2]
+ endif
+ endif
+ if (a:cmd is# 'fetch' && !empty(args)) || len(args)>2
+ unlet kwargs.all
+ endif
+ if a:force
+ let kwargs.force=1
+ endif
+ if a:dryrun
+ let kwargs['dry-run']=1
+ endif
+ return s:F.git(a:repo, a:cmd, args, kwargs, 0, 'ppf', a:cmd)
+endfunction
+"▶1 git.push :: repo, dryrun, force[, URL[, rev]]
+function s:git.push(...)
+ return call(s:F.pushpull, ['push']+a:000, {})
+endfunction
+"▶1 git.pull :: repo, dryrun, force[, URL[, rev]]
+function s:git.pull(...)
+ return call(s:F.pushpull, ['fetch']+a:000, {})
+endfunction
"▶1 git.repo :: path → repo
function s:git.repo(path)
let repo={'path': a:path, 'changesets': {}, 'cslist': [],
@@ -769,7 +769,9 @@ function s:hg.grep(repo, pattern, files, revisions, ignore_case, wdfiles)
\ '("--rev=".join(v:val, "..")):'.
\ '("--rev=".v:val))')+
\['--', a:pattern]+a:files
- let kwargs={'follow': 1, 'line-number': 1}
+ let kwargs={'line-number': 1}
+ let allfiles=a:repo.functions.getcsprop(a:repo, '.', 'allfiles')
+ let kwargs.follow=empty(filter(copy(a:files), 'index(allfiles, v:val)==-1'))
if a:ignore_case
let kwargs['ignore-case']=1
endif
@@ -988,6 +990,35 @@ function s:hg.getrepoprop(repo, prop)
call s:_f.throw('nocfg', a:prop, a:repo.path)
endfunction
endif
+"▶1 pushpull :: cmd, repo, force[, URL[, rev]] → + ?
+function s:F.pushpull(cmd, repo, force, ...)
+ let kwargs={}
+ let args=[]
+ if a:0
+ if a:1 isnot 0
+ let args+=[a:1]
+ endif
+ if a:0>1 && a:2 isnot 0
+ let kwargs.rev=''.a:2
+ endif
+ endif
+ if a:force
+ let kwargs.force=1
+ elseif a:cmd is# 'push'
+ let kwargs['new-branch']=1
+ endif
+ return s:F.runcmd(a:repo, a:cmd, args, kwargs)
+endfunction
+"▶1 hg.push :: repo, dryrun, force[, URL[, rev]]
+function s:hg.push(repo, dryrun, ...)
+ return call(s:F.pushpull, [((a:dryrun)?('outgoing'):
+ \ ('push')), a:repo]+a:000, {})
+endfunction
+"▶1 hg.pull :: repo, dryrun, force[, URL[, rev]]
+function s:hg.pull(repo, dryrun, ...)
+ return call(s:F.pushpull, [((a:dryrun)?('incoming'):
+ \ ('pull')), a:repo]+a:000, {})
+endfunction
"▶1 hg.repo :: path + ? → repo
if s:usepythondriver "▶2
function s:hg.repo(path)
@@ -45,7 +45,10 @@ function s:filefunc.function(rev, file, opts)
let rev=repo.functions.getrevhex(repo, a:rev)
endif
if get(a:opts, 'replace', 0)
+ let winview=winsaveview()
+ silent %delete _
call s:_r.lineutils.setlines(repo.functions.readfile(repo, rev, file),0)
+ call winrestview(winview)
return
endif
if hasbuf
@@ -117,7 +117,12 @@ function s:recfunc.function(opts, ...)
let bvar.getwnrs=s:F.getwnrs
let bvar.recrunmap=s:F.runstatmap
let bvar.write=s:F.write
- let bvar.savedundolevels=&undolevels
+ let bvar.savedopts={'undolevels': &undolevels,
+ \ 'scrollopt': &scrollopt,
+ \ 'autowrite': &autowrite,
+ \ 'autowriteall': &autowriteall,
+ \ 'autoread': &autoread,}
+ setglobal noautowrite noautowriteall noautoread
if !bvar.startundo
setglobal undolevels=-1
endif
@@ -198,7 +203,9 @@ endfunction
"▶1 unload
function s:F.unload(bvar)
let sbvar=get(a:bvar, 'sbvar', a:bvar)
- let &g:undolevels=sbvar.savedundolevels
+ for [o, val] in items(sbvar.savedopts)
+ execute 'let &g:'.o.'=val'
+ endfor
if bufexists(sbvar.bufnr)
call setbufvar(sbvar.bufnr, '&modified', 0)
endif
@@ -484,7 +491,7 @@ function s:F.runstatmap(action, ...)
endif
silent write
if isexe && s:_r.os.name is# 'posix'
- call s:_r.os.run(['chmod', '+x', fullpath])
+ call system('chmod +x '.fnameescape(fullpath))
endif
endif
if !has_key(s:_r.bufvars, bufnr('%'))
@@ -1,7 +1,7 @@
"▶1
scriptencoding utf-8
if !exists('s:_pluginloaded')
- execute frawor#Setup('3.0', {'@/resources': '0.0',
+ execute frawor#Setup('3.1', {'@/resources': '0.0',
\ '@/os': '0.0',
\ '@/options': '0.0',
\ '@aurum/lineutils': '0.0',
@@ -490,7 +490,8 @@ call s:_f.postresource('repo', {'get': s:F.getrepo,
"▶1 regdriver feature
let s:requiredfuncs=['repo', 'getcs', 'checkdir']
let s:optfuncs=['readfile', 'annotate', 'diff', 'status', 'commit', 'update',
- \ 'dirty', 'diffre', 'getrepoprop', 'forget', 'branch', 'label']
+ \ 'dirty', 'diffre', 'getrepoprop', 'forget', 'branch', 'label',
+ \ 'push', 'pull']
"▶2 regdriver :: {f}, name, funcs → + s:drivers
function s:F.regdriver(plugdict, fdict, name, funcs)
"▶3 Check arguments
View
@@ -230,8 +230,10 @@ def run_in_dir(dir, func, *args, **kwargs):
pass
except OSError:
pass
- func(*args, **kwargs)
- os.chdir(workdir)
+ try:
+ func(*args, **kwargs)
+ finally:
+ os.chdir(workdir)
def dodiff(ui, path, rev1, rev2, files, opts):
repo=g_repo(path)
@@ -398,7 +400,12 @@ def call_cmd(path, attr, *args, **kwargs):
kwargs['force']=bool(kwargs['force'])
else:
kwargs['force']=False
- cargs=[PrintUI(), repo]
+ if 'bundle' not in kwargs:
+ kwargs['bundle']=None
+ for key in [key for key in kwargs if key.find('-')!=-1]:
+ newkey=key.replace('-', '_')
+ kwargs[newkey]=kwargs.pop(key)
+ cargs=[repo.ui, repo]
cargs.extend(args)
run_in_dir(repo.root, commands.__getattribute__(attr),
*cargs, **kwargs)
@@ -416,7 +423,9 @@ def grep(path, pattern, files, revisions=None, ignore_case=False, wdfiles=True):
if not revisions:
revisions=None
kwargs={'rev': revisions, 'ignore_case': bool(ignore_case),
- 'line_number': True, 'follow': True, 'print0': True}
+ 'line_number': True, 'print0': True}
+ cs=g_cs(repo, '.')
+ kwargs['follow']=not [f for f in files if f not in cs]
run_in_dir(repo.root, commands.grep, *args, **kwargs)
items=(ui._getCaptured(verbatim=True)).split("\0")
# XXX grep uses "\0" as a terminator, thus last line ends with "\0"

0 comments on commit cb744d9

Please sign in to comment.