NavicoOS / ac2git

Tool to convert an AccuRev repository to Git.
29 stars 15 forks source link

"KeyError: 'DB Encoding' #105

Closed wilmargh closed 7 years ago

wilmargh commented 7 years ago

KeyError: 'DB Encoding' ?? What does this refer to?

c:\GitHub_stand_alone\ac2git>go

c:\GitHub_stand_alone\ac2git>REM

c:\GitHub_stand_alone\ac2git>python ac2git.py -v -m warn
Config info:
  now: 2017-06-26 15:55:13.960414
  filename: ac2git.config.xml
  git:
    repo path: C:\GitHub_stand_alone\Git_Accurev
    message style: notes
    message key: footer
    author is committer: False
    empty child stream action: merge
    source stream fast forward: False
    source stream inferrence: False
    new basis is first parent: True
  accurev:
    depot: Symetra
    stream list:
      - sym_bidm_int_G_wilmar -> sym_bidm_int_G_wilmar
    start tran.: #1
    end tran.:   #now
    username: wilmar
    command cache: command_cache.sqlite3
    ignored transaction types (hard-coded): archive, compress, defcomp, dispatch, unarchive
    excluded stream types: workspace
  method: diff
  merge strategy: normal
  usermaps: 1
  log file: accurev2git.log
  verbose:  True
Start:
fatal: Not a git repository (or any of the parent directories): .git
Creating new git repository.
Created a new git repository.
New git repository. Initial commit on branch master
Running time was  0:00:01.49
The script has encountered an exception, aborting!
Traceback (most recent call last):
  File "ac2git.py", line 4082, in AccuRev2GitMain
    rv = state.Start(isRestart=args.restart, isSoftRestart=args.softRestart)
  File "ac2git.py", line 3271, in Start
    acInfo = accurev.info()
  File "c:\GitHub_stand_alone\ac2git\accurev.py", line 2280, in info
    return obj.Info.fromstring(outputString)
  File "c:\GitHub_stand_alone\ac2git\accurev.py", line 1458, in fromstring
    , dbEncoding=itemMap["DB Encoding"]     \
KeyError: 'DB Encoding'
Traceback (most recent call last):
  File "ac2git.py", line 4102, in <module>
    AccuRev2GitMain(sys.argv)
  File "ac2git.py", line 4082, in AccuRev2GitMain
    rv = state.Start(isRestart=args.restart, isSoftRestart=args.softRestart)
  File "ac2git.py", line 3271, in Start
    acInfo = accurev.info()
  File "c:\GitHub_stand_alone\ac2git\accurev.py", line 2280, in info
    return obj.Info.fromstring(outputString)
  File "c:\GitHub_stand_alone\ac2git\accurev.py", line 1458, in fromstring
    , dbEncoding=itemMap["DB Encoding"]     \
KeyError: 'DB Encoding'
orao commented 7 years ago

It means that on line 1458 the processing of the accurev info command failed to find the string DB Encoding:. Can you run the accurev info command and post the output here? Remember to redact any sensitive information, but please leave the general structure and Accurev fields as they are.

The solution will be to change the dictionary element access from the [] to use the .get() like we do on line 1463 which should make the script assign the value None to the variable when this field is missing. This field has no use in the rest of the script so it should be safe to ignore using the change described..

wilmargh commented 7 years ago

Thanks - first, let me say thanks for your generosity in taking the time to help. I appreciate it very much. The .get() fixed it as you said. The problem now is that it's not finding the Accurev stream. We are now entering an area where the problem is that I don't really understand Accurev very deeply. (We use it only for basic source control, and are now just trying to get away from it). So I'm not sure what to tell ac2git to do.

Anyway, here's accurev info: image

And here's the latest log:

accurev2git.log.txt

And here is a view of the streams. One issue could be (?) that I don't have permissions to access the _PRD stream. I don't care about that, but maybe ac2git does. ?? I only care about the _G_wilmar stream.

image

orao commented 7 years ago

If you only care about one stream then you should use the configuration file to specify only the stream you're interested in. The script is able to autogenerate an example config file for you, and this is documented in the help:

./ac2git.py --help

The example config file is in XML and will have a lot of comments explaining its different options.

The script definitely assumes you have permission to access all the streams. If that's not the case, you will want to restrict it to only process some of the streams. This is done in the config file.

You will be interested in the <streams> section where you'll need to specify only the streams that you want the script to process and convert to Git.

wilmargh commented 7 years ago

Thanks. I did specify a single stream in the config file. ac2git can't find that stream. Here's my config file:

ac2git.config.xml.txt

orao commented 7 years ago

From the screenshot you gave us earlier it seems to me like this stream is actually a workspace. Also, it seems like there is different capitalization in the stream name in the config file. IIRC Accurev stream names are case sensitive. You have:

<stream>sym_bidm_int_G_wilmar</stream>

in the config file and from what is shown in the screenshot the stream name should be:

 <stream>sym_BIDM_INT_G_wilmar</stream>

Would you mind trying that and posting any errors that show up?

You can prove this by trying the following two accurev commands:

accurev show streams -s "sym_bidm_int_G_wilmar"

which should fail, and return no streams.

accurev show streams -s "sym_BIDM_INT_G_wilmar"

which should succeed and print some information about your workspace, if I'm right.

Side note:

In your configuration file you specify that you wish to exclude workspaces from processing with the <stream-list exclude-types="workspace"> line. However, this code seems to ignore the exclusions when streams are explicitly specified, like what you have. Regardless, you could remove or comment out the exclude-types="workspace" part of the config file.

orao commented 7 years ago

@wilmargh do you have any updates on this issue? If it has been resolved, can you please close it?

wilmargh commented 7 years ago

Hi - thanks.! It worked and I was able to create the Git repository from Accurev. All I had to do was fix the case in the stream list in the config file. (I should have thought of that!)

orao commented 7 years ago

Glad we could help. Thanks for letting us know about the problem and working through it with us.